mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-01 19:48:08 +00:00
- This PR adds BaseMarkdownRenderer, it takes all the required attributes from the image node, parses the cw_image_height query and renders it.
29 lines
647 B
Ruby
29 lines
647 B
Ruby
class ChatwootMarkdownRenderer
|
|
def initialize(content)
|
|
@content = content
|
|
end
|
|
|
|
def render_message
|
|
markdown_renderer = BaseMarkdownRenderer.new
|
|
doc = CommonMarker.render_doc(@content, :DEFAULT)
|
|
html = markdown_renderer.render(doc)
|
|
render_as_html_safe(html)
|
|
end
|
|
|
|
def render_article
|
|
markdown_renderer = CustomMarkdownRenderer.new
|
|
doc = CommonMarker.render_doc(@content, :DEFAULT)
|
|
html = markdown_renderer.render(doc)
|
|
|
|
render_as_html_safe(html)
|
|
end
|
|
|
|
private
|
|
|
|
def render_as_html_safe(html)
|
|
# rubocop:disable Rails/OutputSafety
|
|
html.html_safe
|
|
# rubocop:enable Rails/OutputSafety
|
|
end
|
|
end
|