mirror of
https://github.com/discourse/discourse.git
synced 2025-05-29 11:48:08 +08:00
move BBCode formating before the markdown conversion
This commit is contained in:
@ -109,7 +109,8 @@ Discourse.Markdown = {
|
|||||||
|
|
||||||
// Extract quotes so their contents are not passed through markdown.
|
// Extract quotes so their contents are not passed through markdown.
|
||||||
converter.hooks.chain("preConversion", function(text) {
|
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;
|
quoteTemplate = extracted.template;
|
||||||
return extracted.text;
|
return extracted.text;
|
||||||
});
|
});
|
||||||
@ -184,7 +185,7 @@ Discourse.Markdown = {
|
|||||||
text = quoteTemplate(text);
|
text = quoteTemplate(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Discourse.BBCode.format(text, opts);
|
return text;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (opts.sanitize) {
|
if (opts.sanitize) {
|
||||||
|
@ -68,14 +68,14 @@ test("Links", function() {
|
|||||||
test("Quotes", function() {
|
test("Quotes", function() {
|
||||||
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><aside class='quote' data-post=\"1\" >\n <div class='title'>\n <div class='quote-controls'></div>\n" +
|
"<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>\n<p> <br>\n2</p>",
|
" bob\n bob\n said:\n </div>\n <blockquote>my quote</blockquote>\n</aside> <br>\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><aside class='quote' data-post=\"1\" >\n <div class='title'>\n <div class='quote-controls'></div>\n" +
|
"<p>1</p><aside class='quote' data-post=\"1\" > <br>\n <div class='title'>\n <div class='quote-controls'></div></p>\n" +
|
||||||
" \n bob\n said:\n </div>\n <blockquote>my quote</blockquote>\n</aside>\n<p> <br>\n2</p>",
|
"\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");
|
"includes no avatar if none is found");
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -119,3 +119,9 @@ test("SanitizeHTML", function() {
|
|||||||
equal(sanitizeHtml("<div><p class=\"funky\" wrong='1'>hello</p></div>"), "<div><p class=\"funky\">hello</p></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");
|
||||||
|
});
|
||||||
|
Reference in New Issue
Block a user