Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MD053 does not detect links within square brackets #537

Closed
MarkLodato opened this issue Jul 26, 2022 · 4 comments
Closed

MD053 does not detect links within square brackets #537

MarkLodato opened this issue Jul 26, 2022 · 4 comments

Comments

@MarkLodato
Copy link
Contributor

MD053 incorrectly complains about link references that are contained within square brackets. This is perfectly fine Markdown syntax, rendered correctly and parsed by MD051 (see below), but MD053 fails to understand it.

Reproducing

# Test for MD053

MD053 [works] for regular reference, but not those [[within brackets]].

[works]: foo.html
[within brackets]: foo.html
$ npx markdownlint test.md
test.md:6:1 MD053/link-image-reference-definitions Link and image reference definitions should be needed [Unused link or image reference definition: "within brackets"] [Context: "[within brackets]: foo.html"]

Further info

Note that MD051 does properly dereference the link and report it as broken (line 3) while simultaneously MD053 complains that the definition is unused (line 5).

# Test for MD051

[[broken link]]

[broken link]: #broken

Result:

$ npx markdownlint test2.md
test2.md:3 MD051/link-fragments Link fragments should be valid [Context: "#broken"]
test2.md:5:1 MD053/link-image-reference-definitions Link and image reference definitions should be needed [Unused link or image reference definition: "broken link"] [Context: "[broken link]: #broken"]
@DavidAnson
Copy link
Owner

MD051 uses the parser to scan valid links, whereas MD053 uses custom code via getReferenceLinkImageData. This is why the "Further info" example behaves like that.

@ssbarnea
Copy link

ssbarnea commented Aug 2, 2022

This seems to be a regression introduced by v0.32.1 release which affects people using markdown comments as recommended here, which is hugely popular. We used the format below in order to add some placeholder comments which are needed when we compile the documentation, so we know were a specific section starts or ends.

[//]: # DO-NOT-REMOVE-README-TITLE

This worked fine until yesterday, when pre-commit monthly update upgraded markdownlint to v0.32.1.

Is there any workaround for this?

@nschonni

This comment was marked as outdated.

@ssbarnea
Copy link

ssbarnea commented Aug 2, 2022

I filed it as a regression at #545

@nschonni Odd or not it with almost 2000 votes, it cannot be ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants