mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-16 22:10:13 +01:00
Add MD052/reference-links-images and MD053/link-image-reference-definitions for reporting issues with link and image references (fixes #144, fixes #390, fixes #425, fixes #456).
This commit is contained in:
parent
2c947abf7b
commit
c5ca661b96
21 changed files with 1333 additions and 65 deletions
|
|
@ -5750,7 +5750,7 @@ Generated by [AVA](https://avajs.dev).
|
|||
insertText: `␊
|
||||
`,
|
||||
},
|
||||
lineNumber: 98,
|
||||
lineNumber: 101,
|
||||
ruleDescription: 'Files should end with a single newline character',
|
||||
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md047',
|
||||
ruleNames: [
|
||||
|
|
@ -5827,6 +5827,40 @@ Generated by [AVA](https://avajs.dev).
|
|||
'link-fragments',
|
||||
],
|
||||
},
|
||||
{
|
||||
errorContext: '[Missing link][label]',
|
||||
errorDetail: 'Missing link or image reference definition: "label"',
|
||||
errorRange: [
|
||||
1,
|
||||
21,
|
||||
],
|
||||
fixInfo: null,
|
||||
lineNumber: 98,
|
||||
ruleDescription: 'Reference links and images should use a label that is defined',
|
||||
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md052',
|
||||
ruleNames: [
|
||||
'MD052',
|
||||
'reference-links-images',
|
||||
],
|
||||
},
|
||||
{
|
||||
errorContext: '[unused]: link-destination {MD...',
|
||||
errorDetail: 'Unused link or image reference definition: "unused"',
|
||||
errorRange: [
|
||||
1,
|
||||
34,
|
||||
],
|
||||
fixInfo: {
|
||||
deleteCount: -1,
|
||||
},
|
||||
lineNumber: 99,
|
||||
ruleDescription: 'Link and image reference definitions should be needed',
|
||||
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md053',
|
||||
ruleNames: [
|
||||
'MD053',
|
||||
'link-image-reference-definitions',
|
||||
],
|
||||
},
|
||||
],
|
||||
fixed: `## Heading 1 {MD002} {MD041}␊
|
||||
␊
|
||||
|
|
@ -5927,6 +5961,8 @@ Generated by [AVA](https://avajs.dev).
|
|||
␊
|
||||
[Missing link fragment](#missing) {MD051}␊
|
||||
␊
|
||||
[Missing link][label] {MD052}␊
|
||||
␊
|
||||
EOF {MD047}␊
|
||||
`,
|
||||
}
|
||||
|
|
@ -27459,6 +27495,22 @@ Generated by [AVA](https://avajs.dev).
|
|||
'strong-style',
|
||||
],
|
||||
},
|
||||
{
|
||||
errorContext: '[Link to broken label][notlabel]',
|
||||
errorDetail: 'Missing link or image reference definition: "notlabel"',
|
||||
errorRange: [
|
||||
1,
|
||||
32,
|
||||
],
|
||||
fixInfo: null,
|
||||
lineNumber: 27,
|
||||
ruleDescription: 'Reference links and images should use a label that is defined',
|
||||
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md052',
|
||||
ruleNames: [
|
||||
'MD052',
|
||||
'reference-links-images',
|
||||
],
|
||||
},
|
||||
],
|
||||
fixed: `# Long Lines␊
|
||||
␊
|
||||
|
|
@ -27486,7 +27538,7 @@ Generated by [AVA](https://avajs.dev).
|
|||
␊
|
||||
[label]: https://example.org "Title for a link reference that is itself long enough to violate the rule"␊
|
||||
␊
|
||||
[Link to broken label][notlabel]␊
|
||||
[Link to broken label][notlabel] {MD052}␊
|
||||
␊
|
||||
[notlabel\\]: notlink "Invalid syntax for a link label because the right bracket is backslash-escaped {MD013}"␊
|
||||
␊
|
||||
|
|
@ -33027,6 +33079,375 @@ Generated by [AVA](https://avajs.dev).
|
|||
`,
|
||||
}
|
||||
|
||||
## reference-links-and-images.md
|
||||
|
||||
> Snapshot 1
|
||||
|
||||
{
|
||||
errors: [
|
||||
{
|
||||
errorContext: '[text][missing]',
|
||||
errorDetail: 'Missing link or image reference definition: "missing"',
|
||||
errorRange: [
|
||||
16,
|
||||
15,
|
||||
],
|
||||
fixInfo: null,
|
||||
lineNumber: 51,
|
||||
ruleDescription: 'Reference links and images should use a label that is defined',
|
||||
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md052',
|
||||
ruleNames: [
|
||||
'MD052',
|
||||
'reference-links-images',
|
||||
],
|
||||
},
|
||||
{
|
||||
errorContext: '[text][missing]',
|
||||
errorDetail: 'Missing link or image reference definition: "missing"',
|
||||
errorRange: [
|
||||
36,
|
||||
15,
|
||||
],
|
||||
fixInfo: null,
|
||||
lineNumber: 53,
|
||||
ruleDescription: 'Reference links and images should use a label that is defined',
|
||||
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md052',
|
||||
ruleNames: [
|
||||
'MD052',
|
||||
'reference-links-images',
|
||||
],
|
||||
},
|
||||
{
|
||||
errorContext: '[text][missing',
|
||||
errorDetail: 'Missing link or image reference definition: "missing label"',
|
||||
errorRange: [
|
||||
35,
|
||||
14,
|
||||
],
|
||||
fixInfo: null,
|
||||
lineNumber: 55,
|
||||
ruleDescription: 'Reference links and images should use a label that is defined',
|
||||
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md052',
|
||||
ruleNames: [
|
||||
'MD052',
|
||||
'reference-links-images',
|
||||
],
|
||||
},
|
||||
{
|
||||
errorContext: '![text][missing]',
|
||||
errorDetail: 'Missing link or image reference definition: "missing"',
|
||||
errorRange: [
|
||||
13,
|
||||
16,
|
||||
],
|
||||
fixInfo: null,
|
||||
lineNumber: 86,
|
||||
ruleDescription: 'Reference links and images should use a label that is defined',
|
||||
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md052',
|
||||
ruleNames: [
|
||||
'MD052',
|
||||
'reference-links-images',
|
||||
],
|
||||
},
|
||||
{
|
||||
errorContext: '![text][missing]',
|
||||
errorDetail: 'Missing link or image reference definition: "missing"',
|
||||
errorRange: [
|
||||
17,
|
||||
16,
|
||||
],
|
||||
fixInfo: null,
|
||||
lineNumber: 88,
|
||||
ruleDescription: 'Reference links and images should use a label that is defined',
|
||||
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md052',
|
||||
ruleNames: [
|
||||
'MD052',
|
||||
'reference-links-images',
|
||||
],
|
||||
},
|
||||
{
|
||||
errorContext: '[![text][image]][missing]',
|
||||
errorDetail: 'Missing link or image reference definition: "missing"',
|
||||
errorRange: [
|
||||
21,
|
||||
25,
|
||||
],
|
||||
fixInfo: null,
|
||||
lineNumber: 150,
|
||||
ruleDescription: 'Reference links and images should use a label that is defined',
|
||||
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md052',
|
||||
ruleNames: [
|
||||
'MD052',
|
||||
'reference-links-images',
|
||||
],
|
||||
},
|
||||
{
|
||||
errorContext: '[hidden][]',
|
||||
errorDetail: 'Missing link or image reference definition: "hidden"',
|
||||
errorRange: [
|
||||
19,
|
||||
10,
|
||||
],
|
||||
fixInfo: null,
|
||||
lineNumber: 164,
|
||||
ruleDescription: 'Reference links and images should use a label that is defined',
|
||||
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md052',
|
||||
ruleNames: [
|
||||
'MD052',
|
||||
'reference-links-images',
|
||||
],
|
||||
},
|
||||
{
|
||||
errorContext: '[label]: {MD053}',
|
||||
errorDetail: 'Duplicate link or image reference definition: "label"',
|
||||
errorRange: [
|
||||
1,
|
||||
16,
|
||||
],
|
||||
fixInfo: {
|
||||
deleteCount: -1,
|
||||
},
|
||||
lineNumber: 126,
|
||||
ruleDescription: 'Link and image reference definitions should be needed',
|
||||
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md053',
|
||||
ruleNames: [
|
||||
'MD053',
|
||||
'link-image-reference-definitions',
|
||||
],
|
||||
},
|
||||
{
|
||||
errorContext: '[unused]: {MD053}',
|
||||
errorDetail: 'Unused link or image reference definition: "unused"',
|
||||
errorRange: [
|
||||
1,
|
||||
17,
|
||||
],
|
||||
fixInfo: {
|
||||
deleteCount: -1,
|
||||
},
|
||||
lineNumber: 129,
|
||||
ruleDescription: 'Link and image reference definitions should be needed',
|
||||
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md053',
|
||||
ruleNames: [
|
||||
'MD053',
|
||||
'link-image-reference-definitions',
|
||||
],
|
||||
},
|
||||
{
|
||||
errorContext: '[^3]: {MD053}',
|
||||
errorDetail: 'Unused link or image reference definition: "^3"',
|
||||
errorRange: [
|
||||
1,
|
||||
13,
|
||||
],
|
||||
fixInfo: {
|
||||
deleteCount: -1,
|
||||
},
|
||||
lineNumber: 132,
|
||||
ruleDescription: 'Link and image reference definitions should be needed',
|
||||
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md053',
|
||||
ruleNames: [
|
||||
'MD053',
|
||||
'link-image-reference-definitions',
|
||||
],
|
||||
},
|
||||
{
|
||||
errorContext: '[Duplicate unused multi-line l...',
|
||||
errorDetail: 'Unused link or image reference definition: "duplicate unused multi-line label {md053}"',
|
||||
errorRange: [
|
||||
1,
|
||||
44,
|
||||
],
|
||||
fixInfo: null,
|
||||
lineNumber: 134,
|
||||
ruleDescription: 'Link and image reference definitions should be needed',
|
||||
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md053',
|
||||
ruleNames: [
|
||||
'MD053',
|
||||
'link-image-reference-definitions',
|
||||
],
|
||||
},
|
||||
{
|
||||
errorContext: '[Duplicate unused multi-line l...',
|
||||
errorDetail: 'Duplicate link or image reference definition: "duplicate unused multi-line label {md053}"',
|
||||
errorRange: [
|
||||
1,
|
||||
44,
|
||||
],
|
||||
fixInfo: null,
|
||||
lineNumber: 137,
|
||||
ruleDescription: 'Link and image reference definitions should be needed',
|
||||
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md053',
|
||||
ruleNames: [
|
||||
'MD053',
|
||||
'link-image-reference-definitions',
|
||||
],
|
||||
},
|
||||
],
|
||||
fixed: `# Reference Links and Images␊
|
||||
␊
|
||||
## 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 spaces: [text][label with spaces] [text][ label with spaces ]␊
|
||||
␊
|
||||
With nested brackets: [t[ex]t][label]␊
|
||||
␊
|
||||
With inline content: [*text*][label]␊
|
||||
␊
|
||||
With inline code span: [\`code\`][label]␊
|
||||
␊
|
||||
Shortcut inline code span: [\`code\`]␊
|
||||
␊
|
||||
Multi-line full text: [multi␊
|
||||
line][multi line full text]␊
|
||||
␊
|
||||
Multi-line full label: [text][multi␊
|
||||
line full label]␊
|
||||
␊
|
||||
Multi-line collapsed label: [multi␊
|
||||
line collapsed label][]␊
|
||||
␊
|
||||
Multi-line shortcut label: [multi line␊
|
||||
shortcut label]␊
|
||||
␊
|
||||
Dedicated line:␊
|
||||
[text][label]␊
|
||||
␊
|
||||
Dedicated line with trailing colon:␊
|
||||
[text][label]:␊
|
||||
␊
|
||||
Shortcut ending in colon: [colon]:␊
|
||||
␊
|
||||
Use of multi-line label: [multi-line-label][]␊
|
||||
␊
|
||||
Standard link: [text](https://example.com/standard)␊
|
||||
␊
|
||||
## Invalid Links␊
|
||||
␊
|
||||
Missing label: [text][missing] {MD052}␊
|
||||
␊
|
||||
Mixed valid/invalid: [text][label] [text][missing] {MD052}␊
|
||||
␊
|
||||
Missing multi-line label {MD052}: [text][missing␊
|
||||
label]␊
|
||||
␊
|
||||
## Non-Links␊
|
||||
␊
|
||||
Space: [text] [wrong]␊
|
||||
␊
|
||||
Empty: [text][ ]␊
|
||||
␊
|
||||
Code span: \`[text][wrong]\`␊
|
||||
␊
|
||||
Escaped left text: \\[text][wrong]␊
|
||||
␊
|
||||
Escaped right text: [text\\][wrong]␊
|
||||
␊
|
||||
Escaped left label: [text]\\[wrong]␊
|
||||
␊
|
||||
Escaped right label: [text][wrong\\]␊
|
||||
␊
|
||||
## Valid Images␊
|
||||
␊
|
||||
Full style: ![text][image]␊
|
||||
␊
|
||||
Collapsed style: ![image][]␊
|
||||
␊
|
||||
Shortcut style: ![image]␊
|
||||
␊
|
||||
Image in link: [![text][image]][label] [![image][]][label] [![image]][label]␊
|
||||
␊
|
||||
## Invalid Images␊
|
||||
␊
|
||||
Image only: ![text][missing] {MD052}␊
|
||||
␊
|
||||
Image in link: [![text][missing]][label] {MD052}␊
|
||||
␊
|
||||
## Non-Images␊
|
||||
␊
|
||||
Escaped left text: !\\[text][wrong]␊
|
||||
␊
|
||||
Escaped right text: ![text\\][wrong]␊
|
||||
␊
|
||||
Escaped left label: ![text]\\[wrong]␊
|
||||
␊
|
||||
Escaped right label: ![text][wrong\\]␊
|
||||
␊
|
||||
## Valid Footnotes␊
|
||||
␊
|
||||
Footnote[^1]␊
|
||||
␊
|
||||
## Invalid Footnotes␊
|
||||
␊
|
||||
Missing[^2]␊
|
||||
␊
|
||||
## Valid Labels␊
|
||||
␊
|
||||
[label]: https://example.com/label␊
|
||||
[ label with spaces ]: https://example.com/label-with-spaces␊
|
||||
[image]:https://example.com/image␊
|
||||
[\`code\`]: https://example.com/code␊
|
||||
[^1]: https://example.com/footnote␊
|
||||
[multi line full text]: https://example.com/multi-line-full-text␊
|
||||
[multi line full label]: https://example.com/multi-line-full-label␊
|
||||
[multi line collapsed label]: https://example.com/multi-line-collapsed-label␊
|
||||
[multi line shortcut label]: https://example.com/multi-line-shortcut-label␊
|
||||
[colon]: https://example.com/colon␊
|
||||
[multi-line-label]:␊
|
||||
https://example.com/multi-line-label␊
|
||||
␊
|
||||
## Invalid Labels␊
|
||||
␊
|
||||
Duplicate:␊
|
||||
␊
|
||||
Unused:␊
|
||||
␊
|
||||
Unused footnote:␊
|
||||
␊
|
||||
[Duplicate unused multi-line label {MD053}]:␊
|
||||
https://example.com/duplicate-unused-multi-line-label␊
|
||||
␊
|
||||
[Duplicate unused multi-line label {MD053}]:␊
|
||||
https://example.com/duplicate-unused-multi-line-label␊
|
||||
␊
|
||||
\\[Escaped left]: text␊
|
||||
␊
|
||||
[Escaped right\\]: text␊
|
||||
␊
|
||||
## Valid Links and Images after Labels␊
|
||||
␊
|
||||
Link and image: [text][label] [![text][image]][label]␊
|
||||
␊
|
||||
## More Invalid Links and Images after Labels␊
|
||||
␊
|
||||
Bad link with image [![text][image]][missing] {MD052}␊
|
||||
␊
|
||||
## Shortcut One-Way Handling␊
|
||||
␊
|
||||
Validates the label: [shortcut]␊
|
||||
␊
|
||||
[shortcut]: https://example.com/shortcut␊
|
||||
␊
|
||||
Not flagged due to ambiguity: [ignored]␊
|
||||
␊
|
||||
## Open Bracket Pairs␊
|
||||
␊
|
||||
Unmatched [ in text␊
|
||||
␊
|
||||
Hidden reference: [hidden][] {MD052}␊
|
||||
`,
|
||||
}
|
||||
|
||||
## required-headings-all-optional-at-least-one.md
|
||||
|
||||
> Snapshot 1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue