mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2026-04-25 09:16:02 +03:00
[GH-ISSUE #340] MD029 doesn't allow for start="" in ol tags #292
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#292
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 @af4jm on GitHub (Oct 15, 2020).
Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/340
if I set MD029 to "ordered", I would expect any list item to get flagged if it's not 1 more than the previous number, but if I do something like...
this is "ordered", e.g. the 5. should NOT be flagged because the previous is 4... yet it is flagged and the hover text says that the setting is "1-2-3"... um, no, it's not "ordered starting with 1" it's just "ordered"... and it renders correct & valid html with start="4" on the second ol tag (I will admit this type of list only makes sense when the items in the list are naturally numbered anyway... e.g the 10 Commandments, where the subheadings would be "God" & "neighbors")
but it seems odd that markdownlint has no way of creating a start attribute without it being flagged as a violation
@DavidAnson commented on GitHub (Oct 15, 2020):
The pattern you show is not common and therefore usually represents an error, I think. The rules recommendation is consistent with the common case and by flagging each line, it means that automatic fix will be able to correct each of the list item markers. in a single pass.
It should be possible to add an additional parameter to this rule that allows starting with an arbitrary number, but it would complicate the code and I'm not sure how many people would use it.
@af4jm commented on GitHub (Oct 16, 2020):
Hmm... that's an interesting perspective... I see only 3 options...
in my opinion #3 smells like a bug, although the simple fact that this project has been around for a while working the way it is indicates I'm probably very much in the minority, so I'm going to turn this into a question...
if I were going to write a custom rule to work the way I want it to work, what would my filter look like to get all the lists? I tried to start with a copy of MD029, but it uses cache.js which probably isn't accessible from a custom rule (at least not the instance that's actually populated with the document tree). I also tried grabbing ol tags, but I think I also need the child li tags as well.
Looking through the other example rules linked didn't help, presumably because what I'm trying to do is very uncommon.
Thanks!
@DavidAnson commented on GitHub (Oct 16, 2020):
I'd suggest starting from - or modelling - MD029.
cache.jsis not needed - the helpers in https://www.npmjs.com/package/markdownlint-rule-helpers should help with some of the grunt work. You can see what the parse tree looks like for different syntax by looking at the "debug" tab on https://markdown-it.github.io/.I'll caution you that your item 1 would allow "2/3/4" which is usually wrong and item 2 would allow "5/5/5" which is probably also wrong. You may want to remember previous lists and allow starting with a number other than 1 iff the previous list ended with the previous value.
Good luck!
@af4jm commented on GitHub (Oct 16, 2020):
Thanks... and point taken on your "usually wrong" comments, which 100% counter my arguments above... so far I have a custom rule doing exactly what MD029 does out of the box, once I get it doing the custom thing (not today, but probably this weekend) I'll stick it in a gist & link to it here for future reference... but I have definitely been swayed that the existing behavior of MD029 is what makes sense for most cases
@nschonni commented on GitHub (Oct 16, 2020):
@af4jm unless this style is all over your docs, it might be easier to just use
<--markdownlint-disable MD029-->and<--markdownlint-enable MD029-->comments around specific blocks you're sure about@DavidAnson commented on GitHub (Oct 16, 2020):
@af4jm Feel free to publish your rule to npm. If you tag it (see CustomRules.md), others can find it.
@af4jm commented on GitHub (Oct 17, 2020):
published, thanks!
@nschonni I didn't want to do that because the repo in question is an Azure DevOps wiki I'm using to replace my Evernote account (partly because it's the only Markdown-based wiki I could find... and being free was just a bonus.)
@DavidAnson commented on GitHub (Oct 17, 2020):
Congrats! I'll leave this issue open to consider enhancing MD029 with an option to allow list continuations.
@DavidAnson commented on GitHub (Jun 19, 2021):
Closing this based on it usually being an error - and because there's now a rule to help with this: https://www.npmjs.com/package/markdownlint-rule-olstart.