Files
chatwoot/lib/chatwoot_markdown_renderer.rb
Nithin David Thomas e6a49b5800 feat: Shows Youtube and Vimeo links as embeds [cw-1393] (#7330)
This change will render the youbtube, vimeo and .mp4 urls as embedded in the article page in the help centre.

Fixes: https://linear.app/chatwoot/issue/CW-1393/help-center-support-video-upload-in-articles

Co-authored-by: Sojan <sojan@pepalo.com>
2023-06-21 20:28:28 +05:30

27 lines
549 B
Ruby

class ChatwootMarkdownRenderer
def initialize(content)
@content = content
end
def render_message
html = CommonMarker.render_html(@content)
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