mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2026-04-25 01:05:55 +03:00
[GH-ISSUE #1771] False positive for MD051 when header contains a colon #744
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#744
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 @cdwilson on GitHub (Sep 23, 2025).
Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/1771
test.mdproduces a false positive for MD051:Removing the colon from the header in
test2.md:@DavidAnson commented on GitHub (Sep 23, 2025):
In your example, the text ":a" is recognized by the Markdown parser as a directive. You can see that in the output from the demo app:
https://dlaa.me/markdownlint/#%25m%23%20Overview%0A%0A%23%23%20A%20heading%20with%3Aa%20colon%0A%0A%5BA%20heading%20with%3Aa%20colon%5D(%23a-heading-witha-colon)%0A%0A%23%23%20A%20heading%20with%5C%3Aa%20escaped%20colon%0A%0A%5BA%20heading%20with%3Aa%20escaped%20colon%5D(%23a-heading-witha-escaped-colon)%0A
You can read more about directive syntax here: https://github.com/micromark/micromark-extension-directive
While your environment may not support directives, they're enabled and recognized by default by
markdownlint. Per my example above, you can backslash-escape the colon character to avoid the unwanted warning. Or you can disable the rule for that line, file, or project.@cdwilson commented on GitHub (Sep 23, 2025):
Thanks for the context and the example!
I ran across this today when I was trying to lint a table-of-contents generated by https://github.com/hukkin/mdformat-toc
For example, running the following doc through
mdformat:Produces this output:
From your comment, it sounds like
mdformatshould not remove the escape in the heading when it formats the doc. I'll open an issue in themdformat-tocrepo.@DavidAnson commented on GitHub (Sep 23, 2025):
I'm not sure I'd say they are WRONG to do so because directives are not part of the official CommonMark specification, but it IS inconvenient here and they may not need to be doing so. :)