[#58] pre-link MFM content (#59)
[akkoma] / lib / pleroma / web / common_api / utils.ex
index 8fde9ae156efb615addc05c51e2bbb10718382a6..f5bc3acf553a23ff178934da486c448500eb82a5 100644 (file)
@@ -259,7 +259,8 @@ defmodule Pleroma.Web.CommonAPI.Utils do
   @doc """
   Formatting text to plain text, BBCode, HTML, or Markdown
   """
-  def format_input(text, "text/plain", options) do
+  def format_input(text, format, options)
+      when format in ["text/plain", "text/x.misskeymarkdown"] do
     text
     |> Formatter.html_escape("text/plain")
     |> Formatter.linkify(options)
@@ -291,15 +292,6 @@ 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