[GH-ISSUE #591] MD051/link-fragments false positive when code syntax is used #466

Closed
opened 2026-03-03 01:27:11 +03:00 by kerem · 6 comments
Owner

Originally created by @undergroundwires on GitHub (Oct 1, 2022).
Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/591

First of all thank you for the great tool. I use it on almost all of my projects. After upgrading to new version, I realized that MD051 fails to detect valid headers when code ``` backticks are used.

Example:


## `Header`

[Link](#Header) to header.

This is valid link and valid markdown but I get MD051/link-fragments Link fragments should be valid error.

Here is the markdown I use it on.

Originally created by @undergroundwires on GitHub (Oct 1, 2022). Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/591 First of all thank you for the great tool. I use it on almost all of my projects. After upgrading to new version, I realized that MD051 fails to detect valid headers when code ``` backticks are used. Example: ```md ## `Header` [Link](#Header) to header. ``` This is valid link and valid markdown but I get `MD051/link-fragments Link fragments should be valid` error. Here is the [markdown](https://github.com/undergroundwires/privacy.sexy/blob/bd9f4bcaf8a4319473ae5ca2d25f0470276d23d8/docs/collection-files.md) I use it on.
kerem 2026-03-03 01:27:11 +03:00
  • closed this issue
  • added the
    question
    label
Author
Owner

@nschonni commented on GitHub (Oct 1, 2022):

It complains about the anchor not being lowercase, not the backticks

<!-- gh-comment-id:1264396366 --> @nschonni commented on GitHub (Oct 1, 2022): It complains about the anchor not being lowercase, not the backticks
Author
Owner

@undergroundwires commented on GitHub (Oct 1, 2022):

Thank you for super fast response @nschonni , I'm too stupid, sorry for taking your time.

<!-- gh-comment-id:1264433672 --> @undergroundwires commented on GitHub (Oct 1, 2022): Thank you for super fast response @nschonni , I'm too stupid, sorry for taking your time.
Author
Owner

@nschonni commented on GitHub (Oct 1, 2022):

No worries, it's one I hit before too. Not sure if the messaging needs to be updated

<!-- gh-comment-id:1264442442 --> @nschonni commented on GitHub (Oct 1, 2022): No worries, it's one I hit before too. Not sure if the messaging needs to be updated
Author
Owner

@DavidAnson commented on GitHub (Oct 1, 2022):

I made myself a note to look into that.

<!-- gh-comment-id:1264450383 --> @DavidAnson commented on GitHub (Oct 1, 2022): I made myself a note to look into that.
Author
Owner

@MFTabriz commented on GitHub (Oct 11, 2022):

Does the anchor really need to be in lowercase? RfC 3986 does not define the URI fragment as case in-sensitive (so it does not require normalization).

PS: I guess it must be due to the way it's been implemented in GH!

<!-- gh-comment-id:1275242056 --> @MFTabriz commented on GitHub (Oct 11, 2022): Does the anchor really need to be in lowercase? RfC 3986 does not define the URI fragment as case in-sensitive (so it does not require normalization). PS: I guess it must be due to the way it's been implemented in GH!
Author
Owner

@DavidAnson commented on GitHub (Oct 11, 2022):

That's correct, GitHub appears to always use lowercase, and so that is the form this rule requires.

<!-- gh-comment-id:1275271906 --> @DavidAnson commented on GitHub (Oct 11, 2022): That's correct, GitHub appears to always use lowercase, and so that is the form this rule requires.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/markdownlint#466
No description provided.