[GH-ISSUE #1533] [MD051/link-fragments] Feature Request: Add support for checking fragments in other files #704

Closed
opened 2026-03-03 01:29:13 +03:00 by kerem · 4 comments
Owner

Originally created by @Cameronsplaze on GitHub (Mar 9, 2025).
Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/1533

Checking link fragments is currently working great if you're linking to another place in the same file, but fails to warn if the target is in another file.

Similar to https://github.com/DavidAnson/markdownlint/issues/513#issuecomment-1085283870:

  • article.md

    You can see authors in [authors](readme.md#authors-this-is-a-typo) section in readme
    
  • readme.md

    # Authors
    
    - John Doe
    - Bob Foo
    

This will fail to warn that the readme #authors-this-is-a-typo header is invalid. Is there a way around this I'm missing maybe?

Thank you!

Originally created by @Cameronsplaze on GitHub (Mar 9, 2025). Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/1533 Checking link fragments is currently working great if you're linking to another place in the same file, but fails to warn if the target is in another file. Similar to https://github.com/DavidAnson/markdownlint/issues/513#issuecomment-1085283870: - **article.md** ```md You can see authors in [authors](readme.md#authors-this-is-a-typo) section in readme ``` - **readme.md** ```md # Authors - John Doe - Bob Foo ``` This will fail to warn that the readme `#authors-this-is-a-typo` header is invalid. Is there a way around this I'm missing maybe? Thank you!
kerem 2026-03-03 01:29:13 +03:00
  • closed this issue
  • added the
    question
    label
Author
Owner

@DavidAnson commented on GitHub (Mar 9, 2025):

This is by design and implied by the rule documentation that refers to links within a file. Scanning referenced files as you suggest would be possible, but is out of scope for this rule because it can't be done synchronously (or at all in some scenarios).

https://github.com/DavidAnson/markdownlint/blob/main/doc/md051.md

<!-- gh-comment-id:2709126930 --> @DavidAnson commented on GitHub (Mar 9, 2025): This is by design and implied by the rule documentation that refers to links within a file. Scanning referenced files as you suggest would be possible, but is out of scope for this rule because it can't be done synchronously (or at all in some scenarios). <https://github.com/DavidAnson/markdownlint/blob/main/doc/md051.md>
Author
Owner

@Cameronsplaze commented on GitHub (Mar 10, 2025):

Ah that makes sense, thanks!

Would you consider a feature request for adding this as a new rule then? Or is synchronously a blocker for rules?

<!-- gh-comment-id:2711446482 --> @Cameronsplaze commented on GitHub (Mar 10, 2025): Ah that makes sense, thanks! Would you consider a feature request for adding this as a new rule then? Or is synchronously a blocker for rules?
Author
Owner

@DavidAnson commented on GitHub (Mar 10, 2025):

It's a blocker for core rules. Too much unpredictability for scenarios like VS Code in the web, etc.. But it's something someone could implement in a custom rule. Scanning quickly, I think one or two here may do what you want already: https://www.npmjs.com/search?q=keywords:markdownlint-rule

<!-- gh-comment-id:2711897316 --> @DavidAnson commented on GitHub (Mar 10, 2025): It's a blocker for core rules. Too much unpredictability for scenarios like VS Code in the web, etc.. But it's something someone could implement in a custom rule. Scanning quickly, I think one or two here may do what you want already: https://www.npmjs.com/search?q=keywords:markdownlint-rule
Author
Owner

@Cameronsplaze commented on GitHub (Mar 11, 2025):

Got yeah, sounds good. Thank you for the link, I'll check them out!

<!-- gh-comment-id:2712202487 --> @Cameronsplaze commented on GitHub (Mar 11, 2025): Got yeah, sounds good. Thank you for the link, I'll check them out!
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#704
No description provided.