[GH-ISSUE #915] MD052: Add option to apply to shortcut reference links too #552

Closed
opened 2026-03-03 01:27:56 +03:00 by kerem · 5 comments
Owner

Originally created by @waldyrious on GitHub (Jul 22, 2023).
Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/915

Currently, MD052 has the following caveat:

"Shortcut" syntax is ambiguous and a missing label will not generate an error. For example, [shortcut] could be a shortcut link or the text "shortcut" in brackets.

I'd like to have an option (defaulting to false in light of the caveat above) to make MD052 also apply to shortcut-syntax reference links, so that I could configure it like this:

# MD052/reference-links-images
MD052:
  # Also validate reference links using shortcut syntax
  shortcut_links: true

(This issue stems from a discussion that started here.)

Originally created by @waldyrious on GitHub (Jul 22, 2023). Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/915 Currently, [MD052](https://github.com/DavidAnson/markdownlint/blob/v0.29.0/doc/md052.md) has the following caveat: > "Shortcut" syntax is ambiguous and a missing label will not generate an error. For example, `[shortcut]` could be a shortcut link or the text "shortcut" in brackets. I'd like to have an option (defaulting to false in light of the caveat above) to make MD052 also apply to shortcut-syntax reference links, so that I could configure it like this: ```yaml # MD052/reference-links-images MD052: # Also validate reference links using shortcut syntax shortcut_links: true ``` _(This issue stems from a discussion that started [here](https://github.com/DavidAnson/markdownlint/issues/456#issuecomment-1645448773).)_
kerem 2026-03-03 01:27:56 +03:00
Author
Owner

@DavidAnson commented on GitHub (Jul 22, 2023):

This modification would basically assume that every instance of "[whatever]" in a document was intended to be a link rather than text in brackets. I'm not sure that's very common?

<!-- gh-comment-id:1646360452 --> @DavidAnson commented on GitHub (Jul 22, 2023): This modification would basically assume that every instance of "[whatever]" in a document was intended to be a link rather than text in brackets. I'm not sure that's very common?
Author
Owner

@waldyrious commented on GitHub (Jul 22, 2023):

Yeah, I do agree it is likely to catch false positives, hence the suggestion to default to false. My use case is for specific documents, like this changelog, where using the collapsed syntax would be cumbersome given the number of links. So the configuration to enable this would likely not be project-wise, but file-wise using frontmatter, or even section-wise using HTML comments.

<!-- gh-comment-id:1646361629 --> @waldyrious commented on GitHub (Jul 22, 2023): Yeah, I do agree it is likely to catch false positives, hence the suggestion to default to false. My use case is for specific documents, like [this changelog](https://github.com/hamstar/Wikimate/blob/master/CHANGELOG.md?plain=1), where using the [collapsed syntax](https://spec.commonmark.org/0.30/#collapsed-reference-link) would be cumbersome given the number of links. So the configuration to enable this would likely not be project-wise, but file-wise using frontmatter, or even section-wise using HTML comments.
Author
Owner

@nex3 commented on GitHub (Aug 22, 2023):

I would very much appreciate this. My Markdown corpus universally uses shortcut-style links, because they're strictly shorter than collapsed-style links, but currently we lose all linting for these links (and in practice we relatively frequently forget to add references). I would love a configuration option for MD052 that would catch these issues. (In the rare cases where I need to use square brackets outside of code formatting, I'd prefer to write \[foo].)

<!-- gh-comment-id:1687254636 --> @nex3 commented on GitHub (Aug 22, 2023): I would very much appreciate this. My Markdown corpus universally uses shortcut-style links, because they're strictly shorter than collapsed-style links, but currently we lose all linting for these links (and in practice we relatively frequently forget to add references). I would love a configuration option for MD052 that would catch these issues. (In the rare cases where I need to use square brackets outside of code formatting, I'd prefer to write `\[foo]`.)
Author
Owner

@waldyrious commented on GitHub (Sep 10, 2023):

Thank you for implementing this, @DavidAnson! 💯 🙏

<!-- gh-comment-id:1712882551 --> @waldyrious commented on GitHub (Sep 10, 2023): Thank you for implementing this, @DavidAnson! :100: :pray:
Author
Owner

@ElCuboNegro commented on GitHub (Jun 13, 2024):

MD052/reference-links-images is a false positive in all the wikilinks cases.

<!-- gh-comment-id:2164592523 --> @ElCuboNegro commented on GitHub (Jun 13, 2024): MD052/reference-links-images is a false positive in all the wikilinks cases.
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#552
No description provided.