Allow authoring MFM
[akkoma] / lib / pleroma / web / common_api / utils.ex
index b6feaf32a6304ac66a37690838cbeb531a27e85a..8fde9ae156efb615addc05c51e2bbb10718382a6 100644 (file)
@@ -291,6 +291,15 @@ defmodule Pleroma.Web.CommonAPI.Utils do
     |> Formatter.html_escape("text/html")
   end
 
+  def format_input(text, "text/x.misskeymarkdown", options) do
+    text
+    |> Formatter.html_escape("text/plain")
+    |> Formatter.linkify(options)
+    |> (fn {text, mentions, tags} ->
+          {String.replace(text, ~r/\r?\n/, "<br>"), mentions, tags}
+        end).()
+  end
+
   def format_naive_asctime(date) do
     date |> DateTime.from_naive!("Etc/UTC") |> format_asctime
   end