mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: [code] blocks with # headers within
This commit is contained in:
@@ -99,7 +99,7 @@ Discourse.Dialect.replaceBlock({
|
||||
stop: '[/code]',
|
||||
|
||||
emitter: function(blockContents) {
|
||||
return ['p', ['pre'].concat(blockContents)];
|
||||
return ['p', ['pre'].concat(blockContents.join("\n"))];
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -46,6 +46,7 @@ Discourse.Dialect.replaceBlock({
|
||||
});
|
||||
}
|
||||
|
||||
// If there's no username just return a simple quote
|
||||
if (!username) {
|
||||
return ['p', ['aside', params, contents ]];
|
||||
}
|
||||
|
||||
@@ -11,8 +11,6 @@ test('basic bbcode', function() {
|
||||
format("[i]emphasis[/i]", "<span class=\"bbcode-i\">emphasis</span>", "italics text");
|
||||
format("[u]underlined[/u]", "<span class=\"bbcode-u\">underlined</span>", "underlines text");
|
||||
format("[s]strikethrough[/s]", "<span class=\"bbcode-s\">strikethrough</span>", "strikes-through text");
|
||||
format("[code]\nx++\n[/code]", "<pre>\nx++</pre>", "makes code into pre");
|
||||
format("[code]\nx++\ny++\nz++\n[/code]", "<pre>\nx++\ny++\nz++</pre>", "makes code into pre");
|
||||
format("[spoiler]it's a sled[/spoiler]", "<span class=\"spoiler\">it's a sled</span>", "supports spoiler tags");
|
||||
format("[img]http://eviltrout.com/eviltrout.png[/img]", "<img src=\"http://eviltrout.com/eviltrout.png\"/>", "links images");
|
||||
format("[url]http://bettercallsaul.com[/url]", "<a href=\"http://bettercallsaul.com\">http://bettercallsaul.com</a>", "supports [url] without a title");
|
||||
@@ -27,6 +25,12 @@ test('invalid bbcode', function() {
|
||||
equal(cooked, "<p>[code]I am not closed</p>\n\n<p>This text exists.</p>", "does not raise an error with an open bbcode tag.");
|
||||
});
|
||||
|
||||
test('code', function() {
|
||||
format("[code]\nx++\n[/code]", "<pre>\nx++</pre>", "makes code into pre");
|
||||
format("[code]\nx++\ny++\nz++\n[/code]", "<pre>\nx++\ny++\nz++</pre>", "makes code into pre");
|
||||
format("[code]abc\n#def\n[/code]", '<pre>abc\n#def</pre>', 'it handles headings in a [code] block');
|
||||
});
|
||||
|
||||
test('lists', function() {
|
||||
format("[ul][li]option one[/li][/ul]", "<ul><li>option one</li></ul>", "creates an ul");
|
||||
format("[ol][li]option one[/li][/ol]", "<ol><li>option one</li></ol>", "creates an ol");
|
||||
|
||||
Reference in New Issue
Block a user