mirror of
https://github.com/showdownjs/showdown.git
synced 2024-03-22 13:30:55 +08:00
fix(lists): fix sublists inconsistent behavior
Nested ul and ol lists behave inconsistently in the requirement of having 3 spaces to be considered a nested list. This fix changes the requirement to only one space in both cases. Closes #299
This commit is contained in:
parent
b7a69e2dd6
commit
9cfe8b1412
BIN
dist/showdown.js
vendored
BIN
dist/showdown.js
vendored
Binary file not shown.
BIN
dist/showdown.js.map
vendored
BIN
dist/showdown.js.map
vendored
Binary file not shown.
BIN
dist/showdown.min.js
vendored
BIN
dist/showdown.min.js
vendored
Binary file not shown.
BIN
dist/showdown.min.js.map
vendored
BIN
dist/showdown.min.js.map
vendored
Binary file not shown.
|
@ -102,9 +102,8 @@ showdown.subParser('lists', function (text, options, globals) {
|
||||||
*/
|
*/
|
||||||
function parseConsecutiveLists(list, listType, trimTrailing) {
|
function parseConsecutiveLists(list, listType, trimTrailing) {
|
||||||
// check if we caught 2 or more consecutive lists by mistake
|
// check if we caught 2 or more consecutive lists by mistake
|
||||||
// we use the counterRgx, meaning if listType is UL we look for UL and vice versa
|
// we use the counterRgx, meaning if listType is UL we look for OL and vice versa
|
||||||
var counterRxg = (listType === 'ul') ? /^ {0,2}\d+\.[ \t]/gm : /^ {0,2}[*+-][ \t]/gm,
|
var counterRxg = (listType === 'ul') ? /^\d+\.[ \t]/gm : /^[*+-][ \t]/gm,
|
||||||
subLists = [],
|
|
||||||
result = '';
|
result = '';
|
||||||
|
|
||||||
if (list.search(counterRxg) !== -1) {
|
if (list.search(counterRxg) !== -1) {
|
||||||
|
@ -124,9 +123,6 @@ showdown.subParser('lists', function (text, options, globals) {
|
||||||
result += '\n<' + listType + '>\n' + processListItems(txt, !!trimTrailing) + '</' + listType + '>\n';
|
result += '\n<' + listType + '>\n' + processListItems(txt, !!trimTrailing) + '</' + listType + '>\n';
|
||||||
}
|
}
|
||||||
})(list);
|
})(list);
|
||||||
for (var i = 0; i < subLists.length; ++i) {
|
|
||||||
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
result = '\n<' + listType + '>\n' + processListItems(list, !!trimTrailing) + '</' + listType + '>\n';
|
result = '\n<' + listType + '>\n' + processListItems(list, !!trimTrailing) + '</' + listType + '>\n';
|
||||||
}
|
}
|
||||||
|
@ -151,7 +147,7 @@ showdown.subParser('lists', function (text, options, globals) {
|
||||||
text = text.replace(wholeList, function (wholeMatch, m1, list, m3) {
|
text = text.replace(wholeList, function (wholeMatch, m1, list, m3) {
|
||||||
|
|
||||||
var listType = (m3.search(/[*+-]/g) > -1) ? 'ul' : 'ol';
|
var listType = (m3.search(/[*+-]/g) > -1) ? 'ul' : 'ol';
|
||||||
return parseConsecutiveLists(list, listType);
|
return parseConsecutiveLists(list, listType, false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
<ul>
|
||||||
|
<li>one</li>
|
||||||
|
</ul>
|
||||||
|
<ol>
|
||||||
|
<li>two</li>
|
||||||
|
</ol>
|
||||||
|
<p>foo</p>
|
||||||
|
<ul>
|
||||||
|
<li>one
|
||||||
|
|
||||||
|
<ol>
|
||||||
|
<li>two</li></ol></li>
|
||||||
|
</ul>
|
||||||
|
<p>foo</p>
|
||||||
|
<ul>
|
||||||
|
<li>one
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li>two</li></ul></li>
|
||||||
|
</ul>
|
|
@ -0,0 +1,12 @@
|
||||||
|
* one
|
||||||
|
1. two
|
||||||
|
|
||||||
|
foo
|
||||||
|
|
||||||
|
* one
|
||||||
|
1. two
|
||||||
|
|
||||||
|
foo
|
||||||
|
|
||||||
|
* one
|
||||||
|
* two
|
Loading…
Reference in New Issue
Block a user