mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2026-04-25 09:16:02 +03:00
[GH-ISSUE #1616] MD034 - Bare URL used > advice gives code that fails npm/docusaurus md to html conversion/build #2567
Labels
No labels
bug
enhancement
enhancement
enhancement
fixed in next
fixed in next
fixed in next
new rule
new rule
new rule
pull-request
question
refactoring
refactoring
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/markdownlint#2567
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @TuxVinyards on GitHub (May 27, 2025).
Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/1616
The advice given in doc/md034.md throws build errors with
npmwhen using it:I have found that the following pattern in the Docusaurus templates works better instead:
As in https://www.example.com/
Or https://github.com/facebook/docusaurus/blob/main/website/docs/deployment.mdx?plain=1 at line 44
Not sure how much this is a
npmthing or how much it is Docusaurus.Obviously it doesn't happen with GitHub readme files but maybe other .md convertors are affected too?
@DavidAnson commented on GitHub (May 27, 2025):
These are both valid syntax for Markdown links, so I do not understand what you mean by "throws build errors with npm". Please explain that and give an example of what you think the problem is.
If you want to enforce a particular style for links and images (like above), you can use MD054 to do so: https://github.com/DavidAnson/markdownlint/blob/main/doc/md054.md
@TuxVinyards commented on GitHub (May 28, 2025):
Thanks for looking at this.
This issue is really a heads up to say that maybe the guidance in MD034 needs expanding or clarifying as it doesn't work in all cases. But it's your project, so your call ....
What's happening is GitHub allows both raw links and angle bracketed links in their markdown editor. At some stage while working on the .md files I must have pasted in some raw links. Later when I opened the files using VScode your linter pointed me to MD034 where I told:
So this is what I did.
But I have now started looking at creating some github pages. I thought Docusaurus looked like an easy option but found myself getting errors:
The advice, at the end of several of the lines, is:
and for me that solves the problem.
I just wanted to give you some feedback to say that
To fix this, add angle bracketsdoesn't always fix things ....I also did some further looking and ended up trying AI assist:
But then there is this:
In turn countered by this:
So, use square brackets with a descriptor then, as in MD059 maybe?
@DavidAnson commented on GitHub (May 28, 2025):
This project is a linter for Markdown as defined by the CommonMark specification (including some common GitHub Flavored Markdown patterns). In your case, it looks like Docusaurus and/or MDX decided to break compatibility with CommonMark and not allow some valid syntax. In such cases, I recommend disabling the relevant lint rules or configuring them to accommodate the custom behavior. The advice given by MD034 is (still) a best practice for Markdown in my opinion.
@TuxVinyards commented on GitHub (May 29, 2025):
Much thanks for helping clear things up. The data-overload veil of confusion is starting to lift:
It seems that Docusaurus is indeed parsing plain
.mdfiles as.mdxunless you specify otherwise in the config. Also that their CommonMark parser does have wrinkles to iron out still. I will obviously have to embrace mdx or find a different system ....MDX will generally parse CommonMark but autolinks are an exception. This is because
.mdxfiles can contain JSX which is enclosed in angled brackets: https://github.com/micromark/mdx-state-machine#72-deviations-from-markdownHowever, I do note that CommonMark itself is still a work in progress even at BabelMark3:
Looking at the current spec for autolinks it's clear that they are not a universal panacea and that they still have quite a few limitations themselves.
One of the links that I had had was this: https://en.wikipedia.org/wiki/Wayland_(protocol) but if we see https://spec.commonmark.org/0.31.2/#example-603 it would have in fact failed if angled brackets were used.
Putting a deep link to the specs
#autolinkssection, to one that is always the current version could be tricky (?) but a bit more on autolink limitations might be something to consider. I have used markdown for years on Wikipedia. I didn't know that the spec was so complicated.This issue is probably good to close, I guess.
@DavidAnson commented on GitHub (May 29, 2025):
OK, thanks, I'll close this.
FYI, your example above can be expressed using angle brackets and it does not need backlash escaping: https://dlaa.me/markdownlint/#%25m%23%20Issue%201616%0A%0A%3Chttps%3A%2F%2Fen.m.wikipedia.org%2Fwiki%2FWayland_(protocol)%3E%0A