mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2026-04-25 09:16:02 +03:00
[GH-ISSUE #1016] MD051 false positives for section titles with image in them #2442
Labels
No labels
bug
enhancement
enhancement
enhancement
fixed in next
fixed in next
fixed in next
new rule
new rule
new rule
pull-request
question
refactoring
refactoring
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/markdownlint#2442
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @JakubFranek on GitHub (Oct 22, 2023).
Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/1016
Hello,
I am creating a glossary-like Markdown file for my project. I add relevant icons to some of the section titles like this:
Turns out the correct way to link to these section titles is to include the word "icon" from the image link within the section link
[like this](#buy-icon)The linking works perfectly fine like this, however, markdownlint reports false positive MD051 warnings:

I tried putting empty string in the image link square brackets, and although it caused the correct section link to be
[like this](#buy)(i.e. without the word "icon"), the warnings persisted. It seems to me markdownlint is somehow confused by section titles with image links in them.Is there a way to link to section titles with icons without causing MD051 warnings? Thanks a lot for any help.
Regards
Jakub
@DavidAnson commented on GitHub (Oct 22, 2023):
GitHub creates the following anchor for your original example:
#buy-. Using that syntax does not produce a warning from markdownlint: https://dlaa.me/markdownlint/#%25m%23%20Issue%201016%0A%0A%23%23%20Buy%20!%5BIcon%5D(..%2Fresources%2Ficons%2Fbuy.png)%0A%0A%5BLink%5D(%23buy-)%0AYou can read more about this rule's support for the GitHub algorithm toward the bottom of this documentation page: https://github.com/DavidAnson/markdownlint/blob/main/doc/md051.md
It seems like you are using some other platform/algorithm which includes the image description in automatically created anchor links. You may be able to create a named anchor or use an HTML anchor tag to create a custom name and reference that instead. The documentation above includes examples of both.
@JakubFranek commented on GitHub (Oct 22, 2023):
Thanks a lot, you are absolutely correct. The links were working when I used the VS Code native Markdown preview, which put me on the wrong track, but on GitHub they obey different rules. markdownlint works fine with GitHub style links which is good enough for me since GitHub is the intended target of my Markdowns. Thanks again.