Refactor Earmark code, fix tests
This commit is contained in:
parent
b2548cfcda
commit
f8c93246d6
6 changed files with 14 additions and 8 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue