|> Enum.join("")
end
- def minify({text, mentions, hashtags}, type) do
- {minify(text, type), mentions, hashtags}
- end
-
- def minify(text, "text/html") do
- text
- |> String.replace(">\n", ">")
- |> String.replace("> ", ">")
- |> String.replace(" <", "<")
- end
-
def truncate(text, max_length \\ 200, omission \\ "...") do
# Remove trailing whitespace
text = Regex.replace(~r/([^ \t\r\n])([ \t]+$)/u, text, "\\g{1}")
|> Formatter.mentions_escape(options)
|> Formatter.markdown_to_html()
|> Formatter.linkify(options)
- |> Formatter.minify("text/html")
|> Formatter.html_escape("text/html")
end
assert Formatter.html_escape(text, "text/plain") == expected
end
-
- test "it minifies html" do
- text = "<p>\nhello</p>\n<p>\nworld</p>\n"
- expected = "<p>hello</p><p>world</p>"
-
- assert Formatter.minify(text, "text/html") == expected
- end
end