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

Newer versions of markdown lint complain about links that wrap to a new line #552

Closed
michaelgwelch opened this issue Aug 13, 2022 · 4 comments
Labels

Comments

@michaelgwelch
Copy link

michaelgwelch commented Aug 13, 2022

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.

prettier/prettier#9232

@DavidAnson
Copy link
Owner

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.

@DavidAnson DavidAnson added the bug label Aug 13, 2022
@michaelgwelch
Copy link
Author

michaelgwelch commented 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:

function getReferenceLinkImageData(lineMetadata) {

@DavidAnson
Copy link
Owner

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.

@DavidAnson DavidAnson added question and removed bug labels Aug 13, 2022
@michaelgwelch
Copy link
Author

michaelgwelch commented 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 up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants