diff --git a/lib/marked.js b/lib/marked.js index da64a6d4..5bb98d12 100644 --- a/lib/marked.js +++ b/lib/marked.js @@ -195,16 +195,18 @@ block.token = function(str, tokens, top) { l = cap.length; for (; i < l; i++) { + item = cap[i]; + // Remove the list item's bullet // so it is seen as the next token. - item = cap[i].replace(/^ *([*+-]|\d+\.) */, ''); + space = item.length; + item = item.replace(/^ *([*+-]|\d+\.) */, ''); // Outdent whatever the // list item contains. Hacky. - space = /\n( +)/.exec(item); - if (space) { - space = new RegExp('^' + space[1], 'gm'); - item = item.replace(space, ''); + if (~item.indexOf('\n ')) { + space -= item.length; + item = item.replace(new RegExp('^ {1,' + space + '}', 'gm'), ''); } tokens.push({ diff --git a/test/new/list_item_text.html b/test/new/list_item_text.html new file mode 100644 index 00000000..142df366 --- /dev/null +++ b/test/new/list_item_text.html @@ -0,0 +1 @@ + diff --git a/test/new/list_item_text.text b/test/new/list_item_text.text new file mode 100644 index 00000000..a8f81b14 --- /dev/null +++ b/test/new/list_item_text.text @@ -0,0 +1,5 @@ + * item1 + + * item2 + + text diff --git a/test/tests/list_item_text.html b/test/tests/list_item_text.html new file mode 100644 index 00000000..142df366 --- /dev/null +++ b/test/tests/list_item_text.html @@ -0,0 +1 @@ + diff --git a/test/tests/list_item_text.text b/test/tests/list_item_text.text new file mode 100644 index 00000000..a8f81b14 --- /dev/null +++ b/test/tests/list_item_text.text @@ -0,0 +1,5 @@ + * item1 + + * item2 + + text