Merge branch 'changelog/adminfe' into 'develop'
[akkoma] / lib / pleroma / web / common_api / utils.ex
index 887f878c440ed2a6e6550017596c3f3764d1db12..1dfe50b408266efd29f341ac37f5dc3b7b652d53 100644 (file)
@@ -182,6 +182,18 @@ defmodule Pleroma.Web.CommonAPI.Utils do
         end).()
   end
 
+  @doc """
+  Formatting text as BBCode.
+  """
+  def format_input(text, "text/bbcode", options) do
+    text
+    |> String.replace(~r/\r/, "")
+    |> Formatter.html_escape("text/plain")
+    |> BBCode.to_html()
+    |> (fn {:ok, html} -> html end).()
+    |> Formatter.linkify(options)
+  end
+
   @doc """
   Formatting text to html.
   """