FIX: Properly convert quotes to Markdown (#8808)

* FIX: Properly convert quotes to Markdown

When quoting a quote it used to convert the quote header, including the
user avatar and username, into a image and some text and then the
contents. This also caused issues when quoting full paragraphs (or when
selecting paragraphs by triple-clicking) because the user avatar and
name from the following quote would also be included.

This commit implements the support necessary to convert
<aside class="quote"> elements to proper Discourse quotes.
This commit is contained in:
Bianca Nenciu
2020-02-07 17:25:23 +02:00
committed by GitHub
parent 6f3952e7f1
commit 88a4d5a2c1
3 changed files with 77 additions and 12 deletions

View File

@ -386,3 +386,30 @@ QUnit.test("converts image lightboxes to markdown", assert => {
assert.equal(toMarkdown(html), markdown);
});
QUnit.test("converts quotes to markdown", assert => {
let html = `
<p>there is a quote below</p>
<aside class="quote no-group" data-username="foo" data-post="1" data-topic="2">
<div class="title" style="cursor: pointer;">
<div class="quote-controls"><span class="svg-icon-title" title="expand/collapse"><svg class="fa d-icon d-icon-chevron-down svg-icon svg-string" xmlns="http://www.w3.org/2000/svg"><use xlink:href="#chevron-down"></use></svg></span><a href="/t/hello-world-i-am-posting-an-image/158/1" title="go to the quoted post" class="back"><svg class="fa d-icon d-icon-arrow-up svg-icon svg-string" xmlns="http://www.w3.org/2000/svg"><use xlink:href="#arrow-up"></use></svg></a></div>
<img alt="" width="20" height="20" src="" class="avatar"> foo:</div>
<blockquote>
<p>this is a quote</p>
</blockquote>
</aside>
<p>there is a quote above</p>
`;
let markdown = `
there is a quote below
[quote="foo, post:1, topic:2"]
this is a quote
[/quote]
there is a quote above
`;
assert.equal(toMarkdown(html), markdown.trim());
});