mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-16 22:10:13 +01:00
Update MD051/link-fragments to ignore HTML comments embedded in heading text.
This commit is contained in:
parent
6700accfd3
commit
1bd748f79e
5 changed files with 40 additions and 10 deletions
|
|
@ -4610,7 +4610,10 @@ const identifierRe = /(?:id|name)\s*=\s*['"]?([^'"\s>]+)/iu;
|
|||
* @returns {string} Fragment string for heading.
|
||||
*/
|
||||
function convertHeadingToHTMLFragment(inline) {
|
||||
const inlineText = inline.children.map((token) => token.content).join("");
|
||||
const inlineText = inline.children
|
||||
.filter((token) => token.type !== "html_inline")
|
||||
.map((token) => token.content)
|
||||
.join("");
|
||||
return "#" + encodeURIComponent(inlineText
|
||||
.toLowerCase()
|
||||
// RegExp source with Ruby's \p{Word} expanded into its General Categories
|
||||
|
|
@ -4663,7 +4666,7 @@ module.exports = {
|
|||
context = match[0];
|
||||
range = [match.index + 1, match[0].length];
|
||||
}
|
||||
addError(onError, lineNumber, null, context, range);
|
||||
addError(onError, lineNumber, undefined, context, range);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,10 @@ const identifierRe = /(?:id|name)\s*=\s*['"]?([^'"\s>]+)/iu;
|
|||
* @returns {string} Fragment string for heading.
|
||||
*/
|
||||
function convertHeadingToHTMLFragment(inline) {
|
||||
const inlineText = inline.children.map((token) => token.content).join("");
|
||||
const inlineText = inline.children
|
||||
.filter((token) => token.type !== "html_inline")
|
||||
.map((token) => token.content)
|
||||
.join("");
|
||||
return "#" + encodeURIComponent(
|
||||
inlineText
|
||||
.toLowerCase()
|
||||
|
|
@ -77,7 +80,7 @@ module.exports = {
|
|||
context = match[0];
|
||||
range = [ match.index + 1, match[0].length ];
|
||||
}
|
||||
addError(onError, lineNumber, null, context, range);
|
||||
addError(onError, lineNumber, undefined, context, range);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,6 +32,12 @@
|
|||
|
||||
[Valid](#valid-repeated-heading-2)
|
||||
|
||||
[Valid](#valid-heading-with-trailing-space-)
|
||||
|
||||
[Valid](#valid-heading-with-two-trailing-spaces--)
|
||||
|
||||
[Valid](#valid-heading-with-embedded--comment)
|
||||
|
||||
[Valid](#namedlink)
|
||||
|
||||
[Valid](#idlink)
|
||||
|
|
@ -93,6 +99,12 @@ Text
|
|||
|
||||
### Valid Repeated Heading
|
||||
|
||||
### Valid Heading With Trailing Space <!-- comment -->
|
||||
|
||||
### Valid Heading With Two Trailing Spaces <!-- comment -->
|
||||
|
||||
### Valid Heading With Embedded <!-- comment --> Comment
|
||||
|
||||
<a name="namedlink"></a>
|
||||
|
||||
<a id = idlink></a>
|
||||
|
|
|
|||
|
|
@ -20950,7 +20950,7 @@ Generated by [AVA](https://avajs.dev).
|
|||
31,
|
||||
],
|
||||
fixInfo: null,
|
||||
lineNumber: 108,
|
||||
lineNumber: 120,
|
||||
ruleDescription: 'Link fragments should be valid',
|
||||
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md051',
|
||||
ruleNames: [
|
||||
|
|
@ -20966,7 +20966,7 @@ Generated by [AVA](https://avajs.dev).
|
|||
36,
|
||||
],
|
||||
fixInfo: null,
|
||||
lineNumber: 110,
|
||||
lineNumber: 122,
|
||||
ruleDescription: 'Link fragments should be valid',
|
||||
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md051',
|
||||
ruleNames: [
|
||||
|
|
@ -20982,7 +20982,7 @@ Generated by [AVA](https://avajs.dev).
|
|||
28,
|
||||
],
|
||||
fixInfo: null,
|
||||
lineNumber: 112,
|
||||
lineNumber: 124,
|
||||
ruleDescription: 'Link fragments should be valid',
|
||||
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md051',
|
||||
ruleNames: [
|
||||
|
|
@ -20998,7 +20998,7 @@ Generated by [AVA](https://avajs.dev).
|
|||
18,
|
||||
],
|
||||
fixInfo: null,
|
||||
lineNumber: 114,
|
||||
lineNumber: 126,
|
||||
ruleDescription: 'Link fragments should be valid',
|
||||
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md051',
|
||||
ruleNames: [
|
||||
|
|
@ -21014,7 +21014,7 @@ Generated by [AVA](https://avajs.dev).
|
|||
21,
|
||||
],
|
||||
fixInfo: null,
|
||||
lineNumber: 116,
|
||||
lineNumber: 128,
|
||||
ruleDescription: 'Link fragments should be valid',
|
||||
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md051',
|
||||
ruleNames: [
|
||||
|
|
@ -21027,7 +21027,7 @@ Generated by [AVA](https://avajs.dev).
|
|||
errorDetail: null,
|
||||
errorRange: null,
|
||||
fixInfo: null,
|
||||
lineNumber: 118,
|
||||
lineNumber: 130,
|
||||
ruleDescription: 'Link fragments should be valid',
|
||||
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md051',
|
||||
ruleNames: [
|
||||
|
|
@ -21070,6 +21070,12 @@ Generated by [AVA](https://avajs.dev).
|
|||
␊
|
||||
[Valid](#valid-repeated-heading-2)␊
|
||||
␊
|
||||
[Valid](#valid-heading-with-trailing-space-)␊
|
||||
␊
|
||||
[Valid](#valid-heading-with-two-trailing-spaces--)␊
|
||||
␊
|
||||
[Valid](#valid-heading-with-embedded--comment)␊
|
||||
␊
|
||||
[Valid](#namedlink)␊
|
||||
␊
|
||||
[Valid](#idlink)␊
|
||||
|
|
@ -21131,6 +21137,12 @@ Generated by [AVA](https://avajs.dev).
|
|||
␊
|
||||
### Valid Repeated Heading␊
|
||||
␊
|
||||
### Valid Heading With Trailing Space <!-- comment -->␊
|
||||
␊
|
||||
### Valid Heading With Two Trailing Spaces <!-- comment -->␊
|
||||
␊
|
||||
### Valid Heading With Embedded <!-- comment --> Comment␊
|
||||
␊
|
||||
<a name="namedlink"></a>␊
|
||||
␊
|
||||
<a id = idlink></a>␊
|
||||
|
|
|
|||
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue