shuffling code so it can be reused outside the engine

This commit is contained in:
2023-01-15 21:23:36 +02:00
parent ab1f8ef4a8
commit c58b5fc4ba
4 changed files with 45 additions and 43 deletions

View File

@ -4,6 +4,7 @@ require "ruby2js/es2015"
require "ruby2js/filter/functions"
require "ruby2js/haml"
require "ruby2js/filter/vue"
require "merged/shared_helper"
module Merged
class Engine < ::Rails::Engine

View File

@ -0,0 +1,34 @@
require "redcarpet"
module Merged
module SharedHelper
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
def prose_classes
classes = "prose lg:prose-lg "
classes += "prose-headings:text-inherit "
{ class: classes }
end
def markdown_image(section)
return "" unless section.text
down = self.renderer.render(section.text)
image = image_for(section)
down.gsub("IMAGE" , image).html_safe
end
def markdown(text)
text = text.text unless text.is_a?(String)
return "" if text.blank?
self.renderer.render(text).html_safe
end
end
end