Render descriptions as Markdown

This commit is contained in:
ricola 2025-09-27 18:57:36 +02:00
parent 5fa73da51a
commit 481a643748
10 changed files with 42 additions and 12 deletions

View file

@ -6,6 +6,7 @@ require 'securerandom'
require 'chartkick'
require 'mail'
require 'tzinfo'
require 'redcarpet'
include GetText
@ -479,4 +480,22 @@ helpers do
def format_date_and_time(timestamp)
"#{TZInfo::Timezone.get(session[:timezone]).to_local(timestamp).strftime('%F %R')} (#{session[:timezone].gsub('_', ' ')})"
end
def markdown(markdown)
renderer = Redcarpet::Render::HTML.new(hard_wrap: true,
filter_html: true,
no_styles: true,
safe_links_only: true)
parser = Redcarpet::Markdown.new(renderer, tables: true,
autolink: true,
strikethrough: true,
space_after_headers: true,
superscript: true,
underline: true,
highlight: true,
quote: true,
footnotes: true)
parser.render(markdown)
end
end