all text markdown with redcarpet

This commit is contained in:
2022-12-08 19:34:49 +02:00
parent 308b9e1d2e
commit c669cf5cfe
14 changed files with 32 additions and 13 deletions

View File

@ -1,5 +1,23 @@
require "redcarpet"
module Merged
module MergedHelper
@@renderer = nil
def renderer
return @@renderer unless @@renderer.nil?
options = {hard_wrap: true , autolink: true, no_intra_emphasis: true ,
safe_links_only: true, no_styles: true ,
link_attributes: { target: '_blank' }}
html = Redcarpet::Render::HTML.new(options)
@@renderer = Redcarpet::Markdown.new(html, options)
end
def markdown(text)
text = text.text unless text.is_a?(String)
return "" if text.blank?
renderer.render(text).html_safe
end
def blue_button( text, url)
button( text , url , "bg-blue-500" )
end