mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2026-04-25 17:26:22 +03:00
[GH-ISSUE #1411] 🐛・[Bug] Headers detection #2524
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#2524
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 @kckmzx on GitHub (Nov 8, 2024).
Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/1411
Hi ! First, thanks for your work, it's very useful !!
First, here is my

markdown-lintconfiguration:What's the problem
When two headers have the same content, but one is followed by a comment, they are considered different. Thus, when I create a link to a header that contains a comment, the
MD051rule is triggered.Typically, I often use a comment next to the header to indicate that it should not be displayed in the table of contents (
# ... <!-- omit in toc -->used by the Markdown All in One extension).How to reproduce
Example of headers that should produce the same result:
Normally, the
Header Example 3should also trigger an error.Example with the MD051 rule
Example with this header:

This link works (in the markdown preview), but the rule
MD051is triggered.Conversely, this one does not work (in the markdown preview) but the rule
MD051is not triggered (because the header is followed by a comment and is therefore considered different).@DavidAnson commented on GitHub (Nov 8, 2024):
I'm not sure I agree the first example is wrong, but it definitely depends on whether one considers the content of the comment as part of the heading or not. I may decide it should be ignored as you suggest, but I'll need to think about that more. Your second example does not appear to be a bug because that rule honors the GitHub implementation and the GitHub-generated link for a heading followed by a comment includes the trailing dash.
@kckmzx commented on GitHub (Nov 15, 2024):
Okay, I understand for the second example. Maybe you can add it as a setting ?