Closed nschonni closed 4 years ago
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
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
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.
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:
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).
This is for docs.microsoft.com content, so Markdig :)
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:
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
No clear fix here, and the issue seems to be mitigated by disabling the rule.
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
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.