mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-01 19:48:08 +00:00
fix: Renders youtube and vimeo links within blank lines as embeds (#7422)
Within the article we are now rendering every link for youtube and vimeo as embeds. This isn't a good solution, as users might need to have plain links as well. This fix will render only links within two blank lines as embeds. Co-authored-by: Sojan Jose <sojan@pepalo.com>
This commit is contained in:
committed by
GitHub
parent
27fc24375d
commit
53dc38e650
@@ -104,8 +104,8 @@ describe CustomMarkdownRenderer do
|
||||
end
|
||||
|
||||
context 'when multiple links are present' do
|
||||
it 'renders all links' do
|
||||
markdown = '[youtube](https://www.youtube.com/watch?v=VIDEO_ID) [vimeo](https://vimeo.com/1234567) ^ hello ^ [normal](https://example.com)'
|
||||
it 'renders all links when present between empty lines' do
|
||||
markdown = "\n[youtube](https://www.youtube.com/watch?v=VIDEO_ID)\n\n[vimeo](https://vimeo.com/1234567)\n^ hello ^ [normal](https://example.com)"
|
||||
output = render_markdown(markdown)
|
||||
expect(output).to include('src="https://www.youtube.com/embed/VIDEO_ID"')
|
||||
expect(output).to include('src="https://player.vimeo.com/video/1234567"')
|
||||
@@ -113,5 +113,15 @@ describe CustomMarkdownRenderer do
|
||||
expect(output).to include('<sup> hello </sup>')
|
||||
end
|
||||
end
|
||||
|
||||
context 'when links within text are present' do
|
||||
it 'renders only text within blank lines as embeds' do
|
||||
markdown = "\n[youtube](https://www.youtube.com/watch?v=VIDEO_ID)\nthis is such an amazing [vimeo](https://vimeo.com/1234567)\n[vimeo](https://vimeo.com/1234567)"
|
||||
output = render_markdown(markdown)
|
||||
expect(output).to include('src="https://www.youtube.com/embed/VIDEO_ID"')
|
||||
expect(output).to include('href="https://vimeo.com/1234567"')
|
||||
expect(output).to include('src="https://player.vimeo.com/video/1234567"')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user