+ @doc """
+ Formatting text to html.
+ """
+ def format_input(text, mentions, _tags, "text/html") do
+ text
+ |> Formatter.html_escape("text/html")
+ |> String.replace(~r/\r?\n/, "<br>")
+ |> (&{[], &1}).()
+ |> Formatter.add_user_links(mentions)
+ |> Formatter.finalize()
+ end
+
+ @doc """
+ Formatting text to markdown.
+ """
+ def format_input(text, mentions, tags, "text/markdown") do
+ text
+ |> Formatter.mentions_escape(mentions)
+ |> Earmark.as_html!()
+ |> Formatter.html_escape("text/html")
+ |> String.replace(~r/\r?\n/, "")
+ |> (&{[], &1}).()
+ |> Formatter.add_user_links(mentions)
+ |> Formatter.add_hashtag_links(tags)
+ |> Formatter.finalize()
+ end
+