add support for bbcode

This commit is contained in:
William Pitcock 2019-04-26 10:17:57 +00:00
commit 501af917b5
3 changed files with 30 additions and 1 deletions

View 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.
"""