[GH-ISSUE #957] Bug with MD052 and Hugo Shortcodes #2416

Closed
opened 2026-03-07 20:07:35 +03:00 by kerem · 2 comments
Owner

Originally created by @j-maynard on GitHub (Sep 7, 2023).
Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/957

Hi Peoples

I think I've found a bug in the way rule MD052 is processed. In my markdown files I have the following snippet:

Security issues found, if any, will be triaged following [the standard process][4].

With the references at the end of the markdown being:

[1]: https://docs.google.com/document/d/15eNKGA3zyZazsJMldqTBFbYMnVUSQSpU14lo22JMZQY/edit
[2]: https://gitlab.com/gitlab-com/gl-security/appsec/appsec-reviews/issues
[3]: {{< ref "./_index.md#stable-counterparts" >}}
[4]: {{< ref "/handbook/security#issue-triage" >}}

Items 4 and 3 are Hugo shortcodes which produce valid URLs but I think because of the way markdownlint processes this section it throws an MD052 error. My exact error is:

application-security/appsec-reviews.md:29:58 MD052/reference-links-images Reference links and images should use a label that is defined [Missing link or image reference definition: "4"] [Context: "[the standard process][4]"]

Would it be possible to confirm the bug and advise if you might fix it so I can advise my handbook community and make a decision on if I should disable the rule in my project (not something I want to do).

Originally created by @j-maynard on GitHub (Sep 7, 2023). Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/957 Hi Peoples I think I've found a bug in the way rule MD052 is processed. In my markdown files I have the following snippet: ``` Security issues found, if any, will be triaged following [the standard process][4]. ``` With the references at the end of the markdown being: ``` [1]: https://docs.google.com/document/d/15eNKGA3zyZazsJMldqTBFbYMnVUSQSpU14lo22JMZQY/edit [2]: https://gitlab.com/gitlab-com/gl-security/appsec/appsec-reviews/issues [3]: {{< ref "./_index.md#stable-counterparts" >}} [4]: {{< ref "/handbook/security#issue-triage" >}} ``` Items 4 and 3 are Hugo shortcodes which produce valid URLs but I think because of the way markdownlint processes this section it throws an MD052 error. My exact error is: ``` application-security/appsec-reviews.md:29:58 MD052/reference-links-images Reference links and images should use a label that is defined [Missing link or image reference definition: "4"] [Context: "[the standard process][4]"] ``` Would it be possible to confirm the bug and advise if you might fix it so I can advise my handbook community and make a decision on if I should disable the rule in my project (not something I want to do).
kerem 2026-03-07 20:07:35 +03:00
  • closed this issue
  • added the
    question
    label
Author
Owner

@DavidAnson commented on GitHub (Sep 7, 2023):

Hugo shortcodes are not part of the CommonMark/GFM specification which this tool uses. If you run this tool against the example as you show, the issues reported are correct because 3 and 4 are not valid link definitions. If you were to run this tool against the output after Hugo had processed the above and expanded its shortcodes, 3 and 4 should become valid link definitions and no issues should be reported. I do not consider this a bug.

<!-- gh-comment-id:1710425135 --> @DavidAnson commented on GitHub (Sep 7, 2023): Hugo shortcodes are not part of the CommonMark/GFM specification which this tool uses. If you run this tool against the example as you show, the issues reported are correct because 3 and 4 are not valid link definitions. If you were to run this tool against the output after Hugo had processed the above and expanded its shortcodes, 3 and 4 should become valid link definitions and no issues should be reported. I do not consider this a bug.
Author
Owner

@j-maynard commented on GitHub (Sep 7, 2023):

Cool... Thank you for taking a look. I'd throw out a feature request to add shortcode support in the future.

I'll disable the rule in our config as I think this going to come up a lot for our Handbook. I'll close the issue.

<!-- gh-comment-id:1710558847 --> @j-maynard commented on GitHub (Sep 7, 2023): Cool... Thank you for taking a look. I'd throw out a feature request to add shortcode support in the future. I'll disable the rule in our config as I think this going to come up a lot for our Handbook. I'll close the issue.
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#2416
No description provided.