mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-16 22:10:13 +01:00
Update MD039/no-space-in-links to not remove code/emphasis markers when fixing issues (fixes #482).
This commit is contained in:
parent
a8f946e0b3
commit
7bb80d19b1
6 changed files with 207 additions and 5 deletions
|
|
@ -3967,7 +3967,7 @@ module.exports = {
|
|||
var linkText = "";
|
||||
var lineIndex = 0;
|
||||
children.forEach(function (child) {
|
||||
var content = child.content, type = child.type;
|
||||
var content = child.content, markup = child.markup, type = child.type;
|
||||
if (type === "link_open") {
|
||||
inLink = true;
|
||||
linkText = "";
|
||||
|
|
@ -4000,7 +4000,9 @@ module.exports = {
|
|||
lineIndex = 0;
|
||||
}
|
||||
else if (inLink) {
|
||||
linkText += content;
|
||||
linkText += type.endsWith("_inline") ?
|
||||
"".concat(markup).concat(content).concat(markup) :
|
||||
(content || markup);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ module.exports = {
|
|||
let linkText = "";
|
||||
let lineIndex = 0;
|
||||
children.forEach((child) => {
|
||||
const { content, type } = child;
|
||||
const { content, markup, type } = child;
|
||||
if (type === "link_open") {
|
||||
inLink = true;
|
||||
linkText = "";
|
||||
|
|
@ -57,7 +57,9 @@ module.exports = {
|
|||
lineNumber++;
|
||||
lineIndex = 0;
|
||||
} else if (inLink) {
|
||||
linkText += content;
|
||||
linkText += type.endsWith("_inline") ?
|
||||
`${markup}${content}${markup}` :
|
||||
(content || markup);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
|||
17
test/detailed-results-spaces-inside-link-text.md
Normal file
17
test/detailed-results-spaces-inside-link-text.md
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
# Spaces Inside Link Text
|
||||
|
||||
[ link ](https://example.com/) {MD039}
|
||||
|
||||
[ "link" ](https://example.com/) {MD039}
|
||||
|
||||
[ `link` ](https://example.com/) {MD039}
|
||||
|
||||
[ *link* ](https://example.com/) {MD039}
|
||||
|
||||
[ __link__ ](https://example.com/) {MD039}
|
||||
|
||||
[ link "link" ](https://example.com/) {MD039}
|
||||
|
||||
[ link `link` ](https://example.com/) {MD039}
|
||||
|
||||
[ *link* link ](https://example.com/) {MD039}
|
||||
17
test/detailed-results-spaces-inside-link-text.md.fixed
Normal file
17
test/detailed-results-spaces-inside-link-text.md.fixed
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
# Spaces Inside Link Text
|
||||
|
||||
[link](https://example.com/) {MD039}
|
||||
|
||||
["link"](https://example.com/) {MD039}
|
||||
|
||||
[`link`](https://example.com/) {MD039}
|
||||
|
||||
[*link*](https://example.com/) {MD039}
|
||||
|
||||
[__link__](https://example.com/) {MD039}
|
||||
|
||||
[link "link"](https://example.com/) {MD039}
|
||||
|
||||
[link `link`](https://example.com/) {MD039}
|
||||
|
||||
[*link* link](https://example.com/) {MD039}
|
||||
162
test/detailed-results-spaces-inside-link-text.results.json
Normal file
162
test/detailed-results-spaces-inside-link-text.results.json
Normal file
|
|
@ -0,0 +1,162 @@
|
|||
[
|
||||
{
|
||||
"errorContext": "[ link ]",
|
||||
"errorDetail": null,
|
||||
"errorRange": [
|
||||
1,
|
||||
8
|
||||
],
|
||||
"fixInfo": {
|
||||
"deleteCount": 6,
|
||||
"editColumn": 2,
|
||||
"insertText": "link"
|
||||
},
|
||||
"lineNumber": 3,
|
||||
"ruleDescription": "Spaces inside link text",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md039",
|
||||
"ruleNames": [
|
||||
"MD039",
|
||||
"no-space-in-links"
|
||||
]
|
||||
},
|
||||
{
|
||||
"errorContext": "[ \"link\" ]",
|
||||
"errorDetail": null,
|
||||
"errorRange": [
|
||||
1,
|
||||
10
|
||||
],
|
||||
"fixInfo": {
|
||||
"deleteCount": 8,
|
||||
"editColumn": 2,
|
||||
"insertText": "\"link\""
|
||||
},
|
||||
"lineNumber": 5,
|
||||
"ruleDescription": "Spaces inside link text",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md039",
|
||||
"ruleNames": [
|
||||
"MD039",
|
||||
"no-space-in-links"
|
||||
]
|
||||
},
|
||||
{
|
||||
"errorContext": "[ `link` ]",
|
||||
"errorDetail": null,
|
||||
"errorRange": [
|
||||
1,
|
||||
10
|
||||
],
|
||||
"fixInfo": {
|
||||
"deleteCount": 8,
|
||||
"editColumn": 2,
|
||||
"insertText": "`link`"
|
||||
},
|
||||
"lineNumber": 7,
|
||||
"ruleDescription": "Spaces inside link text",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md039",
|
||||
"ruleNames": [
|
||||
"MD039",
|
||||
"no-space-in-links"
|
||||
]
|
||||
},
|
||||
{
|
||||
"errorContext": "[ *link* ]",
|
||||
"errorDetail": null,
|
||||
"errorRange": [
|
||||
1,
|
||||
10
|
||||
],
|
||||
"fixInfo": {
|
||||
"deleteCount": 8,
|
||||
"editColumn": 2,
|
||||
"insertText": "*link*"
|
||||
},
|
||||
"lineNumber": 9,
|
||||
"ruleDescription": "Spaces inside link text",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md039",
|
||||
"ruleNames": [
|
||||
"MD039",
|
||||
"no-space-in-links"
|
||||
]
|
||||
},
|
||||
{
|
||||
"errorContext": "[ __link__ ]",
|
||||
"errorDetail": null,
|
||||
"errorRange": [
|
||||
1,
|
||||
12
|
||||
],
|
||||
"fixInfo": {
|
||||
"deleteCount": 10,
|
||||
"editColumn": 2,
|
||||
"insertText": "__link__"
|
||||
},
|
||||
"lineNumber": 11,
|
||||
"ruleDescription": "Spaces inside link text",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md039",
|
||||
"ruleNames": [
|
||||
"MD039",
|
||||
"no-space-in-links"
|
||||
]
|
||||
},
|
||||
{
|
||||
"errorContext": "[ link \"link\" ]",
|
||||
"errorDetail": null,
|
||||
"errorRange": [
|
||||
1,
|
||||
15
|
||||
],
|
||||
"fixInfo": {
|
||||
"deleteCount": 13,
|
||||
"editColumn": 2,
|
||||
"insertText": "link \"link\""
|
||||
},
|
||||
"lineNumber": 13,
|
||||
"ruleDescription": "Spaces inside link text",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md039",
|
||||
"ruleNames": [
|
||||
"MD039",
|
||||
"no-space-in-links"
|
||||
]
|
||||
},
|
||||
{
|
||||
"errorContext": "[ link `link` ]",
|
||||
"errorDetail": null,
|
||||
"errorRange": [
|
||||
1,
|
||||
15
|
||||
],
|
||||
"fixInfo": {
|
||||
"deleteCount": 13,
|
||||
"editColumn": 2,
|
||||
"insertText": "link `link`"
|
||||
},
|
||||
"lineNumber": 15,
|
||||
"ruleDescription": "Spaces inside link text",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md039",
|
||||
"ruleNames": [
|
||||
"MD039",
|
||||
"no-space-in-links"
|
||||
]
|
||||
},
|
||||
{
|
||||
"errorContext": "[ *link* link ]",
|
||||
"errorDetail": null,
|
||||
"errorRange": [
|
||||
1,
|
||||
15
|
||||
],
|
||||
"fixInfo": {
|
||||
"deleteCount": 13,
|
||||
"editColumn": 2,
|
||||
"insertText": "*link* link"
|
||||
},
|
||||
"lineNumber": 17,
|
||||
"ruleDescription": "Spaces inside link text",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md039",
|
||||
"ruleNames": [
|
||||
"MD039",
|
||||
"no-space-in-links"
|
||||
]
|
||||
}
|
||||
]
|
||||
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
[*foo*](https://bar/)
|
||||
|
||||
[**foo**](https://bar/)
|
||||
[__foo__](https://bar/)
|
||||
|
||||
[foo "bar"](https://baz/)
|
||||
|
||||
|
|
@ -28,6 +28,8 @@
|
|||
|
||||
[ *foo* ](https://bar/) {MD039}
|
||||
|
||||
[ __foo__ ](https://bar/) {MD039}
|
||||
|
||||
The following shouldn't break anything:
|
||||
[](/images/Screenshot.png)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue