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

@ -1,35 +1,8 @@
require "redcarpet"
module Merged
module MergedHelper
include OptionsHelper
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
include SharedHelper
def aspect_ratio image
x , y = image.aspect_ratio