X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=lib%2Fpleroma%2Fformatter.ex;h=fc841a55087f266fe6feb2021f06b82b1a89d287;hb=a079ec3a3cdfd42d2cbd51c7698c2c87828e5778;hp=ad29d21d77d464622c2bf73b0cf775b5d83accab;hpb=ff6c8455fb0b64f979cd551fd644c5024c91ccc6;p=akkoma diff --git a/lib/pleroma/formatter.ex b/lib/pleroma/formatter.ex index ad29d21d7..fc841a550 100644 --- a/lib/pleroma/formatter.ex +++ b/lib/pleroma/formatter.ex @@ -124,8 +124,8 @@ defmodule Pleroma.Formatter do end end - def markdown_to_html(text) do - Earmark.as_html!(text, %Earmark.Options{compact_output: true}) + def markdown_to_html(text, opts \\ %{}) do + Earmark.as_html!(text, %Earmark.Options{compact_output: true} |> Map.merge(opts)) end def html_escape({text, mentions, hashtags}, type) do @@ -136,7 +136,12 @@ defmodule Pleroma.Formatter do HTML.filter_tags(text) end - def html_escape(text, format) when format in ["text/plain", "text/x.misskeymarkdown"] do + def html_escape(text, "text/x.misskeymarkdown") do + text + |> HTML.filter_tags() + end + + def html_escape(text, "text/plain") do Regex.split(@link_regex, text, include_captures: true) |> Enum.map_every(2, fn chunk -> {:safe, part} = Phoenix.HTML.html_escape(chunk)