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

Lint for likely-malformed reference style links #1952

Open
CAD97 opened this issue Aug 13, 2017 · 4 comments
Open

Lint for likely-malformed reference style links #1952

CAD97 opened this issue Aug 13, 2017 · 4 comments
Labels
A-documentation Area: Adding or improving documentation A-lint Area: New lints good-first-issue These issues are a good way to get started with Clippy L-correctness Lint: Belongs in the correctness lint group T-AST Type: Requires working with the AST

Comments

@CAD97
Copy link
Contributor

CAD97 commented Aug 13, 2017

I often come across the situation in markdown when I accidentally write the following:

[useful text][reference]

[reference](<example.com>)

This, though it might look like a reference style link, is not:

[useful text][reference]

reference

The correct syntax is as follows:

[useful text][reference]

[reference]: <example.com>

useful text

Clippy could lint against this likely-malformed reference link.

Notes:

  • This lint should only trigger if [reference](<link>) is on a line on its own (e.g. would be a valid reference target) and reference could be a valid reference key.
  • This lint should not trigger if there is any escaping of the in-text part of the reference which makes it not a valid reference link, even if it renders [like][so] in the output.
  • I don't think [bracketed][words] would ever be desired except in a code block about markdown, so this lint shouldn't have a lot of real-world false positives.
@CAD97
Copy link
Contributor Author

CAD97 commented Aug 13, 2017

The original OP had an unrelated lint triggering on an invalid reference style link which should not (and does not) trigger for an actual reference style link.

This comment was me realizing my mistake.

@CAD97 CAD97 closed this as completed Aug 13, 2017
@llogiq
Copy link
Contributor

llogiq commented Aug 13, 2017

We could still try to detect those cases and issue a better warning message.

@CAD97
Copy link
Contributor Author

CAD97 commented Aug 13, 2017

What I had was [ref](link) instead of [ref]: link if you want to lint against it @llogiq. It feels like a common mistake (at least for me).

@CAD97 CAD97 changed the title doc_markdown should ignore reference style links Lint for likely-malformed reference style links Aug 14, 2017
@CAD97
Copy link
Contributor Author

CAD97 commented Aug 14, 2017

I have re-purposed this issue to lint against near-miss reference style links.

@CAD97 CAD97 reopened this Aug 14, 2017
@oli-obk oli-obk added L-correctness Lint: Belongs in the correctness lint group good-first-issue These issues are a good way to get started with Clippy A-documentation Area: Adding or improving documentation A-lint Area: New lints T-AST Type: Requires working with the AST labels Aug 14, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-documentation Area: Adding or improving documentation A-lint Area: New lints good-first-issue These issues are a good way to get started with Clippy L-correctness Lint: Belongs in the correctness lint group T-AST Type: Requires working with the AST
Projects
None yet
Development

No branches or pull requests

5 participants