in dev, allow dev FE
[akkoma] / lib / pleroma / formatter.ex
index ad29d21d77d464622c2bf73b0cf775b5d83accab..fc841a55087f266fe6feb2021f06b82b1a89d287 100644 (file)
@@ -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)