DavidAnson / markdownlint

A Node.js style checker and lint tool for Markdown/CommonMark files.
MIT License
4.72k stars 717 forks source link

New line doesnt restart list index, triggers MD029 #429

Closed wolf99 closed 3 years ago

wolf99 commented 3 years ago

Using the following triggers MD029

1. first list, first item
2. first list, second item

1. second list, first item - MD029/ol-prefix: Ordered list item prefix [Expected: 3; Actual: 1; Style: 1/2/3] markdownlint (MD029)
2. second list, second item - MD029/ol-prefix: Ordered list item prefix [Expected: 4; Actual: 2; Style: 1/2/3] markdownlint (MD029)

Seems like markdownlint incorrectly continues index counting across the newline. That is, it does not allow the new line between the lists to start a new list as far as the list index numbers are concerned.

Markdownlint v0.43.2 in MS VS Ccode 1.60.1 (seen on 1.60.0 also) on MS Windows 10 1909

DavidAnson commented 3 years ago

The output is correct - this is a single list: https://markdown-it.github.io/#md3=%7B%22source%22%3A%221.%20first%20list%2C%20first%20item%5Cn2.%20first%20list%2C%20second%20item%5Cn%5Cn1.%20second%20list%2C%20first%20item%5Cn2.%20second%20list%2C%20second%20item%22%2C%22defaults%22%3A%7B%22html%22%3Afalse%2C%22xhtmlOut%22%3Afalse%2C%22breaks%22%3Afalse%2C%22langPrefix%22%3A%22language-%22%2C%22linkify%22%3Atrue%2C%22typographer%22%3Atrue%2C%22_highlight%22%3Atrue%2C%22_strict%22%3Afalse%2C%22_view%22%3A%22src%22%7D%7D

The specification calls out that blank lines are allowed between list items and do not "split" the list: https://spec.commonmark.org/0.30/#lists

wolf99 commented 3 years ago

Oh. I agree the spec does indicate that. However, do you know is there then a recommended way to have two separate ordered lists, one after the other ?

DavidAnson commented 3 years ago

Example 308 suggests an empty HTML comment: https://spec.commonmark.org/0.30/#example-308

wolf99 commented 3 years ago

Yuck. But it works 😅

wolf99 commented 3 years ago

Doesn't this breach MD033? https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md#md033---inline-html

DavidAnson commented 3 years ago

No, comments are not elements and example 308 does not trigger any violations: https://dlaa.me/markdownlint/#%25m%23%20Example%20308%0A%0A-%20foo%0A-%20bar%0A%0A%3C!--%20--%3E%0A%0A-%20baz%0A-%20bim%0A