Refactor Earmark code, fix tests

This commit is contained in:
Alex Gleason 2020-10-13 14:27:50 -05:00 committed by Mark Felder
commit f8c93246d6
6 changed files with 14 additions and 8 deletions

View file

@ -121,6 +121,10 @@ defmodule Pleroma.Formatter do
end
end
def markdown_to_html(text) do
Earmark.as_html!(text)
end
def html_escape({text, mentions, hashtags}, type) do
{html_escape(text, type), mentions, hashtags}
end

View file

@ -95,7 +95,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.AudioVideoValidator do
when is_binary(content) do
content =
content
|> Earmark.as_html!()
|> Pleroma.Formatter.markdown_to_html()
|> Pleroma.HTML.filter_tags()
Map.put(data, "content", content)

View file

@ -294,7 +294,7 @@ defmodule Pleroma.Web.CommonAPI.Utils do
def format_input(text, "text/markdown", options) do
text
|> Formatter.mentions_escape(options)
|> Earmark.as_html!()
|> Formatter.markdown_to_html()
|> Formatter.linkify(options)
|> Formatter.minify("text/html")
|> Formatter.html_escape("text/html")