mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2026-04-25 17:26:22 +03:00
[GH-ISSUE #1678] New Rule: Order of List + Heading = 1. List 2. Heading #733
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#733
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 @Malix-Labs on GitHub (Jul 14, 2025).
Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/1678
Numbered headings doesn't seem to have a standard, but there is two ways of doing them
The GitHub renderer seems to correctly parse the semantic (but also does not adjust the font size) of a List, then a Heading:
But seems to not correctly parse the semantic (but also does adjust the font size) of a Heading, then a List:
I do not know if that is in the standard markdown spec,
But it might be worth creating a new rule for it
@DavidAnson commented on GitHub (Jul 14, 2025):
I'm not sure this construct makes a lot of sense in either form. I'd guess this is quite rare in practice. Perhaps a rule could exist to discourage both forms, but I don't think I see a lot of value if it's already something people don't do?
@Malix-Labs commented on GitHub (Jul 15, 2025):
I see numbered headings quite often personally
i.e. yesterday, I encountered it in the Markdown form of AGPL v3
@DavidAnson commented on GitHub (Jul 15, 2025):
That document you link to is Markdown in the sense that all text is Markdown, but I do not think it is making any attempt to adhere to basic Markdown conventions.
In your example, it looks to me like someone wanted to emphasize the numbered sections of an existing text document and just made them all headings.
Here's another example, a sequence of unordered list items containing a single ordered list item each:
I do not want to make too many decisions based on scenarios like this that feel like Markdown in name only.
@Malix-Labs commented on GitHub (Jul 15, 2025):
This is true indeed
However, I think numbered headings are still valuable
They are especially common for legal or legislative (non-markdown) documents
@DavidAnson commented on GitHub (Jul 15, 2025):
FYI, headings that begin with a list item-like number are not treated as ordered or unordered lists per the CommonMark specification.
Specifically, the body of an ATX list is parsed as inline content which excludes list items (which are container blocks): https://spec.commonmark.org/0.31.2/#atx-headings
Corresponding example using the dingus: https://spec.commonmark.org/dingus/?text=%23%201.%20Test%0A%0A
@DavidAnson commented on GitHub (Jul 15, 2025):
List items can explicitly include headings: https://spec.commonmark.org/0.31.2/#example-300
@Malix-Labs commented on GitHub (Jul 15, 2025):
Indeed;
Thus:
A List, then a Heading:
Is correct
While a Heading, then a List:
Is incorrect
@DavidAnson commented on GitHub (Jul 15, 2025):
What do you mean by "correct" and "incorrect"? These are two different structures with (seemingly) defined behavior. Putting large blocks of content inside a list has different implications than having numbered headings, but I'm not sure I'd say either is obviously better in the abstract or in what scenarios one or the other is inappropriate.
@Malix-Labs commented on GitHub (Oct 4, 2025):
Have you tested how the vast majority of markdown processors handle them?