mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2026-04-25 01:05:55 +03:00
[GH-ISSUE #1591] MD024: Allow defining siblings_only per level #2565
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#2565
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 @alonso-herreros on GitHub (May 5, 2025).
Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/1591
I like rule MD024, it's specially useful when your document includes a Table of Contents. However, I have ran into a case where I want to keep
siblings_onlyturned off only until a certain heading level, sayh4. In my case,h4s are left out of the Table of Contents, it's too deep, so I have no need for them to be unique. It's a case similar to a changelog; in this case many of myh3sections need the sameh4subsections, which should be unique between siblings but not globally.Example
Here's an example where level 4 headings could be allowed to be duplicate globally as long as they're unique between siblings.
Proposal
I think a good solution would be allowing
siblings_onlyto take a list of integers as a value, which would indicate the levels where only siblings are required to be unique.For backwards-compatibility,
truewould mean all levels, whilefalse(or an empty list) would mean none.Also, a nice option could be interpreting a single integer as 'that level and below'. A
0or a1would be equivalent totrue.Skipping a level while also indicating 'and below' would not be possible (e.g. level 3 plus 5 and below), but I think this is too rare to worry about, an you can get the same functionality by just specifying all levels you use.