This repository has been archived on 2023-11-26. You can view files and clone it, but cannot push or open issues or pull requests.
bdfr-browser/lib/bdfr_browser/render_utils.ex

18 lines
385 B
Elixir
Raw Normal View History

2023-08-15 11:09:32 +00:00
defmodule BdfrBrowser.RenderUtils do
def selftext(txt) do
Earmark.as_html!(txt)
end
def comment(cmt) do
Earmark.as_html!(cmt)
end
2023-08-15 11:09:32 +00:00
def message(msg) do
2023-08-15 15:56:02 +00:00
img_replacement = "<img src=\"/chat_media/\\1\" style=\"max-width: 300px;\" alt=\"Image\" />"
2023-08-15 11:09:32 +00:00
msg
|> String.replace(~r/https:\/\/i\.redd\.it\/(.+)/, img_replacement)
|> Earmark.as_html!()
end
end