Replace abandoned earmark with mdex for markdown rendering
This commit is contained in:
@@ -546,9 +546,9 @@ defmodule BDS.Desktop.ShellLive.ChatEditor do
|
||||
@spec markdown_html(binary()) :: Phoenix.HTML.Safe.t()
|
||||
def markdown_html(content) when is_binary(content) do
|
||||
html =
|
||||
case Earmark.as_html(content, escape: true) do
|
||||
{:ok, rendered, _messages} -> rendered
|
||||
{:error, rendered, _messages} -> rendered
|
||||
case MDEx.to_html(content) do
|
||||
{:ok, rendered} -> rendered
|
||||
{:error, _reason} -> ""
|
||||
end
|
||||
|> rewrite_external_images()
|
||||
|
||||
|
||||
@@ -279,9 +279,9 @@ defmodule BDS.Desktop.ShellLive.MiscEditor do
|
||||
@spec markdown_html(String.t()) :: Phoenix.HTML.safe()
|
||||
def markdown_html(content) do
|
||||
html =
|
||||
case Earmark.as_html(content || "", escape: true) do
|
||||
{:ok, rendered, _messages} -> rendered
|
||||
{:error, rendered, _messages} -> rendered
|
||||
case MDEx.to_html(content || "") do
|
||||
{:ok, rendered} -> rendered
|
||||
{:error, _reason} -> ""
|
||||
end
|
||||
|
||||
raw(html)
|
||||
|
||||
@@ -180,9 +180,12 @@ defmodule BDS.Rendering.Filters do
|
||||
end
|
||||
|
||||
defp render_markdown_html(markdown) do
|
||||
case Earmark.as_html(markdown) do
|
||||
{:ok, html, _messages} -> html
|
||||
{:error, html, _messages} -> html
|
||||
# Macros above inject raw HTML (gallery, video embeds), so the render path
|
||||
# must pass HTML through untouched. unsafe: true matches the prior Earmark
|
||||
# no-escape behavior.
|
||||
case MDEx.to_html(markdown, render: [unsafe: true]) do
|
||||
{:ok, html} -> html
|
||||
{:error, _reason} -> markdown
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user