diff options
author | Alex Gleason <alex@alexgleason.me> | 2020-10-13 14:27:50 -0500 |
---|---|---|
committer | Mark Felder <feld@FreeBSD.org> | 2020-12-11 17:22:42 -0600 |
commit | f8c93246d69a193ead81248879ba260e98673b3d (patch) | |
tree | 493fdc9f2b3b4b2aa0734db6a2d7f9fd1b81ac7f /lib | |
parent | b2548cfcdabdcb90bfcc9f4022c0b1cff9157a4a (diff) | |
download | pleroma-f8c93246d69a193ead81248879ba260e98673b3d.tar.gz |
Refactor Earmark code, fix tests
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/formatter.ex | 4 | ||||
-rw-r--r-- | lib/pleroma/web/activity_pub/object_validators/audio_video_validator.ex | 2 | ||||
-rw-r--r-- | lib/pleroma/web/common_api/utils.ex | 2 |
3 files changed, 6 insertions, 2 deletions
diff --git a/lib/pleroma/formatter.ex b/lib/pleroma/formatter.ex index 61906dda6..1be12055f 100644 --- a/lib/pleroma/formatter.ex +++ b/lib/pleroma/formatter.ex @@ -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 diff --git a/lib/pleroma/web/activity_pub/object_validators/audio_video_validator.ex b/lib/pleroma/web/activity_pub/object_validators/audio_video_validator.ex index eaf94797a..9b38aa4c2 100644 --- a/lib/pleroma/web/activity_pub/object_validators/audio_video_validator.ex +++ b/lib/pleroma/web/activity_pub/object_validators/audio_video_validator.ex @@ -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) diff --git a/lib/pleroma/web/common_api/utils.ex b/lib/pleroma/web/common_api/utils.ex index b434a069e..be86009af 100644 --- a/lib/pleroma/web/common_api/utils.ex +++ b/lib/pleroma/web/common_api/utils.ex @@ -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") |