mirror of
https://github.com/discourse/discourse.git
synced 2025-05-30 15:28:37 +08:00
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:
@ -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());
|
||||
});
|
||||
|
Reference in New Issue
Block a user