mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-16 14:00:13 +01:00
Update MD052/reference-links-images to add a shortcut_syntax parameter for opting into shortcut scanning (fixes #915).
This commit is contained in:
parent
a736588958
commit
c118c1160a
13 changed files with 433 additions and 29 deletions
|
|
@ -912,7 +912,7 @@ test("readme", async(t) => {
|
|||
});
|
||||
|
||||
test("validateJsonUsingConfigSchemaStrict", (t) => {
|
||||
t.plan(160);
|
||||
t.plan(161);
|
||||
const configRe =
|
||||
/^[\s\S]*<!-- markdownlint-configure-file ([\s\S]*) -->[\s\S]*$/;
|
||||
const ignoreFiles = new Set([
|
||||
|
|
|
|||
112
test/reference-links-and-images-shortcuts.md
Normal file
112
test/reference-links-and-images-shortcuts.md
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
# Reference Links and Images (Shortcuts)
|
||||
|
||||
## Shortcut Handling
|
||||
|
||||
Validates the shortcut: [shortcut]
|
||||
|
||||
[shortcut]: https://example.com/shortcut
|
||||
|
||||
Missing reference: [missing] {MD052}
|
||||
|
||||
## Valid Links
|
||||
|
||||
Full reference link: [text][label]
|
||||
|
||||
Collapsed reference link: [label][]
|
||||
|
||||
Shortcut reference link: [label]
|
||||
|
||||
Same line: [text][label] [label][] [label]
|
||||
|
||||
Mixed case: [TEXT][LABEL] [LABEL][] [LABEL]
|
||||
|
||||
With nested brackets: [t\[ex\]t][label]
|
||||
|
||||
Shortcut inline code span: [`code`]
|
||||
|
||||
Shortcut ending in colon: [colon]:
|
||||
|
||||
## Invalid Links
|
||||
|
||||
Missing: [missing] {MD052}
|
||||
|
||||
> Missing in blockquote: [missing] {MD052}
|
||||
|
||||
## Non-Links
|
||||
|
||||
Code span: `[code]`
|
||||
|
||||
Escaped left: \[escaped]
|
||||
|
||||
Escaped right: [escaped\]
|
||||
|
||||
Escaped both: \[escaped\]
|
||||
|
||||
Unmatched [ in text
|
||||
|
||||
Unmatched ] in text
|
||||
|
||||
## Valid Images
|
||||
|
||||
Full style: ![text][image0]
|
||||
|
||||
Collapsed style: ![image1][]
|
||||
|
||||
Shortcut style: ![image2]
|
||||
|
||||
Image in link: [![text][image3]](link) [![image4][]](link) [![image5]](link)
|
||||
|
||||
Image in shortcut link: [![text][image6]][unique6] [![image7][]][unique7] [![image8]][unique8]
|
||||
|
||||
Wrapped in brackets: \[![text][unique9]\]
|
||||
|
||||
Embedded \[in ![text][unique10] brackets\]
|
||||
|
||||
## Invalid Images
|
||||
|
||||
Missing: ![missing] {MD052}
|
||||
|
||||
> Missing in blockquote: ![missing] {MD052}
|
||||
|
||||
## Non-Images
|
||||
|
||||
Escaped left: !\[escaped]
|
||||
|
||||
Escaped right: ![escaped\]
|
||||
|
||||
Escaped both: !\[escaped\]
|
||||
|
||||
## Valid Footnotes
|
||||
|
||||
Footnote[^1]
|
||||
|
||||
## Invalid Footnotes
|
||||
|
||||
Missing[^2] {MD052}
|
||||
|
||||
## Valid Labels
|
||||
|
||||
[label]: https://example.com/label
|
||||
[image0]: https://example.com/image0
|
||||
[image1]: https://example.com/image1
|
||||
[image2]: https://example.com/image2
|
||||
[image3]: https://example.com/image3
|
||||
[image4]: https://example.com/image4
|
||||
[image5]: https://example.com/image5
|
||||
[image6]: https://example.com/image6
|
||||
[image7]: https://example.com/image7
|
||||
[image8]: https://example.com/image8
|
||||
[`code`]: https://example.com/code
|
||||
[colon]: https://example.com/colon
|
||||
[unique6]: https://example.com/unique6
|
||||
[unique7]: https://example.com/unique7
|
||||
[unique8]: https://example.com/unique8
|
||||
[unique9]: https://example.com/unique9
|
||||
[unique10]: https://example.com/unique10
|
||||
[^1]: https://example.com/footnote {MD034}
|
||||
|
||||
<!-- markdownlint-configure-file {
|
||||
"reference-links-images": {
|
||||
"shortcut_syntax": true
|
||||
}
|
||||
} -->
|
||||
|
|
@ -38664,6 +38664,244 @@ Generated by [AVA](https://avajs.dev).
|
|||
`,
|
||||
}
|
||||
|
||||
## reference-links-and-images-shortcuts.md
|
||||
|
||||
> Snapshot 1
|
||||
|
||||
{
|
||||
errors: [
|
||||
{
|
||||
errorContext: 'https://example.com/footnote',
|
||||
errorDetail: null,
|
||||
errorRange: [
|
||||
7,
|
||||
28,
|
||||
],
|
||||
fixInfo: {
|
||||
deleteCount: 28,
|
||||
editColumn: 7,
|
||||
insertText: '<https://example.com/footnote>',
|
||||
},
|
||||
lineNumber: 106,
|
||||
ruleDescription: 'Bare URL used',
|
||||
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md034.md',
|
||||
ruleNames: [
|
||||
'MD034',
|
||||
'no-bare-urls',
|
||||
],
|
||||
},
|
||||
{
|
||||
errorContext: '[missing]',
|
||||
errorDetail: 'Missing link or image reference definition: "missing"',
|
||||
errorRange: [
|
||||
20,
|
||||
9,
|
||||
],
|
||||
fixInfo: null,
|
||||
lineNumber: 9,
|
||||
ruleDescription: 'Reference links and images should use a label that is defined',
|
||||
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md052.md',
|
||||
ruleNames: [
|
||||
'MD052',
|
||||
'reference-links-images',
|
||||
],
|
||||
},
|
||||
{
|
||||
errorContext: '[missing]',
|
||||
errorDetail: 'Missing link or image reference definition: "missing"',
|
||||
errorRange: [
|
||||
10,
|
||||
9,
|
||||
],
|
||||
fixInfo: null,
|
||||
lineNumber: 31,
|
||||
ruleDescription: 'Reference links and images should use a label that is defined',
|
||||
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md052.md',
|
||||
ruleNames: [
|
||||
'MD052',
|
||||
'reference-links-images',
|
||||
],
|
||||
},
|
||||
{
|
||||
errorContext: '[missing]',
|
||||
errorDetail: 'Missing link or image reference definition: "missing"',
|
||||
errorRange: [
|
||||
26,
|
||||
9,
|
||||
],
|
||||
fixInfo: null,
|
||||
lineNumber: 33,
|
||||
ruleDescription: 'Reference links and images should use a label that is defined',
|
||||
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md052.md',
|
||||
ruleNames: [
|
||||
'MD052',
|
||||
'reference-links-images',
|
||||
],
|
||||
},
|
||||
{
|
||||
errorContext: '![missing]',
|
||||
errorDetail: 'Missing link or image reference definition: "missing"',
|
||||
errorRange: [
|
||||
10,
|
||||
10,
|
||||
],
|
||||
fixInfo: null,
|
||||
lineNumber: 67,
|
||||
ruleDescription: 'Reference links and images should use a label that is defined',
|
||||
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md052.md',
|
||||
ruleNames: [
|
||||
'MD052',
|
||||
'reference-links-images',
|
||||
],
|
||||
},
|
||||
{
|
||||
errorContext: '![missing]',
|
||||
errorDetail: 'Missing link or image reference definition: "missing"',
|
||||
errorRange: [
|
||||
26,
|
||||
10,
|
||||
],
|
||||
fixInfo: null,
|
||||
lineNumber: 69,
|
||||
ruleDescription: 'Reference links and images should use a label that is defined',
|
||||
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md052.md',
|
||||
ruleNames: [
|
||||
'MD052',
|
||||
'reference-links-images',
|
||||
],
|
||||
},
|
||||
{
|
||||
errorContext: '[^2]',
|
||||
errorDetail: 'Missing link or image reference definition: "^2"',
|
||||
errorRange: [
|
||||
8,
|
||||
4,
|
||||
],
|
||||
fixInfo: null,
|
||||
lineNumber: 85,
|
||||
ruleDescription: 'Reference links and images should use a label that is defined',
|
||||
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md052.md',
|
||||
ruleNames: [
|
||||
'MD052',
|
||||
'reference-links-images',
|
||||
],
|
||||
},
|
||||
],
|
||||
fixed: `# Reference Links and Images (Shortcuts)␊
|
||||
␊
|
||||
## Shortcut Handling␊
|
||||
␊
|
||||
Validates the shortcut: [shortcut]␊
|
||||
␊
|
||||
[shortcut]: https://example.com/shortcut␊
|
||||
␊
|
||||
Missing reference: [missing] {MD052}␊
|
||||
␊
|
||||
## Valid Links␊
|
||||
␊
|
||||
Full reference link: [text][label]␊
|
||||
␊
|
||||
Collapsed reference link: [label][]␊
|
||||
␊
|
||||
Shortcut reference link: [label]␊
|
||||
␊
|
||||
Same line: [text][label] [label][] [label]␊
|
||||
␊
|
||||
Mixed case: [TEXT][LABEL] [LABEL][] [LABEL]␊
|
||||
␊
|
||||
With nested brackets: [t\\[ex\\]t][label]␊
|
||||
␊
|
||||
Shortcut inline code span: [\`code\`]␊
|
||||
␊
|
||||
Shortcut ending in colon: [colon]:␊
|
||||
␊
|
||||
## Invalid Links␊
|
||||
␊
|
||||
Missing: [missing] {MD052}␊
|
||||
␊
|
||||
> Missing in blockquote: [missing] {MD052}␊
|
||||
␊
|
||||
## Non-Links␊
|
||||
␊
|
||||
Code span: \`[code]\`␊
|
||||
␊
|
||||
Escaped left: \\[escaped]␊
|
||||
␊
|
||||
Escaped right: [escaped\\]␊
|
||||
␊
|
||||
Escaped both: \\[escaped\\]␊
|
||||
␊
|
||||
Unmatched [ in text␊
|
||||
␊
|
||||
Unmatched ] in text␊
|
||||
␊
|
||||
## Valid Images␊
|
||||
␊
|
||||
Full style: ![text][image0]␊
|
||||
␊
|
||||
Collapsed style: ![image1][]␊
|
||||
␊
|
||||
Shortcut style: ![image2]␊
|
||||
␊
|
||||
Image in link: [![text][image3]](link) [![image4][]](link) [![image5]](link)␊
|
||||
␊
|
||||
Image in shortcut link: [![text][image6]][unique6] [![image7][]][unique7] [![image8]][unique8]␊
|
||||
␊
|
||||
Wrapped in brackets: \\[![text][unique9]\\]␊
|
||||
␊
|
||||
Embedded \\[in ![text][unique10] brackets\\]␊
|
||||
␊
|
||||
## Invalid Images␊
|
||||
␊
|
||||
Missing: ![missing] {MD052}␊
|
||||
␊
|
||||
> Missing in blockquote: ![missing] {MD052}␊
|
||||
␊
|
||||
## Non-Images␊
|
||||
␊
|
||||
Escaped left: !\\[escaped]␊
|
||||
␊
|
||||
Escaped right: ![escaped\\]␊
|
||||
␊
|
||||
Escaped both: !\\[escaped\\]␊
|
||||
␊
|
||||
## Valid Footnotes␊
|
||||
␊
|
||||
Footnote[^1]␊
|
||||
␊
|
||||
## Invalid Footnotes␊
|
||||
␊
|
||||
Missing[^2] {MD052}␊
|
||||
␊
|
||||
## Valid Labels␊
|
||||
␊
|
||||
[label]: https://example.com/label␊
|
||||
[image0]: https://example.com/image0␊
|
||||
[image1]: https://example.com/image1␊
|
||||
[image2]: https://example.com/image2␊
|
||||
[image3]: https://example.com/image3␊
|
||||
[image4]: https://example.com/image4␊
|
||||
[image5]: https://example.com/image5␊
|
||||
[image6]: https://example.com/image6␊
|
||||
[image7]: https://example.com/image7␊
|
||||
[image8]: https://example.com/image8␊
|
||||
[\`code\`]: https://example.com/code␊
|
||||
[colon]: https://example.com/colon␊
|
||||
[unique6]: https://example.com/unique6␊
|
||||
[unique7]: https://example.com/unique7␊
|
||||
[unique8]: https://example.com/unique8␊
|
||||
[unique9]: https://example.com/unique9␊
|
||||
[unique10]: https://example.com/unique10␊
|
||||
[^1]: <https://example.com/footnote> {MD034}␊
|
||||
␊
|
||||
<!-- markdownlint-configure-file {␊
|
||||
"reference-links-images": {␊
|
||||
"shortcut_syntax": true␊
|
||||
}␊
|
||||
} -->␊
|
||||
`,
|
||||
}
|
||||
|
||||
## reference-links-and-images.md
|
||||
|
||||
> Snapshot 1
|
||||
|
|
|
|||
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue