mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-17 06:20:12 +01:00
Update MD039/no-space-in-links to fix reference-style links, be slightly more permissive matching link content.
This commit is contained in:
parent
064a1e33e1
commit
7a76f1d22d
6 changed files with 163 additions and 2 deletions
|
|
@ -3712,7 +3712,7 @@ module.exports = {
|
||||||
// @ts-check
|
// @ts-check
|
||||||
|
|
||||||
var _a = __webpack_require__(/*! ../helpers */ "../helpers/helpers.js"), addErrorContext = _a.addErrorContext, filterTokens = _a.filterTokens;
|
var _a = __webpack_require__(/*! ../helpers */ "../helpers/helpers.js"), addErrorContext = _a.addErrorContext, filterTokens = _a.filterTokens;
|
||||||
var spaceInLinkRe = /\[(?:\s+(?:[^\]]*?)\s*|(?:[^\]]*?)\s+)](?=\(\S*\))/;
|
var spaceInLinkRe = /\[(?:\s+(?:[^\]]*?)\s*|(?:[^\]]*?)\s+)](?=((?:\([^)]*\))|(?:\[[^\]]*\])))/;
|
||||||
module.exports = {
|
module.exports = {
|
||||||
"names": ["MD039", "no-space-in-links"],
|
"names": ["MD039", "no-space-in-links"],
|
||||||
"description": "Spaces inside link text",
|
"description": "Spaces inside link text",
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,8 @@
|
||||||
|
|
||||||
const { addErrorContext, filterTokens } = require("../helpers");
|
const { addErrorContext, filterTokens } = require("../helpers");
|
||||||
|
|
||||||
const spaceInLinkRe = /\[(?:\s+(?:[^\]]*?)\s*|(?:[^\]]*?)\s+)](?=\(\S*\))/;
|
const spaceInLinkRe =
|
||||||
|
/\[(?:\s+(?:[^\]]*?)\s*|(?:[^\]]*?)\s+)](?=((?:\([^)]*\))|(?:\[[^\]]*\])))/;
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
"names": [ "MD039", "no-space-in-links" ],
|
"names": [ "MD039", "no-space-in-links" ],
|
||||||
|
|
|
||||||
|
|
@ -28,3 +28,17 @@ Text <https://example.com/same> more \* text https://example.com/same more \[ te
|
||||||
Text https://example.com/first more text https://example.com/second still more text https://example.com/third done
|
Text https://example.com/first more text https://example.com/second still more text https://example.com/third done
|
||||||
|
|
||||||
(Incorrect link syntax)[https://www.example.com/]
|
(Incorrect link syntax)[https://www.example.com/]
|
||||||
|
|
||||||
|
Text [link ](https://example.com/) text.
|
||||||
|
|
||||||
|
Text [ link](https://example.com/) text.
|
||||||
|
|
||||||
|
Text [ link ](https://example.com/) text.
|
||||||
|
|
||||||
|
Text [link ][reference] text.
|
||||||
|
|
||||||
|
Text [ link][reference] text.
|
||||||
|
|
||||||
|
Text [ link ][reference] text.
|
||||||
|
|
||||||
|
[reference]: https://example.com/
|
||||||
|
|
|
||||||
|
|
@ -28,3 +28,17 @@ Text <https://example.com/same> more \* text https://example.com/same more \[ te
|
||||||
Text <https://example.com/first> more text <https://example.com/second> still more text <https://example.com/third> done
|
Text <https://example.com/first> more text <https://example.com/second> still more text <https://example.com/third> done
|
||||||
|
|
||||||
[Incorrect link syntax](https://www.example.com/)
|
[Incorrect link syntax](https://www.example.com/)
|
||||||
|
|
||||||
|
Text [link](https://example.com/) text.
|
||||||
|
|
||||||
|
Text [link](https://example.com/) text.
|
||||||
|
|
||||||
|
Text [link](https://example.com/) text.
|
||||||
|
|
||||||
|
Text [link][reference] text.
|
||||||
|
|
||||||
|
Text [link][reference] text.
|
||||||
|
|
||||||
|
Text [link][reference] text.
|
||||||
|
|
||||||
|
[reference]: https://example.com/
|
||||||
|
|
|
||||||
|
|
@ -271,5 +271,125 @@
|
||||||
"deleteCount": 25,
|
"deleteCount": 25,
|
||||||
"insertText": "<https://example.com/third>"
|
"insertText": "<https://example.com/third>"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"lineNumber": 32,
|
||||||
|
"ruleNames": [
|
||||||
|
"MD039",
|
||||||
|
"no-space-in-links"
|
||||||
|
],
|
||||||
|
"ruleDescription": "Spaces inside link text",
|
||||||
|
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md039",
|
||||||
|
"errorDetail": null,
|
||||||
|
"errorContext": "[link ]",
|
||||||
|
"errorRange": [
|
||||||
|
6,
|
||||||
|
7
|
||||||
|
],
|
||||||
|
"fixInfo": {
|
||||||
|
"editColumn": 7,
|
||||||
|
"deleteCount": 5,
|
||||||
|
"insertText": "link"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"lineNumber": 34,
|
||||||
|
"ruleNames": [
|
||||||
|
"MD039",
|
||||||
|
"no-space-in-links"
|
||||||
|
],
|
||||||
|
"ruleDescription": "Spaces inside link text",
|
||||||
|
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md039",
|
||||||
|
"errorDetail": null,
|
||||||
|
"errorContext": "[ link]",
|
||||||
|
"errorRange": [
|
||||||
|
6,
|
||||||
|
7
|
||||||
|
],
|
||||||
|
"fixInfo": {
|
||||||
|
"editColumn": 7,
|
||||||
|
"deleteCount": 5,
|
||||||
|
"insertText": "link"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"lineNumber": 36,
|
||||||
|
"ruleNames": [
|
||||||
|
"MD039",
|
||||||
|
"no-space-in-links"
|
||||||
|
],
|
||||||
|
"ruleDescription": "Spaces inside link text",
|
||||||
|
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md039",
|
||||||
|
"errorDetail": null,
|
||||||
|
"errorContext": "[ link ]",
|
||||||
|
"errorRange": [
|
||||||
|
6,
|
||||||
|
8
|
||||||
|
],
|
||||||
|
"fixInfo": {
|
||||||
|
"editColumn": 7,
|
||||||
|
"deleteCount": 6,
|
||||||
|
"insertText": "link"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"lineNumber": 38,
|
||||||
|
"ruleNames": [
|
||||||
|
"MD039",
|
||||||
|
"no-space-in-links"
|
||||||
|
],
|
||||||
|
"ruleDescription": "Spaces inside link text",
|
||||||
|
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md039",
|
||||||
|
"errorDetail": null,
|
||||||
|
"errorContext": "[link ]",
|
||||||
|
"errorRange": [
|
||||||
|
6,
|
||||||
|
7
|
||||||
|
],
|
||||||
|
"fixInfo": {
|
||||||
|
"editColumn": 7,
|
||||||
|
"deleteCount": 5,
|
||||||
|
"insertText": "link"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"lineNumber": 40,
|
||||||
|
"ruleNames": [
|
||||||
|
"MD039",
|
||||||
|
"no-space-in-links"
|
||||||
|
],
|
||||||
|
"ruleDescription": "Spaces inside link text",
|
||||||
|
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md039",
|
||||||
|
"errorDetail": null,
|
||||||
|
"errorContext": "[ link]",
|
||||||
|
"errorRange": [
|
||||||
|
6,
|
||||||
|
7
|
||||||
|
],
|
||||||
|
"fixInfo": {
|
||||||
|
"editColumn": 7,
|
||||||
|
"deleteCount": 5,
|
||||||
|
"insertText": "link"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"lineNumber": 42,
|
||||||
|
"ruleNames": [
|
||||||
|
"MD039",
|
||||||
|
"no-space-in-links"
|
||||||
|
],
|
||||||
|
"ruleDescription": "Spaces inside link text",
|
||||||
|
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md039",
|
||||||
|
"errorDetail": null,
|
||||||
|
"errorContext": "[ link ]",
|
||||||
|
"errorRange": [
|
||||||
|
6,
|
||||||
|
8
|
||||||
|
],
|
||||||
|
"fixInfo": {
|
||||||
|
"editColumn": 7,
|
||||||
|
"deleteCount": 6,
|
||||||
|
"insertText": "link"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
@ -50,3 +50,15 @@ Wrapped [ link with leading space
|
||||||
](https://example.com) {MD039}
|
](https://example.com) {MD039}
|
||||||
|
|
||||||
Non-wrapped [ link with leading space](https://example.com) {MD039}
|
Non-wrapped [ link with leading space](https://example.com) {MD039}
|
||||||
|
|
||||||
|
[][ref]
|
||||||
|
|
||||||
|
[link][ref]
|
||||||
|
|
||||||
|
[link ][ref] {MD039}
|
||||||
|
|
||||||
|
[ link][ref] {MD039}
|
||||||
|
|
||||||
|
[ link ][ref] {MD039}
|
||||||
|
|
||||||
|
[ref]: https://example.com
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue