markdownlint
markdownlint copied to clipboard
Add rule to enforce links as reference links
As default deactivated. If active, raise error here:
I'm a paragraph with [a link](http://link-to-somewhere)
...but passes this:
I'm a paragraph with [a link][link-to-somewhere]
[link-to-somewhere]: http://link-to-somewhere
It would also be nice if this was configurable by the length of the URL — i.e. non-reference links shorter than N characters would not trigger this rule, with the default max length being 0.
Agree, I like the rule and the parameter suggestion.
@DavidAnson @mondeja Any interest in an additional rule to enforce correct style on reference links for at least one unit of whitespace after the colon?
This would fail:
[link-to-somewhere]:http://link-to-somewhere
This would pass:
[link-to-somewhere]: http://link-to-somewhere
It doesn't seem required by the specification, but I agree that one space is stylistically preferred. This would be a reasonable rule.
CommonMark deviates from this and says it is optional but it is mentioned explicitly in the original Daring Fireball docs:
Then, anywhere in the document, you define your link label like this, on a line by itself:
[id]: http://example.com/ "Optional Title Here"
That is:
Square brackets containing the link identifier (optionally indented from the left margin using up to three spaces); followed by a colon; followed by one or more spaces (or tabs); followed by the URL for the link; optionally followed by a title attribute for the link, enclosed in double or single quotes, or enclosed in parentheses.
Opened https://github.com/DavidAnson/markdownlint/issues/326
Sorry to interrupt this, but thanks for the quick answers!
I would like this as an optional rule, either with or without the space. (Though I prefer with the space)
Possible duplicate of #40 ?
Yes, looks like #40 covers the same functionality with more options.
Agree, thanks!