[GH-ISSUE #269] MD034 triggered when URL is escaped in the protocol section #229

Closed
opened 2026-03-03 01:24:54 +03:00 by kerem · 9 comments
Owner

Originally created by @nschonni on GitHub (Mar 31, 2020).
Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/269

https://dlaa.me/markdownlint/#%25mhttp%5C%3A%2F%2Fwww.contoso.com

Sometimes you want to show a link without the autolink happening, so you escape one of the characters in the :// sequence. It seems the reqex for the rule is ignoring that and still treating it as a link.

Originally created by @nschonni on GitHub (Mar 31, 2020). Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/269 https://dlaa.me/markdownlint/#%25mhttp%5C%3A%2F%2Fwww.contoso.com Sometimes you want to show a link without the autolink happening, so you escape one of the characters in the `://` sequence. It seems the reqex for the rule is ignoring that and still treating it as a link.
kerem 2026-03-03 01:24:54 +03:00
  • closed this issue
  • added the
    question
    label
Author
Owner

@DavidAnson commented on GitHub (Mar 31, 2020):

The RegExp is applied after parsing, so it doesn’t see the ‘\’. What about the suggestion to use a code block at the end of the rule documentation? https://github.com/DavidAnson/markdownlint/blob/master/doc/Rules.md#md034

<!-- gh-comment-id:606359732 --> @DavidAnson commented on GitHub (Mar 31, 2020): The RegExp is applied after parsing, so it doesn’t see the ‘\’. What about the suggestion to use a code block at the end of the rule documentation? https://github.com/DavidAnson/markdownlint/blob/master/doc/Rules.md#md034
Author
Owner
<!-- gh-comment-id:606360454 --> @DavidAnson commented on GitHub (Mar 31, 2020): The `markdown-it` parser doesn’t seem to ignore the link using this technique: https://markdown-it.github.io/#md3=%7B%22source%22%3A%22http%5C%5C%3A%2F%2Fwww.contoso.com%22%2C%22defaults%22%3A%7B%22html%22%3Afalse%2C%22xhtmlOut%22%3Afalse%2C%22breaks%22%3Afalse%2C%22langPrefix%22%3A%22language-%22%2C%22linkify%22%3Atrue%2C%22typographer%22%3Atrue%2C%22_highlight%22%3Atrue%2C%22_strict%22%3Afalse%2C%22_view%22%3A%22html%22%7D%7D
Author
Owner

@nschonni commented on GitHub (Mar 31, 2020):

Sorry, I stripped down the example to the minimum viable, but in the case I came across, it was being escaped to it could be bolded/emphasized, so the backticks wouldn't work.

<!-- gh-comment-id:606362156 --> @nschonni commented on GitHub (Mar 31, 2020): Sorry, I stripped down the example to the minimum viable, but in the case I came across, it was being escaped to it could be bolded/emphasized, so the backticks wouldn't work.
Author
Owner

@DavidAnson commented on GitHub (Apr 1, 2020):

As I note above, the trick you show with backslash does not work with the markdown-itparser which means it shouldn’t work with any CommonMark parser.

There are other tricks:

But they are all unsightly and some break the link.

Ultimately, I think my recommendation is to disable MD034 for this scenario, either per-line, file, or project. Or disable auto-linking in the relevant Markdown parser (good ones should provide this option).

<!-- gh-comment-id:607055779 --> @DavidAnson commented on GitHub (Apr 1, 2020): As I note above, the trick you show with backslash does not work with the `markdown-it`parser which means it shouldn’t work with any CommonMark parser. There are other tricks: - https://stackoverflow.com/questions/25706012/how-do-i-prevent-auto-generated-links-in-the-github-wiki - https://gist.github.com/alexpeattie/4729247 But they are all unsightly and some break the link. Ultimately, I think my recommendation is to disable MD034 for this scenario, either per-line, file, or project. Or disable auto-linking in the relevant Markdown parser (good ones should provide this option).
Author
Owner

@nschonni commented on GitHub (Apr 1, 2020):

This is for docs.microsoft.com content, so Markdig :)

<!-- gh-comment-id:607286658 --> @nschonni commented on GitHub (Apr 1, 2020): This is for docs.microsoft.com content, so Markdig :)
Author
Owner

@DavidAnson commented on GitHub (Apr 2, 2020):

This works (using the zero-width non-breaking space character), though it’s pretty ugly in the source. However, I think it’s the best I can offer:

https://dlaa.me/markdownlint/#%25m%23%20Issue%20269%0A%0Ahttp%3A%26%2365279%3B%2F%2Fwww.contoso.com%0A

<!-- gh-comment-id:607637839 --> @DavidAnson commented on GitHub (Apr 2, 2020): This works (using the zero-width non-breaking space character), though it’s pretty ugly in the source. However, I think it’s the best I can offer: https://dlaa.me/markdownlint/#%25m%23%20Issue%20269%0A%0Ahttp%3A%26%2365279%3B%2F%2Fwww.contoso.com%0A
Author
Owner

@nschonni commented on GitHub (Apr 2, 2020):

For the particular PR, they ended up just disabling the rule for it. Probably something for Markdown-it I guess, so it doesn't appear as a link in the AST

<!-- gh-comment-id:608150097 --> @nschonni commented on GitHub (Apr 2, 2020): For the particular PR, they ended up just disabling the rule for it. Probably something for Markdown-it I guess, so it doesn't appear as a link in the AST
Author
Owner

@DavidAnson commented on GitHub (Apr 6, 2020):

No clear fix here, and the issue seems to be mitigated by disabling the rule.

<!-- gh-comment-id:609578381 --> @DavidAnson commented on GitHub (Apr 6, 2020): No clear fix here, and the issue seems to be mitigated by disabling the rule.
Author
Owner

@nschonni commented on GitHub (Feb 10, 2022):

Ha, when to open up this issue again because I've hit it again on mdn/content 😄
FYI, I've got the basic config in that repo now, but it isn't fully plugged into the CI yet, so there is still regular regressions

<!-- gh-comment-id:1034448720 --> @nschonni commented on GitHub (Feb 10, 2022): Ha, when to open up this issue again because I've hit it again on mdn/content 😄 FYI, I've got the basic config in that repo now, but it isn't fully plugged into the CI yet, so there is still regular regressions
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#229
No description provided.