Skip to content

Nested list item becomes single paragraph when indenting >=4 spaces #523

@lishid

Description

@lishid

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 #315 so they might be related.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions