diff --git a/lib/marked.js b/lib/marked.js index 4dee3b94..b86eb9aa 100644 --- a/lib/marked.js +++ b/lib/marked.js @@ -17,15 +17,22 @@ var block = { heading: /^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/, lheading: /^([^\n]+)\n *(=|-){3,} *\n*/, blockquote: /^( *>[^\n]+(\n[^\n]+)*\n*)+/, - list: /^( *)([*+-]|\d+\.) [^\0]+?(?:\n{2,}(?! )(?!\1bullet)\n*|\s*$)/, + list: /^( *)(bull) [^\0]+?(?:rule|\n{2,}(?! )(?!\1bull )\n*|\s*$)/, html: /^ *(?:comment|closed|closing) *(?:\n{2,}|\s*$)/, def: /^ *\[([^\]]+)\]: *([^\s]+)(?: +["(]([^\n]+)[")])? *(?:\n+|$)/, paragraph: /^([^\n]+\n?(?!body))+\n*/, text: /^[^\n]+/ }; +block.bullet = /(?:[*+-]|\d+\.)/; +block.item = /^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/; +block.item = replace(block.item, 'gm') + (/bull/g, block.bullet) + (); + block.list = replace(block.list) - ('bullet', /(?:[*+-](?!(?: *[-*]){2,})|\d+\.) /) + (/bull/g, block.bullet) + ('rule', /\n+(?=(?: *[-*_]){3,})/) (); block.html = replace(block.html) @@ -193,9 +200,7 @@ block.token = function(src, tokens, top) { }); // Get each top-level item. - cap = cap[0].match( - /^( *)([*+-]|\d+\.) [^\n]*(?:\n(?!\1(?:[*+-]|\d+\.) )[^\n]*)*/gm - ); + cap = cap[0].match(block.item); next = false; l = cap.length; @@ -688,10 +693,11 @@ function tag() { return tag; } -function replace(regex) { +function replace(regex, opt) { regex = regex.source; + opt = opt || ''; return function self(name, val) { - if (!name) return new RegExp(regex); + if (!name) return new RegExp(regex, opt); regex = regex.replace(name, val.source || val); return self; }; diff --git a/test/new/hr_list_break.html b/test/new/hr_list_break.html new file mode 100644 index 00000000..bd3ad1f7 --- /dev/null +++ b/test/new/hr_list_break.html @@ -0,0 +1,10 @@ + + +
+ +

you today?

diff --git a/test/new/hr_list_break.text b/test/new/hr_list_break.text new file mode 100644 index 00000000..036fe479 --- /dev/null +++ b/test/new/hr_list_break.text @@ -0,0 +1,6 @@ +* hello +world +* how +are +* * * +you today? diff --git a/test/tests/hr_list_break.html b/test/tests/hr_list_break.html new file mode 100644 index 00000000..bd3ad1f7 --- /dev/null +++ b/test/tests/hr_list_break.html @@ -0,0 +1,10 @@ + + +
+ +

you today?

diff --git a/test/tests/hr_list_break.text b/test/tests/hr_list_break.text new file mode 100644 index 00000000..036fe479 --- /dev/null +++ b/test/tests/hr_list_break.text @@ -0,0 +1,6 @@ +* hello +world +* how +are +* * * +you today?