Skip to content

Commit 4e613fb

Browse files
committed
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.
1 parent c30fff5 commit 4e613fb

File tree

1 file changed

+2
-15
lines changed
  • packages/remark-parse/lib/tokenize

1 file changed

+2
-15
lines changed

packages/remark-parse/lib/tokenize/list.js

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ function list(eat, value, silent) {
3636
var index = 0
3737
var length = value.length
3838
var start = null
39-
var size = 0
39+
var size
4040
var queue
4141
var ordered
4242
var character
@@ -64,21 +64,13 @@ function list(eat, value, silent) {
6464
while (index < length) {
6565
character = value.charAt(index)
6666

67-
if (character === tab) {
68-
size += tabSize - (size % tabSize)
69-
} else if (character === space) {
70-
size++
71-
} else {
67+
if (character !== tab && character !== space) {
7268
break
7369
}
7470

7571
index++
7672
}
7773

78-
if (size >= tabSize) {
79-
return
80-
}
81-
8274
character = value.charAt(index)
8375

8476
if (character === asterisk || character === plusSign || character === dash) {
@@ -141,7 +133,6 @@ function list(eat, value, silent) {
141133
nextIndex = length
142134
}
143135

144-
end = index + tabSize
145136
size = 0
146137

147138
while (index < length) {
@@ -158,10 +149,6 @@ function list(eat, value, silent) {
158149
index++
159150
}
160151

161-
if (size >= tabSize) {
162-
indented = true
163-
}
164-
165152
if (item && size >= item.indent) {
166153
indented = true
167154
}

0 commit comments

Comments
 (0)