[GH-ISSUE #894] False positive for MD053 when link follows inline HTML #546

Closed
opened 2026-03-03 01:27:53 +03:00 by kerem · 1 comment
Owner

Originally created by @philoserf on GitHub (Jul 3, 2023).
Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/894

Given

Text with a [link] and [another link].

<hr> <!-- inline html -->
[this link] | [and this link]

<!-- references -->
[link]: https://examples.com/link
[another link]: https://examples.com/another+link
[this link]: https://examples.com/this+link
[and this link]: https://examples.com/and+this+link

Markdownlint identifies [this link] & [and this link] as unreferenced.

Given

Text with a [link] and [another link].

[this link] | [and this link]

<!-- references -->
[link]: https://examples.com/link
[another link]: https://examples.com/another+link
[this link]: https://examples.com/this+link
[and this link]: https://examples.com/and+this+link

Markdownlint does not identify [this link] & [and this link] as unreferenced.

Originally created by @philoserf on GitHub (Jul 3, 2023). Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/894 Given ```markdown Text with a [link] and [another link]. <hr> <!-- inline html --> [this link] | [and this link] <!-- references --> [link]: https://examples.com/link [another link]: https://examples.com/another+link [this link]: https://examples.com/this+link [and this link]: https://examples.com/and+this+link ``` Markdownlint identifies `[this link]` & `[and this link]` as unreferenced. Given ```markdown Text with a [link] and [another link]. [this link] | [and this link] <!-- references --> [link]: https://examples.com/link [another link]: https://examples.com/another+link [this link]: https://examples.com/this+link [and this link]: https://examples.com/and+this+link ``` Markdownlint does not identify `[this link]` & `[and this link]` as unreferenced.
kerem 2026-03-03 01:27:53 +03:00
  • closed this issue
  • added the
    question
    label
Author
Owner
<!-- gh-comment-id:1618908879 --> @DavidAnson commented on GitHub (Jul 3, 2023): I believe this is correct per the CommonMark specification. Because there is no empty line between the HTML and following content in your first example, it gets treated as part of the same block instead of as Markdown. You can see that neither of the things after that tag are treated as links by the parser and therefore the corresponding link reference definitions are indeed unused: https://markdown-it.github.io/#md3=%7B%22source%22%3A%22Text%20with%20a%20%5Blink%5D%20and%20%5Banother%20link%5D.%5Cn%5Cn%3Chr%3E%20%3C!--%20inline%20html%20--%3E%5Cn%5Bthis%20link%5D%20%7C%20%5Band%20this%20link%5D%5Cn%5Cn%3C!--%20references%20--%3E%5Cn%5Blink%5D%3A%20https%3A%2F%2Fexamples.com%2Flink%5Cn%5Banother%20link%5D%3A%20https%3A%2F%2Fexamples.com%2Fanother%2Blink%5Cn%5Bthis%20link%5D%3A%20https%3A%2F%2Fexamples.com%2Fthis%2Blink%5Cn%5Band%20this%20link%5D%3A%20https%3A%2F%2Fexamples.com%2Fand%2Bthis%2Blink%22%2C%22defaults%22%3A%7B%22html%22%3Atrue%2C%22xhtmlOut%22%3Afalse%2C%22breaks%22%3Afalse%2C%22langPrefix%22%3A%22language-%22%2C%22linkify%22%3Atrue%2C%22typographer%22%3Atrue%2C%22_highlight%22%3Atrue%2C%22_strict%22%3Afalse%2C%22_view%22%3A%22html%22%7D%7D
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#546
No description provided.