mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 03:16:41 +08:00
move BBCode formating before the markdown conversion
This commit is contained in:
parent
da52ac88b0
commit
3d2ef18bb7
|
@ -109,7 +109,8 @@ Discourse.Markdown = {
|
|||
|
||||
// Extract quotes so their contents are not passed through markdown.
|
||||
converter.hooks.chain("preConversion", function(text) {
|
||||
var extracted = Discourse.BBCode.extractQuotes(text);
|
||||
var formated = Discourse.BBCode.format(text, opts);
|
||||
var extracted = Discourse.BBCode.extractQuotes(formated);
|
||||
quoteTemplate = extracted.template;
|
||||
return extracted.text;
|
||||
});
|
||||
|
@ -184,7 +185,7 @@ Discourse.Markdown = {
|
|||
text = quoteTemplate(text);
|
||||
}
|
||||
|
||||
return Discourse.BBCode.format(text, opts);
|
||||
return text;
|
||||
});
|
||||
|
||||
if (opts.sanitize) {
|
||||
|
|
|
@ -68,14 +68,14 @@ test("Links", function() {
|
|||
test("Quotes", function() {
|
||||
cookedOptions("1[quote=\"bob, post:1\"]my quote[/quote]2",
|
||||
{ topicId: 2, lookupAvatar: function(name) { return "" + name; } },
|
||||
"<p>1</p><aside class='quote' data-post=\"1\" >\n <div class='title'>\n <div class='quote-controls'></div>\n" +
|
||||
" bob\n bob\n said:\n </div>\n <blockquote>my quote</blockquote>\n</aside>\n<p> <br>\n2</p>",
|
||||
"<p>1</p><aside class='quote' data-post=\"1\" > <br>\n <div class='title'>\n <div class='quote-controls'></div>\n" +
|
||||
" bob\n bob\n said:\n </div>\n <blockquote>my quote</blockquote>\n</aside> <br>\n<p>2</p>",
|
||||
"handles quotes properly");
|
||||
|
||||
cookedOptions("1[quote=\"bob, post:1\"]my quote[/quote]2",
|
||||
{ topicId: 2, lookupAvatar: function(name) { } },
|
||||
"<p>1</p><aside class='quote' data-post=\"1\" >\n <div class='title'>\n <div class='quote-controls'></div>\n" +
|
||||
" \n bob\n said:\n </div>\n <blockquote>my quote</blockquote>\n</aside>\n<p> <br>\n2</p>",
|
||||
"<p>1</p><aside class='quote' data-post=\"1\" > <br>\n <div class='title'>\n <div class='quote-controls'></div></p>\n" +
|
||||
"\n<p>bob\n said:\n </div>\n <blockquote>my quote</blockquote>\n</aside> <br>\n<p>2</p>",
|
||||
"includes no avatar if none is found");
|
||||
});
|
||||
|
||||
|
@ -118,4 +118,10 @@ test("SanitizeHTML", function() {
|
|||
equal(sanitizeHtml("<div><script>alert('hi');</script></div>"), "<div></div>");
|
||||
equal(sanitizeHtml("<div><p class=\"funky\" wrong='1'>hello</p></div>"), "<div><p class=\"funky\">hello</p></div>");
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
test("with BBCode", function() {
|
||||
cooked("[img]http://eviltrout.com/eviltrout.png[/img]",
|
||||
"<p><img src=\"http://eviltrout.com/eviltrout.png\"></p>",
|
||||
"BBCode is parsed first");
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Block a user