FIX: Too many new lines in long quotes
This commit is contained in:
parent
3f3551f1e2
commit
37304b7eba
|
@ -30,8 +30,16 @@ Discourse.Dialect.replaceBlock({
|
||||||
avatarImg = options.lookupAvatar(username);
|
avatarImg = options.lookupAvatar(username);
|
||||||
}
|
}
|
||||||
|
|
||||||
var contents = this.processInline(blockContents.join(" \n \n"));
|
var contents = ['blockquote'];
|
||||||
contents.unshift('blockquote');
|
if (blockContents.length) {
|
||||||
|
var self = this;
|
||||||
|
blockContents.forEach(function (bc) {
|
||||||
|
var processed = self.processInline(bc);
|
||||||
|
if (processed.length) {
|
||||||
|
contents.push(['p'].concat(processed));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return ['p', ['aside', params,
|
return ['p', ['aside', params,
|
||||||
['div', {'class': 'title'},
|
['div', {'class': 'title'},
|
||||||
|
|
|
@ -14,15 +14,15 @@ describe PrettyText do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "produces a quote even with new lines in it" do
|
it "produces a quote even with new lines in it" do
|
||||||
PrettyText.cook("[quote=\"EvilTrout, post:123, topic:456, full:true\"]ddd\n[/quote]").should match_html "<p><aside class=\"quote\" data-post=\"123\" data-topic=\"456\" data-full=\"true\"><div class=\"title\">\n<div class=\"quote-controls\"></div>\n<img width=\"20\" height=\"20\" src=\"http://test.localhost/uploads/default/avatars/42d/57c/46ce7ee487/40.png\" class=\"avatar\">EvilTrout said:</div>\n<blockquote>ddd</blockquote></aside></p>"
|
PrettyText.cook("[quote=\"EvilTrout, post:123, topic:456, full:true\"]ddd\n[/quote]").should match_html "<p><aside class=\"quote\" data-post=\"123\" data-topic=\"456\" data-full=\"true\"><div class=\"title\">\n<div class=\"quote-controls\"></div>\n<img width=\"20\" height=\"20\" src=\"http://test.localhost/uploads/default/avatars/42d/57c/46ce7ee487/40.png\" class=\"avatar\">EvilTrout said:</div>\n<blockquote><p>ddd</p></blockquote></aside></p>"
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should produce a quote" do
|
it "should produce a quote" do
|
||||||
PrettyText.cook("[quote=\"EvilTrout, post:123, topic:456, full:true\"]ddd[/quote]").should match_html "<p><aside class=\"quote\" data-post=\"123\" data-topic=\"456\" data-full=\"true\"><div class=\"title\">\n<div class=\"quote-controls\"></div>\n<img width=\"20\" height=\"20\" src=\"http://test.localhost/uploads/default/avatars/42d/57c/46ce7ee487/40.png\" class=\"avatar\">EvilTrout said:</div>\n<blockquote>ddd</blockquote></aside></p>"
|
PrettyText.cook("[quote=\"EvilTrout, post:123, topic:456, full:true\"]ddd[/quote]").should match_html "<p><aside class=\"quote\" data-post=\"123\" data-topic=\"456\" data-full=\"true\"><div class=\"title\">\n<div class=\"quote-controls\"></div>\n<img width=\"20\" height=\"20\" src=\"http://test.localhost/uploads/default/avatars/42d/57c/46ce7ee487/40.png\" class=\"avatar\">EvilTrout said:</div>\n<blockquote><p>ddd</p></blockquote></aside></p>"
|
||||||
end
|
end
|
||||||
|
|
||||||
it "trims spaces on quote params" do
|
it "trims spaces on quote params" do
|
||||||
PrettyText.cook("[quote=\"EvilTrout, post:555, topic: 666\"]ddd[/quote]").should match_html "<p><aside class=\"quote\" data-post=\"555\" data-topic=\"666\"><div class=\"title\">\n<div class=\"quote-controls\"></div>\n<img width=\"20\" height=\"20\" src=\"http://test.localhost/uploads/default/avatars/42d/57c/46ce7ee487/40.png\" class=\"avatar\">EvilTrout said:</div>\n<blockquote>ddd</blockquote></aside></p>"
|
PrettyText.cook("[quote=\"EvilTrout, post:555, topic: 666\"]ddd[/quote]").should match_html "<p><aside class=\"quote\" data-post=\"555\" data-topic=\"666\"><div class=\"title\">\n<div class=\"quote-controls\"></div>\n<img width=\"20\" height=\"20\" src=\"http://test.localhost/uploads/default/avatars/42d/57c/46ce7ee487/40.png\" class=\"avatar\">EvilTrout said:</div>\n<blockquote><p>ddd</p></blockquote></aside></p>"
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -83,17 +83,17 @@ test("quote formatting", function() {
|
||||||
|
|
||||||
format("[quote=\"EvilTrout, post:123, topic:456, full:true\"][sam][/quote]",
|
format("[quote=\"EvilTrout, post:123, topic:456, full:true\"][sam][/quote]",
|
||||||
"<aside class=\"quote\" data-post=\"123\" data-topic=\"456\" data-full=\"true\"><div class=\"title\">" +
|
"<aside class=\"quote\" data-post=\"123\" data-topic=\"456\" data-full=\"true\"><div class=\"title\">" +
|
||||||
"<div class=\"quote-controls\"></div>EvilTrout said:</div><blockquote>[sam]</blockquote></aside>",
|
"<div class=\"quote-controls\"></div>EvilTrout said:</div><blockquote><p>[sam]</p></blockquote></aside>",
|
||||||
"it allows quotes with [] inside");
|
"it allows quotes with [] inside");
|
||||||
|
|
||||||
format("[quote=\"eviltrout, post:1, topic:1\"]abc[/quote]",
|
format("[quote=\"eviltrout, post:1, topic:1\"]abc[/quote]",
|
||||||
"<aside class=\"quote\" data-post=\"1\" data-topic=\"1\"><div class=\"title\"><div class=\"quote-controls\"></div>eviltrout said:" +
|
"<aside class=\"quote\" data-post=\"1\" data-topic=\"1\"><div class=\"title\"><div class=\"quote-controls\"></div>eviltrout said:" +
|
||||||
"</div><blockquote>abc</blockquote></aside>",
|
"</div><blockquote><p>abc</p></blockquote></aside>",
|
||||||
"renders quotes properly");
|
"renders quotes properly");
|
||||||
|
|
||||||
format("[quote=\"eviltrout, post:1, topic:1\"]abc[/quote]\nhello",
|
format("[quote=\"eviltrout, post:1, topic:1\"]abc[/quote]\nhello",
|
||||||
"<aside class=\"quote\" data-post=\"1\" data-topic=\"1\"><div class=\"title\"><div class=\"quote-controls\"></div>eviltrout said:" +
|
"<aside class=\"quote\" data-post=\"1\" data-topic=\"1\"><div class=\"title\"><div class=\"quote-controls\"></div>eviltrout said:" +
|
||||||
"</div><blockquote>abc</blockquote></aside></p>\n\n<p>hello",
|
"</div><blockquote><p>abc</p></blockquote></aside></p>\n\n<p>hello",
|
||||||
"handles new lines properly");
|
"handles new lines properly");
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -129,22 +129,22 @@ test("simple quotes", function() {
|
||||||
|
|
||||||
test("Quotes", function() {
|
test("Quotes", function() {
|
||||||
|
|
||||||
cookedOptions("[quote=\"eviltrout, post: 1\"]\na quote\n\nsecond line\n[/quote]",
|
cookedOptions("[quote=\"eviltrout, post: 1\"]\na quote\n\nsecond line\n\nthird line[/quote]",
|
||||||
{ topicId: 2 },
|
{ topicId: 2 },
|
||||||
"<p><aside class=\"quote\" data-post=\"1\"><div class=\"title\"><div class=\"quote-controls\"></div>eviltrout said:</div><blockquote>" +
|
"<p><aside class=\"quote\" data-post=\"1\"><div class=\"title\"><div class=\"quote-controls\"></div>eviltrout said:</div><blockquote>" +
|
||||||
"a quote<br/><br/>second line</blockquote></aside></p>",
|
"<p>a quote</p><p>second line</p><p>third line</p></blockquote></aside></p>",
|
||||||
"works with multiple lines");
|
"works with multiple lines");
|
||||||
|
|
||||||
cookedOptions("1[quote=\"bob, post:1\"]my quote[/quote]2",
|
cookedOptions("1[quote=\"bob, post:1\"]my quote[/quote]2",
|
||||||
{ topicId: 2, lookupAvatar: function(name) { return "" + name; } },
|
{ topicId: 2, lookupAvatar: function(name) { return "" + name; } },
|
||||||
"<p>1</p>\n\n<p><aside class=\"quote\" data-post=\"1\"><div class=\"title\"><div class=\"quote-controls\"></div>bob" +
|
"<p>1</p>\n\n<p><aside class=\"quote\" data-post=\"1\"><div class=\"title\"><div class=\"quote-controls\"></div>bob" +
|
||||||
"bob said:</div><blockquote>my quote</blockquote></aside></p>\n\n<p>2</p>",
|
"bob said:</div><blockquote><p>my quote</p></blockquote></aside></p>\n\n<p>2</p>",
|
||||||
"handles quotes properly");
|
"handles quotes properly");
|
||||||
|
|
||||||
cookedOptions("1[quote=\"bob, post:1\"]my quote[/quote]2",
|
cookedOptions("1[quote=\"bob, post:1\"]my quote[/quote]2",
|
||||||
{ topicId: 2, lookupAvatar: function(name) { } },
|
{ topicId: 2, lookupAvatar: function(name) { } },
|
||||||
"<p>1</p>\n\n<p><aside class=\"quote\" data-post=\"1\"><div class=\"title\"><div class=\"quote-controls\"></div>bob said:" +
|
"<p>1</p>\n\n<p><aside class=\"quote\" data-post=\"1\"><div class=\"title\"><div class=\"quote-controls\"></div>bob said:" +
|
||||||
"</div><blockquote>my quote</blockquote></aside></p>\n\n<p>2</p>",
|
"</div><blockquote><p>my quote</p></blockquote></aside></p>\n\n<p>2</p>",
|
||||||
"includes no avatar if none is found");
|
"includes no avatar if none is found");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue