feat(messages): render markdown in message body

uses redcarpet gem to render markdown to html. Also a html email template
is added.
This commit is contained in:
Philipp Rothmann 2023-01-30 13:14:37 +01:00 committed by Gitea
parent a7747c9e84
commit 0a2f528269
7 changed files with 37 additions and 4 deletions

View file

@ -263,4 +263,26 @@ module ApplicationHelper
stylesheet_link_tag foodcoop_css_path, media: 'all'
end
end
# renders html from markdown input
def markdown(text)
options = {
filter_html: true,
hard_wrap: true,
link_attributes: { rel: 'nofollow', target: "_blank" },
fenced_code_blocks: true
}
extensions = {
autolink: true,
superscript: true,
disable_indented_code_blocks: true,
tables: true,
strikethrough: true,
footnotes: true
}
renderer = ::Redcarpet::Render::HTML.new(options)
markdown = ::Redcarpet::Markdown.new(renderer, extensions)
markdown.render(text).html_safe
end
end