This commit is contained in:
jun-sheaf
2020-06-17 18:29:05 +02:00
parent fcfe15fba6
commit d8e12752cd
3 changed files with 11 additions and 9 deletions
+5 -4
View File
@@ -492,12 +492,13 @@ var Tokenizer_1 = class Tokenizer {
let raw = cap[0];
const bull = cap[2];
const isordered = bull.length > 1;
const isparen = bull[bull.length - 1] === ')';
const list = {
type: 'list',
raw,
ordered: isordered,
start: isordered ? +bull : '',
start: isordered ? +bull.slice(0, -1) : '',
loose: false,
items: []
};
@@ -522,7 +523,7 @@ var Tokenizer_1 = class Tokenizer {
// Remove the list item's bullet
// so it is seen as the next token.
space = item.length;
item = item.replace(/^ *([*+-]|\d+\.) */, '');
item = item.replace(/^ *([*+-]|\d+[.)]) */, '');
// Outdent whatever the
// list item contains. Hacky.
@@ -537,7 +538,7 @@ var Tokenizer_1 = class Tokenizer {
// Backpedal if it does not belong in this list.
if (i !== l - 1) {
b = this.rules.block.bullet.exec(itemMatch[i + 1])[0];
if (bull.length > 1 ? b.length === 1
if (isordered ? b.length === 1 || (!isparen && b[b.length - 1] === ')')
: (b.length > 1 || (this.options.smartLists && b !== bull))) {
addBack = itemMatch.slice(i + 1).join('\n');
list.raw = list.raw.substring(0, list.raw.length - addBack.length);
@@ -974,7 +975,7 @@ block.def = edit$1(block.def)
.replace('title', block._title)
.getRegex();
block.bullet = /(?:[*+-]|\d{1,9}\.)/;
block.bullet = /(?:[*+-]|\d{1,9}[.)])/;
block.item = /^( *)(bull) ?[^\n]*(?:\n(?!\1bull ?)[^\n]*)*/;
block.item = edit$1(block.item, 'gm')
.replace(/bull/g, block.bullet)
+5 -4
View File
@@ -585,11 +585,12 @@
var raw = cap[0];
var bull = cap[2];
var isordered = bull.length > 1;
var isparen = bull[bull.length - 1] === ')';
var list = {
type: 'list',
raw: raw,
ordered: isordered,
start: isordered ? +bull : '',
start: isordered ? +bull.slice(0, -1) : '',
loose: false,
items: []
}; // Get each top-level item.
@@ -611,7 +612,7 @@
// so it is seen as the next token.
space = item.length;
item = item.replace(/^ *([*+-]|\d+\.) */, ''); // Outdent whatever the
item = item.replace(/^ *([*+-]|\d+[.)]) */, ''); // Outdent whatever the
// list item contains. Hacky.
if (~item.indexOf('\n ')) {
@@ -624,7 +625,7 @@
if (i !== l - 1) {
b = this.rules.block.bullet.exec(itemMatch[i + 1])[0];
if (bull.length > 1 ? b.length === 1 : b.length > 1 || this.options.smartLists && b !== bull) {
if (isordered ? b.length === 1 || !isparen && b[b.length - 1] === ')' : b.length > 1 || this.options.smartLists && b !== bull) {
addBack = itemMatch.slice(i + 1).join('\n');
list.raw = list.raw.substring(0, list.raw.length - addBack.length);
i = l - 1;
@@ -1076,7 +1077,7 @@
block._label = /(?!\s*\])(?:\\[\[\]]|[^\[\]])+/;
block._title = /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/;
block.def = edit$1(block.def).replace('label', block._label).replace('title', block._title).getRegex();
block.bullet = /(?:[*+-]|\d{1,9}\.)/;
block.bullet = /(?:[*+-]|\d{1,9}[.)])/;
block.item = /^( *)(bull) ?[^\n]*(?:\n(?!\1bull ?)[^\n]*)*/;
block.item = edit$1(block.item, 'gm').replace(/bull/g, block.bullet).getRegex();
block.list = edit$1(block.list).replace(/bull/g, block.bullet).replace('hr', '\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))').replace('def', '\\n+(?=' + block.def.source + ')').getRegex();
+1 -1
View File
File diff suppressed because one or more lines are too long