FIX: Quotes inside a list

This commit is contained in:
Robin Ward 2013-09-05 17:03:35 -04:00
parent 341f8c8877
commit 63be950e5f
4 changed files with 25 additions and 16 deletions

View file

@ -25,18 +25,3 @@ replaceMarkdown('*', 'em');
replaceMarkdown('_', 'em');
// There's a weird issue with the markdown parser where it won't process simple blockquotes
// when they are prefixed with spaces. This fixes it.
Discourse.Dialect.on("register", function(event) {
var dialect = event.dialect,
MD = event.MD;
dialect.block["fix_simple_quotes"] = function(block, next) {
var m = /^ +(\>[\s\S]*)/.exec(block);
if (m && m[1] && m[1].length) {
next.unshift(MD.mk_block(m[1]));
return [];
}
};
});

View file

@ -0,0 +1,16 @@
// There's a weird issue with the markdown parser where it won't process simple blockquotes
// when they are prefixed with spaces. This fixes it.
Discourse.Dialect.on("register", function(event) {
var dialect = event.dialect,
MD = event.MD;
dialect.block["fix_simple_quotes"] = function(block, next) {
var m = /(^|\n) +(\>[\s\S]*)/.exec(block);
if (m && m[2] && m[2].length) {
var blockContents = block.replace(/(^|\n) +\>/, "$1>");
next.unshift(blockContents);
return [];
}
};
});

View file

@ -691,7 +691,8 @@ Markdown.dialects.Gruber = {
var next_block = next[0] && next[0].valueOf() || "";
if ( next_block.match(is_list_re) || next_block.match( /^ / ) ) {
if ( next_block.match(is_list_re) || (next_block.match(/^ /) && (!next_block.match(/^ *\>/))) ) {
block = next.shift();
// Check for an HR following a list: features/lists/hr_abutting
@ -711,6 +712,7 @@ Markdown.dialects.Gruber = {
break;
} // loose_search
return ret;
};
})(),

View file

@ -119,6 +119,12 @@ test("simple quotes", function() {
cooked("> level 1\n> > level 2",
"<blockquote><p>level 1</p><blockquote><p>level 2</p></blockquote></blockquote>",
"it allows nesting of blockquotes with spaces");
cooked("- hello\n\n > world\n > eviltrout",
"<ul><li>hello</li></ul>\n\n<blockquote><p>world<br>eviltrout</p></blockquote>",
"it allows quotes within a list.");
cooked(" > indent 1\n > indent 2", "<blockquote><p>indent 1<br>indent 2</p></blockquote>", "allow multiple spaces to indent");
});
test("Quotes", function() {