diff --git a/lib/marked.js b/lib/marked.js index 49b81ef0..2062d703 100644 --- a/lib/marked.js +++ b/lib/marked.js @@ -16,10 +16,7 @@ var block = { lheading: /^([^\n]+)\n *(=|-){3,}/, hr: /^( ?[\-*_]){3,}/, blockquote: /^ *>[^\n]*(?:\n *>[^\n]*)*/, - // list: /^(?:( *)(\*|\+|-|\d+\.)[^\n]+(?:\n(?:\1 )+[^\n]+)*(?:\n+|$)){2,}/g, - // this can be simplified because its the whole list - //list: /^(?:( *)(\*|\+|-|\d+\.)[^\n]+(?:\n\1+[^\n]+)*(?:\n{1,2}|$)){2,}/g, - list: /^(?: *(\*|\+|-|\d+\.)[^\n]+(?:\n[^\n]+)*(\n{1,2}|$)){2,}/g, + list: /^(?: *(\*|\+|-|\d+\.)[^\n]+(?:\n[^\n]+)*(?:\n{1,2}|$)){2,}/g, html: /^<([^\/\s>]+)[^\n>]*>[^\n]*(?:\n[^\n]+)*\n?<\/\1>/, text: /^[^\n]+/ }; @@ -123,7 +120,12 @@ block.token = function(str, tokens) { }); break; case 'list': - var loose = false; //cap[2].length === 2; + //var loose = false; //cap[2].length === 2; + var loose = new RegExp( + '\n *\n' + + cap[1] + + '(?:\\*|\\+|-|\\d+\\.)' + ).test(cap[0]); tokens.push({ type: 'list_start', ordered: isFinite(cap[1]) @@ -146,7 +148,7 @@ block.token = function(str, tokens) { } tokens.push({ type: loose - ? 'loose_list_item_start' + ? 'loose_item_start' : 'list_item_start' }); block.token(item, tokens); @@ -396,8 +398,6 @@ var tok = function() { case 'list_item_start': var body = []; while (next().type !== 'list_item_end') { - // TODO incorporate paragraph - // list items here body.push(token.type === 'text' ? inline.lexer(token.text) : tok()); @@ -405,6 +405,14 @@ var tok = function() { return '
Just a note, I've found that I can't test my markdown parser vs others. For example, both markdown.js and showdown code blocks in lists wrong. They're also completely inconsistent with regards to paragraphs in list items.
A link. Not anymore.
Code goes here.
-Lots of it...
- bq Item 1
- bq Item 2
- New bq Item 1
- New bq Item 2 Text here
Another blockquote! I really need to get more creative with mockup text.. markdown.js breaks here again
Hello world. Here is a link. And an image .
Code goes here.
+Lots of it...
Paragraph.
- bq Item 1
- bq Item 2
- New bq Item 1
- New bq Item 2 Text here
Another blockquote! I really need to get more creative with mockup text.. markdown.js breaks here again
Hello world. Here is a link. And an image .
Code goes here.
Lots of it...