[GH-ISSUE #552] Newer versions of markdown lint complain about links that wrap to a new line #450

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

Originally created by @michaelgwelch on GitHub (Aug 13, 2022).
Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/552

I'm coming from an older version of markdownlint: 0.8.1.

Our repo uses prettier to format all documents with proseWrap: always configured. This has the effect of wrapping links.

For example here's a link we have in our doc:

[http 403 forbidden]:
  https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/403

It wasn't written this way but prettier formats it this way. With 0.8.1 markdownlint didn't issue any warning or error. With the latest version (0.26.2) which I just upgraded to, we now get an error:

  file: designs/capabilities/README.md
    ✘ 1979 Link and image reference definitions should be needed: [http 403 forbidden]:

Which seems like a MD052 violation.

I think (at least based upon the common mark spec) that a line break is allowed (bolding added by me):

A link reference definition consists of a link label, optionally preceded by up to three spaces of indentation, followed by a colon (:), optional spaces or tabs (including up to one line ending), a link destination, optional spaces or tabs (including up to one line ending), and an optional link title, which if it is present must be separated from the link destination by spaces or tabs.

There is an open issue on the prettier repo but it doesn't seem to have much traction.

https://github.com/prettier/prettier/issues/9232

Originally created by @michaelgwelch on GitHub (Aug 13, 2022). Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/552 I'm coming from an older version of markdownlint: 0.8.1. Our repo uses prettier to format all documents with `proseWrap: always` configured. This has the effect of wrapping links. For example here's a link we have in our doc: ```md [http 403 forbidden]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/403 ``` It wasn't written this way but prettier formats it this way. With 0.8.1 markdownlint didn't issue any warning or error. With the latest version (0.26.2) which I just upgraded to, we now get an error: ```bash file: designs/capabilities/README.md ✘ 1979 Link and image reference definitions should be needed: [http 403 forbidden]: ``` Which seems like a MD052 violation. I think (at least based upon the [common mark spec](https://spec.commonmark.org/0.30/#link-reference-definition)) that a line break is allowed (bolding added by me): > A [link reference definition](https://spec.commonmark.org/0.30/#link-reference-definition) consists of a [link label](https://spec.commonmark.org/0.30/#link-label), optionally preceded by up to three spaces of indentation, followed by a colon (:), **optional spaces or tabs (including up to one [line ending](https://spec.commonmark.org/0.30/#line-ending))**, a [link destination](https://spec.commonmark.org/0.30/#link-destination), optional spaces or tabs (including up to one [line ending](https://spec.commonmark.org/0.30/#line-ending)), and an optional [link title](https://spec.commonmark.org/0.30/#link-title), which if it is present must be separated from the [link destination](https://spec.commonmark.org/0.30/#link-destination) by spaces or tabs. There is an open issue on the prettier repo but it doesn't seem to have much traction. https://github.com/prettier/prettier/issues/9232
kerem 2026-03-03 01:27:00 +03:00
  • closed this issue
  • added the
    question
    label
Author
Owner

@DavidAnson commented on GitHub (Aug 13, 2022):

A new line in that position is expressly allowed by the specification: https://spec.commonmark.org/0.30/#example-198

However, it is annoying for my purposes. I will look to update the library to stop reporting this pattern as a violation.

<!-- gh-comment-id:1214215229 --> @DavidAnson commented on GitHub (Aug 13, 2022): A new line in that position is expressly allowed by the specification: https://spec.commonmark.org/0.30/#example-198 However, it is annoying for my purposes. I will look to update the library to stop reporting this pattern as a violation.
Author
Owner

@michaelgwelch commented on GitHub (Aug 13, 2022):

However, it is annoying for my purposes. I will look to update the library to stop reporting this pattern as a violation.

Yeah, I can see that. I was just looking at the following function and while you do concatenate all the lines for "single-line exclusions for inline code spans" it's back to line by line for links:
github.com/DavidAnson/markdownlint@2488a5c0ce/helpers/helpers.js (L782)

<!-- gh-comment-id:1214220465 --> @michaelgwelch commented on GitHub (Aug 13, 2022): > However, it is annoying for my purposes. I will look to update the library to stop reporting this pattern as a violation. Yeah, I can see that. I was just looking at the following function and while you do concatenate all the lines for "single-line exclusions for inline code spans" it's back to line by line for links: https://github.com/DavidAnson/markdownlint/blob/2488a5c0ce92d65ddcc6422f5d453384f3c1e1be/helpers/helpers.js#L782
Author
Owner

@DavidAnson commented on GitHub (Aug 13, 2022):

Waaaait a minute. I remembered that regular expression as wanting to match part of the link, but it does not.

Trying your example in the demo app works fine for me: https://dlaa.me/markdownlint/#%25m%23%20Issue%20552%0A%0ASee%20%5Bhttp%20403%20forbidden%5D.%0A%0A%5Bhttp%20403%20forbidden%5D%3A%0A%20%20https%3A%2F%2Fdeveloper.mozilla.org%2Fen-US%2Fdocs%2FWeb%2FHTTP%2FStatus%2F403%0A

Can you show me the document where this is failing for you? There may be something else going on.

<!-- gh-comment-id:1214225753 --> @DavidAnson commented on GitHub (Aug 13, 2022): Waaaait a minute. I remembered that regular expression as wanting to match part of the link, but it does not. Trying your example in the demo app works fine for me: https://dlaa.me/markdownlint/#%25m%23%20Issue%20552%0A%0ASee%20%5Bhttp%20403%20forbidden%5D.%0A%0A%5Bhttp%20403%20forbidden%5D%3A%0A%20%20https%3A%2F%2Fdeveloper.mozilla.org%2Fen-US%2Fdocs%2FWeb%2FHTTP%2FStatus%2F403%0A Can you show me the document where this is failing for you? There may be something else going on.
Author
Owner

@michaelgwelch commented on GitHub (Aug 13, 2022):

@DavidAnson My apologies. The error I'm getting is MD053 and is triggering exactly for the reason it should. The link in question is not used. (I'm not the author of the document this triggered on and I had just assumed all the links in it were used, and therefore assumed the issue was due to the formatting)

<!-- gh-comment-id:1214236524 --> @michaelgwelch commented on GitHub (Aug 13, 2022): @DavidAnson My apologies. The error I'm getting is MD053 and is triggering exactly for the reason it should. The link in question is not used. (I'm not the author of the document this triggered on and I had just assumed all the links in it were used, and therefore assumed the issue was due to the formatting)
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#450
No description provided.