Merge remote-tracking branch 'pleroma/develop' into plug-runtime-dev
[akkoma] / lib / pleroma / formatter.ex
index b0e4a84ae8ed43dfbc243bde53eef0557d93d0b9..764e347ec04583e1d3c6031a6ecba988f0efc134 100644 (file)
@@ -1,5 +1,5 @@
 # Pleroma: A lightweight social networking server
-# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
+# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
 # SPDX-License-Identifier: AGPL-3.0-only
 
 defmodule Pleroma.Formatter do
@@ -121,6 +121,10 @@ defmodule Pleroma.Formatter do
     end
   end
 
+  def markdown_to_html(text) do
+    Earmark.as_html!(text, %Earmark.Options{compact_output: true})
+  end
+
   def html_escape({text, mentions, hashtags}, type) do
     {html_escape(text, type), mentions, hashtags}
   end
@@ -138,14 +142,6 @@ defmodule Pleroma.Formatter do
     |> Enum.join("")
   end
 
-  def minify({text, mentions, hashtags}, type) do
-    {minify(text, type), mentions, hashtags}
-  end
-
-  def minify(text, "text/html") do
-    String.replace(text, "\n", "")
-  end
-
   def truncate(text, max_length \\ 200, omission \\ "...") do
     # Remove trailing whitespace
     text = Regex.replace(~r/([^ \t\r\n])([ \t]+$)/u, text, "\\g{1}")