From 4e613fba8b717caffdfa11a39bb5b47faee2f914 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Thu, 23 Apr 2020 13:44:50 +0200 Subject: [PATCH] Refactor to loosen list parsing This eases the code a bit to do exactly the same, but remove some unneeded code. If indented code is not supported (say, someone removed the tokenizer), this also adds support for lists that are indented more than 4 spaces. All other tokenizers already supported that. --- packages/remark-parse/lib/tokenize/list.js | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/packages/remark-parse/lib/tokenize/list.js b/packages/remark-parse/lib/tokenize/list.js index 033c46a19..02ce0960e 100644 --- a/packages/remark-parse/lib/tokenize/list.js +++ b/packages/remark-parse/lib/tokenize/list.js @@ -36,7 +36,7 @@ function list(eat, value, silent) { var index = 0 var length = value.length var start = null - var size = 0 + var size var queue var ordered var character @@ -64,21 +64,13 @@ function list(eat, value, silent) { while (index < length) { character = value.charAt(index) - if (character === tab) { - size += tabSize - (size % tabSize) - } else if (character === space) { - size++ - } else { + if (character !== tab && character !== space) { break } index++ } - if (size >= tabSize) { - return - } - character = value.charAt(index) if (character === asterisk || character === plusSign || character === dash) { @@ -141,7 +133,6 @@ function list(eat, value, silent) { nextIndex = length } - end = index + tabSize size = 0 while (index < length) { @@ -158,10 +149,6 @@ function list(eat, value, silent) { index++ } - if (size >= tabSize) { - indented = true - } - if (item && size >= item.indent) { indented = true }