[GH-ISSUE #753] [New rule] Link can be simplified to autolink #527

Closed
opened 2026-03-03 01:27:42 +03:00 by kerem · 4 comments
Owner

Originally created by @Marcono1234 on GitHub (Mar 21, 2023).
Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/753

Problem

Sometimes, maybe due to usage of graphical editors, users write overly verbose inline links and reference links where the link display text is the same as the link destination. For example:

[https://example.com/my-page](https://example.com/my-page)
[https://example.com/my-page][site]

[site]: https://example.com/my-page

Especially for complex URLs such Markdown code can be difficult to read, and it is error-prone in case only the display text is updated but the link destination is left unchanged and vice versa.

Suggested rule behavior

In these cases markdownlint should suggest usage of autolinks, e.g. <https://example.com/my-page>. Autolinks make it much easier to read the Markdown code.

Corner cases to consider:

  • The rule should only apply when the link target is actually a valid autolink (e.g. it should not apply for relative links)
  • Special escaping rules for autolinks have to be considered, or the rule should not apply when special escaping is needed to convert the link to an autolink (because that might defeat the point about being less error-prone)
  • The rule cannot apply when the link has additional data such as a hover title
Originally created by @Marcono1234 on GitHub (Mar 21, 2023). Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/753 ### Problem Sometimes, maybe due to usage of graphical editors, users write overly verbose [inline links](https://spec.commonmark.org/0.30/#inline-link) and [reference links](https://spec.commonmark.org/0.30/#reference-link) where the link display text is the same as the link destination. For example: ```md [https://example.com/my-page](https://example.com/my-page) ``` ```md [https://example.com/my-page][site] [site]: https://example.com/my-page ``` Especially for complex URLs such Markdown code can be difficult to read, and it is error-prone in case only the display text is updated but the link destination is left unchanged and vice versa. ### Suggested rule behavior In these cases markdownlint should suggest usage of [autolinks](https://spec.commonmark.org/0.30/#autolink), e.g. `<https://example.com/my-page>`. Autolinks make it much easier to read the Markdown code. Corner cases to consider: - The rule should only apply when the link target is actually a valid autolink (e.g. it should not apply for relative links) - Special escaping rules for autolinks have to be considered, or the rule should not apply when special escaping is needed to convert the link to an autolink (because that might defeat the point about being less error-prone) - The rule cannot apply when the link has additional data such as a hover title
kerem 2026-03-03 01:27:42 +03:00
Author
Owner

@nschonni commented on GitHub (Mar 21, 2023):

Not entirely the same, but the conversion of text to auto links is already covered by md034 autofixing

<!-- gh-comment-id:1478726903 --> @nschonni commented on GitHub (Mar 21, 2023): Not entirely the same, but the conversion of text to auto links is already covered by md034 autofixing
Author
Owner

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

Just for the sake of reference: this seems similar to #399

<!-- gh-comment-id:1565658104 --> @tommy-gilligan commented on GitHub (May 27, 2023): Just for the sake of reference: this seems similar to #399
Author
Owner

@DavidAnson commented on GitHub (May 27, 2023):

Agreed!

<!-- gh-comment-id:1565664883 --> @DavidAnson commented on GitHub (May 27, 2023): Agreed!
Author
Owner

@DavidAnson commented on GitHub (Nov 12, 2023):

Reopening this issue because #399 is fixed (in next branch), but does not include this behavior. I'm still thinking about whether it should or if this is something different.

<!-- gh-comment-id:1807018173 --> @DavidAnson commented on GitHub (Nov 12, 2023): Reopening this issue because #399 is fixed (in `next` branch), but does not include this behavior. I'm still thinking about whether it should or if this is something different.
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#527
No description provided.