smarter whitespace handling for list items
This commit is contained in:
parent
9bbb0b71e1
commit
5809d6ad8d
@ -195,16 +195,18 @@ block.token = function(str, tokens, top) {
|
|||||||
l = cap.length;
|
l = cap.length;
|
||||||
|
|
||||||
for (; i < l; i++) {
|
for (; i < l; i++) {
|
||||||
|
item = cap[i];
|
||||||
|
|
||||||
// Remove the list item's bullet
|
// Remove the list item's bullet
|
||||||
// so it is seen as the next token.
|
// so it is seen as the next token.
|
||||||
item = cap[i].replace(/^ *([*+-]|\d+\.) */, '');
|
space = item.length;
|
||||||
|
item = item.replace(/^ *([*+-]|\d+\.) */, '');
|
||||||
|
|
||||||
// Outdent whatever the
|
// Outdent whatever the
|
||||||
// list item contains. Hacky.
|
// list item contains. Hacky.
|
||||||
space = /\n( +)/.exec(item);
|
if (~item.indexOf('\n ')) {
|
||||||
if (space) {
|
space -= item.length;
|
||||||
space = new RegExp('^' + space[1], 'gm');
|
item = item.replace(new RegExp('^ {1,' + space + '}', 'gm'), '');
|
||||||
item = item.replace(space, '');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tokens.push({
|
tokens.push({
|
||||||
|
1
test/new/list_item_text.html
Normal file
1
test/new/list_item_text.html
Normal file
@ -0,0 +1 @@
|
|||||||
|
<ul><li><p>item1</p> <ul><li>item2 </li></ul> <p>text</p> </li></ul>
|
5
test/new/list_item_text.text
Normal file
5
test/new/list_item_text.text
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
* item1
|
||||||
|
|
||||||
|
* item2
|
||||||
|
|
||||||
|
text
|
1
test/tests/list_item_text.html
Normal file
1
test/tests/list_item_text.html
Normal file
@ -0,0 +1 @@
|
|||||||
|
<ul><li><p>item1</p> <ul><li>item2 </li></ul> <p>text</p> </li></ul>
|
5
test/tests/list_item_text.text
Normal file
5
test/tests/list_item_text.text
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
* item1
|
||||||
|
|
||||||
|
* item2
|
||||||
|
|
||||||
|
text
|
Loading…
x
Reference in New Issue
Block a user