Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛・[Bug] Headers detection #1411

Open
mlaidouni opened this issue Nov 8, 2024 · 2 comments
Open

🐛・[Bug] Headers detection #1411

mlaidouni opened this issue Nov 8, 2024 · 2 comments
Labels

Comments

@mlaidouni
Copy link

Hi ! First, thanks for your work, it's very useful !!

Important

I think I found a bug with the header detection.

First, here is my markdown-lint configuration:
image

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 MD051 rule 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:

image

Normally, the Header Example 3 should also trigger an error.

Example with the MD051 rule

Example with this header:
image

This link works (in the markdown preview), but the rule MD051 is triggered.

image
image

Conversely, this one does not work (in the markdown preview) but the rule MD051 is not triggered (because the header is followed by a comment and is therefore considered different).

image

@DavidAnson
Copy link
Owner

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.

@DavidAnson DavidAnson transferred this issue from DavidAnson/vscode-markdownlint Nov 8, 2024
@mlaidouni
Copy link
Author

Okay, I understand for the second example. Maybe you can add it as a setting ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants