mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2026-04-25 01:05:55 +03:00
[GH-ISSUE #167] Modify MD029 to allow lists starting larger than one #144
Labels
No labels
bug
enhancement
enhancement
enhancement
fixed in next
fixed in next
fixed in next
new rule
new rule
new rule
pull-request
question
refactoring
refactoring
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/markdownlint#144
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @vstrien on GitHub (Feb 22, 2019).
Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/167
Currently, MD029 only considers lists starting at 1 as valid.
However, in documentation a series of steps is often outlined with explanations in between. For example:
Currently, MD029 marks the second sequence (starting at 2) as
[Expected: 1; Actual: 2; Style: 1/1/1], while the "broken list" (or any list starting at another digit than just 1) displays correctly in markdown-it as well as GFM.@DavidAnson commented on GitHub (Feb 22, 2019):
The example above where a paragraph is placed "inside" a list is definitely valid and I understand the scenario where it is useful. However, the linter can't tell the difference between that scenario and the (more common) scenario where the 2-item list after the paragraph is meant to be a separate list (and starts at the wrong number).
If we tried to allow this behavior, what are the rules for content that is allowed to interrupt a list? Is it just one paragraph, or two, or ten? What about another list? I'm not seeing a clear policy that will allow the tool to detect the common mis-numbering scenario AND allow the pattern above AND still remain useful.
As such, I think that disabling MD029 for this part of your project may be the most practical solution.
@vstrien commented on GitHub (Feb 25, 2019):
Sure, I agree. An alternative is to allow lists starting not only at one, but also at two. The cases for lists starting at 2 are almost always corner-cases though, so maybe it's easier / better to disable this single rule for those projects.
@redactedscribe commented on GitHub (Jul 15, 2023):
@DavidAnson I understand the difficulty with implementing a reliable rule, but I don't think disabling the rule should be the solution either. The example scenario above isn't too uncommon across projects. In my case:
Indenting the warning doesn't make sense for it to be part of step 2.
Can we not just treat the lists as two separate lists and allow them to begin at any number? Or does that also run into issues?
VS Code's Markdown preview however doesn't seem to struggle in this scenario and renders it as a single list (at least visually) and without any of the large gaps between each list item when a list contains an empty line. Perhaps it's actually starting a new list at
3..Thanks.
markdownlint 0.51.0
VSCodium 1.80.1
@DavidAnson commented on GitHub (Jul 15, 2023):
@redactedscribe, the problem is not one of detecting there is a second list, but rather of guessing whether the author wanted the two lists to seem like the same list (and have continuous numbering) or treat them as separate lists according to the specification (meaning each should start at 1). The syntax in your example defines two different lists according to the CommonMark specification and so the warning from markdownlint is correct. My suggestion for a scenario like this is to indent the warning so it is part of the second list item. As you can see below, that means there is only a single list defined and there are no warnings from markdownlint.
https://dlaa.me/markdownlint/#%25m%23%20Issue%20167%0A%0A1.%20Copy.%0A2.%20Paste.%0A%0A%20%20%20%3E%20Warning!%0A%0A3.%20Run%20thing.%0A4.%20I%20did%20a%20computer!%0A