Skip to content

Commit

Permalink
Refactor to loosen list parsing
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
wooorm committed Apr 23, 2020
1 parent c30fff5 commit 4e613fb
Showing 1 changed file with 2 additions and 15 deletions.
17 changes: 2 additions & 15 deletions packages/remark-parse/lib/tokenize/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -141,7 +133,6 @@ function list(eat, value, silent) {
nextIndex = length
}

end = index + tabSize
size = 0

while (index < length) {
Expand All @@ -158,10 +149,6 @@ function list(eat, value, silent) {
index++
}

if (size >= tabSize) {
indented = true
}

if (item && size >= item.indent) {
indented = true
}
Expand Down

0 comments on commit 4e613fb

Please sign in to comment.