2022-12-25 23:32:34 +02:00
|
|
|
require "redcarpet"
|
|
|
|
|
2022-11-21 12:10:04 +02:00
|
|
|
module ApplicationHelper
|
2022-12-25 14:13:11 +02:00
|
|
|
|
2022-12-25 23:32:34 +02:00
|
|
|
def renderer
|
|
|
|
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)
|
|
|
|
Redcarpet::Markdown.new(html, options)
|
|
|
|
end
|
|
|
|
|
2022-12-25 14:13:11 +02:00
|
|
|
def markdown(text)
|
2022-12-25 23:32:34 +02:00
|
|
|
text = text.text unless text.is_a?(String)
|
|
|
|
return "" if text.blank?
|
|
|
|
self.renderer.render(text).html_safe
|
2022-12-25 14:13:11 +02:00
|
|
|
end
|
2022-12-25 23:32:34 +02:00
|
|
|
|
2022-12-21 00:34:11 +02:00
|
|
|
def main_app
|
|
|
|
Rails.application.routes.url_helpers
|
|
|
|
end
|
2022-12-25 23:32:34 +02:00
|
|
|
|
2022-11-21 12:10:04 +02:00
|
|
|
end
|