allow small/center tags in misskeymarkdown (#132)
[akkoma] / lib / pleroma / web / common_api / utils.ex
index f5bc3acf553a23ff178934da486c448500eb82a5..826160a23c0c3783ceffaaf184aab8a9380e98f2 100644 (file)
@@ -259,8 +259,7 @@ defmodule Pleroma.Web.CommonAPI.Utils do
   @doc """
   Formatting text to plain text, BBCode, HTML, or Markdown
   """
-  def format_input(text, format, options)
-      when format in ["text/plain", "text/x.misskeymarkdown"] do
+  def format_input(text, "text/plain", options) do
     text
     |> Formatter.html_escape("text/plain")
     |> Formatter.linkify(options)
@@ -284,6 +283,15 @@ defmodule Pleroma.Web.CommonAPI.Utils do
     |> Formatter.linkify(options)
   end
 
+  def format_input(text, "text/x.misskeymarkdown", options) do
+    text
+    |> Formatter.linkify(options)
+    |> Formatter.html_escape("text/x.misskeymarkdown")
+    |> (fn {text, mentions, tags} ->
+          {String.replace(text, ~r/\r?\n/, "<br>"), mentions, tags}
+        end).()
+  end
+
   def format_input(text, "text/markdown", options) do
     text
     |> Formatter.mentions_escape(options)