markdownlint icon indicating copy to clipboard operation
markdownlint copied to clipboard

Add rule to check for inline-style links

Open pascalberger opened this issue 8 years ago • 4 comments

A rule to dissallow inline-style links would be a nice enhancements.

Possible configuration parameters:

  • Disallow all inline-style links
  • Allow inline-style links in lists only
  • Allow all inline-style links

pascalberger avatar Jan 10 '17 12:01 pascalberger

Can you please give some examples to be sure I understand the request? I searched "for inline-style" links and it suggests something like the following:

<a href="..." style="something">...</a>

If so, does rule MD033 Inline HTML help? It can be used to block HTML content which should cover the first of your three scenarios.

Also, why are lists special with regard to inline-style links? Would blockquotes deserve similar treatment? Tables? Just lists?

Thanks for the clarification!

DavidAnson avatar Jan 11 '17 05:01 DavidAnson

No, I didn't mean inline HTML. Some examples to clarify:

Good:

Lorem ipsum dolor sit amet, [consectetur adipiscing] elit. Etiam lectus dui, laoreet eget mauris eget, interdum blandit risus. Vestibulum ac ornare dolor, et tincidunt nulla. Suspendisse vitae dolor nec ipsum vehicula varius non et diam. Vivamus finibus libero sed tincidunt accumsan. Aliquam erat volutpat. Donec faucibus, neque ac semper blandit, est lacus placerat purus, a blandit magna diam et lorem. Maecenas tincidunt iaculis eleifend. In bibendum elementum ex, sit amet pharetra est efficitur at. 

[consectetur adipiscing]: http://example.com

Bad, if not Allow all inline-style links is set:

Lorem ipsum dolor sit amet, [consectetur adipiscing](http://example.com) elit. Etiam lectus dui, laoreet eget mauris eget, interdum blandit risus. Vestibulum ac ornare dolor, et tincidunt nulla. Suspendisse vitae dolor nec ipsum vehicula varius non et diam. Vivamus finibus libero sed tincidunt accumsan. Aliquam erat volutpat. Donec faucibus, neque ac semper blandit, est lacus placerat purus, a blandit magna diam et lorem. Maecenas tincidunt iaculis eleifend. In bibendum elementum ex, sit amet pharetra est efficitur at. 

Good, if Allow inline-style links in lists is set:

* [Google](https://google.com)
* [Bing](https://bing.com)

The general idea behind the rule would be that inline-style links makes the Markdown source file harder to read. The exception for lists is that IMHO if you make a list of just links, it's easier to read if using inline-style than reference-style links, since the link is the whole content there. More precise this exception should only be valid if there is no additional text in the list, but don't know if this is possible :)

pascalberger avatar Jan 11 '17 07:01 pascalberger

Makes perfect sense, thank you!

DavidAnson avatar Jan 11 '17 17:01 DavidAnson

For completeness, an option to disallow reference links would be nice, and/or a "consistent" option, ala ul-style.

bhrutledge avatar Nov 24 '19 11:11 bhrutledge

Re-adding comment from #321, which was closed as a duplicate:

It would also be nice if this was configurable by the length of the URL — i.e. non-reference links shorter than N characters would not trigger this rule, with the default max length being 0.

waldyrious avatar Oct 08 '22 21:10 waldyrious

Another possible criteria for which link style to use: whether or not the link destination is relative eg. [read destination docs](./destination/README.md) vs [read destination docs](https://example.com/destination)

tommy-gilligan avatar May 30 '23 00:05 tommy-gilligan

Should autolinks be allowed?

tommy-gilligan avatar May 30 '23 01:05 tommy-gilligan

Should autolinks be allowed?

Tentatitve decision: Autolinks should be ignored

Allow inline-style links in lists only

Another possible criteria for which link style to use: whether or not the link destination is relative

It would also be nice if this was configurable by the length of the URL — i.e. non-reference links shorter than N characters would not trigger this rule, with the default max length being 0.

Tentatitve decision: All of these should be configurable but it is not clear to me what that should look like in the schema.

tommy-gilligan avatar May 31 '23 05:05 tommy-gilligan