Remark: Nested list item becomes single paragraph when indenting >=4 spaces

Created on 19 Aug 2020  路  5Comments  路  Source: remarkjs/remark

Subject of the issue

It seems like if the 4-space indented list item is followed by an unindented text block, the parser would recognize all 3 lines into a single paragraph within the first list item. This doesn't seem to happen without an unindented text block after, nor with 2 or 3 spaces of indentation. With CommonMark, it seems that this behavior only happens when indenting >=6 spaces.

Your environment

  • OS: Windows 10
  • Packages: remark-parse 8.0.3
  • Env: Chrome 84.0.4147.125

Steps to reproduce

Sample: (notice there are exactly 4 spaces in the second list item, the same happens with a tab character)

- Test
    - Test
Test

remark

image

CommonMark dingus

image

Observation

Interestingly, when the indentation is done with 2 or 3 spaces, the parser correctly recognize the list item. Only when 4 or more spaces does remark fail to parse the indented list item.

With CommonMark, it seems like the required number of spaces to produce a similar result is 6 spaces instead of 4.

Debugging

I've put in a few hours stepping through the code. It's a bit tedious and difficult to understand, but it would seem that the normalListItem function eats up the - at the beginning of the first line, causing the difference in indentation to be 2 characters greater, which may be causing the symptom observed.

Unfortunately, with my limited experience, I am unsure how to continue with debugging or coming up with a fix.

Additional Information

This behavior is similar to https://github.com/remarkjs/remark/issues/315 so they might be related.

remark-parse 鉀碉笍 statureleased 馃悰 typbug

All 5 comments

Heya, just wanted to give an update about micromark, it鈥檚 sort-of a new motor that we鈥檒l soon use in remark to parse markdown. It鈥檚 not yet 100% ready but will be relatively soon. The good news is, it fixes this issue! (P.S. see this twitter thread for some more info!)

Awesome, thanks for the update!

Sorry for the wait! I just wanted to share that there鈥檚 now a PR that solves this issue: https://github.com/remarkjs/remark/pull/536.

This is now released in [email protected]

This is great, thank you!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

maximbaz picture maximbaz  路  7Comments

wooorm picture wooorm  路  4Comments

soroushm picture soroushm  路  6Comments

niksurff picture niksurff  路  4Comments

muescha picture muescha  路  6Comments