Files
chatwoot/lib/chatwoot_markdown_renderer.rb
Shivam Mishra 36b6c0cb9c feat: support image height in markdown rendering of messages (#8177)
- This PR adds BaseMarkdownRenderer, it takes all the required attributes from the image node, parses the cw_image_height query and renders it.
2023-11-02 13:51:54 -07:00

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