[GH-ISSUE #40] Add rule to check for inline-style links #32

Closed
opened 2026-03-03 01:23:10 +03:00 by kerem · 8 comments
Owner

Originally created by @pascalberger on GitHub (Jan 10, 2017).
Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/40

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
Originally created by @pascalberger on GitHub (Jan 10, 2017). Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/40 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
kerem 2026-03-03 01:23:10 +03:00
Author
Owner

@DavidAnson commented on GitHub (Jan 11, 2017):

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!

<!-- gh-comment-id:271779657 --> @DavidAnson commented on GitHub (Jan 11, 2017): 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: ```html <a href="..." style="something">...</a> ``` If so, does rule [MD033 Inline HTML](https://github.com/DavidAnson/markdownlint/blob/master/doc/Rules.md#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!
Author
Owner

@pascalberger commented on GitHub (Jan 11, 2017):

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 :)

<!-- gh-comment-id:271801005 --> @pascalberger commented on GitHub (Jan 11, 2017): 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 :)
Author
Owner

@DavidAnson commented on GitHub (Jan 11, 2017):

Makes perfect sense, thank you!

<!-- gh-comment-id:271929398 --> @DavidAnson commented on GitHub (Jan 11, 2017): Makes perfect sense, thank you!
Author
Owner

@bhrutledge commented on GitHub (Nov 24, 2019):

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

<!-- gh-comment-id:557879584 --> @bhrutledge commented on GitHub (Nov 24, 2019): For completeness, an option to disallow reference links would be nice, and/or a "consistent" option, ala [ul-style](https://github.com/DavidAnson/markdownlint/blob/master/doc/Rules.md#md004).
Author
Owner

@waldyrious commented on GitHub (Oct 8, 2022):

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.

<!-- gh-comment-id:1272403025 --> @waldyrious commented on GitHub (Oct 8, 2022): Re-adding [comment](https://github.com/DavidAnson/markdownlint/issues/321#issuecomment-680123781) 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.
Author
Owner

@tommy-gilligan commented on GitHub (May 30, 2023):

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)

<!-- gh-comment-id:1567628869 --> @tommy-gilligan commented on GitHub (May 30, 2023): 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)`
Author
Owner

@tommy-gilligan commented on GitHub (May 30, 2023):

Should autolinks be allowed?

<!-- gh-comment-id:1567652170 --> @tommy-gilligan commented on GitHub (May 30, 2023): Should autolinks be allowed?
Author
Owner

@tommy-gilligan commented on GitHub (May 31, 2023):

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.

<!-- gh-comment-id:1569529248 --> @tommy-gilligan commented on GitHub (May 31, 2023): > 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.
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#32
No description provided.