Use MDEx to consolidate Markdown handling
This commit is contained in:
@@ -157,7 +157,7 @@ defmodule MusicLibraryWeb.Components.Notes do
|
||||
end
|
||||
|
||||
# sobelow_skip ["XSS.Raw"]
|
||||
# Markdown.to_html/1 sanitizes HTML via HtmlSanitizeEx
|
||||
# Markdown.to_html/1 sanitizes HTML via MDEx (ammonia)
|
||||
defp render_content(content) do
|
||||
content
|
||||
|> Markdown.to_html()
|
||||
|
||||
@@ -347,7 +347,7 @@ defmodule MusicLibraryWeb.SearchComponents do
|
||||
end
|
||||
|
||||
# sobelow_skip ["XSS.Raw"]
|
||||
# Markdown.to_html/1 sanitizes HTML via HtmlSanitizeEx
|
||||
# Markdown.to_html/1 sanitizes HTML via MDEx (ammonia)
|
||||
defp render_description(description) do
|
||||
description
|
||||
|> String.slice(0, 100)
|
||||
|
||||
@@ -475,7 +475,7 @@ defmodule MusicLibraryWeb.RecordSetLive.Index do
|
||||
end
|
||||
|
||||
# sobelow_skip ["XSS.Raw"]
|
||||
# Markdown.to_html/1 sanitizes HTML via HtmlSanitizeEx
|
||||
# Markdown.to_html/1 sanitizes HTML via MDEx (ammonia)
|
||||
defp render_description(description) do
|
||||
description
|
||||
|> Markdown.to_html()
|
||||
|
||||
@@ -303,7 +303,7 @@ defmodule MusicLibraryWeb.RecordSetLive.Show do
|
||||
defp page_title(:add_record, record_set), do: gettext("Add Record") <> " · " <> record_set.name
|
||||
|
||||
# sobelow_skip ["XSS.Raw"]
|
||||
# Markdown.to_html/1 sanitizes HTML via HtmlSanitizeEx
|
||||
# Markdown.to_html/1 sanitizes HTML via MDEx (ammonia)
|
||||
defp render_description(description) do
|
||||
description
|
||||
|> Markdown.to_html()
|
||||
|
||||
@@ -21,8 +21,11 @@ defmodule MusicLibraryWeb.Markdown do
|
||||
result =
|
||||
markdown_text
|
||||
|> process_double_bracket_links()
|
||||
|> Earmark.as_html!(%Earmark.Options{gfm: true})
|
||||
|> HtmlSanitizeEx.markdown_html()
|
||||
|> MDEx.to_html!(
|
||||
extension: [autolink: true, strikethrough: true, table: true],
|
||||
render: [unsafe: true],
|
||||
sanitize: MDEx.Document.default_sanitize_options()
|
||||
)
|
||||
|
||||
{result, %{}}
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user