mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2026-01-27 09:26:09 +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
|
|
@ -95,4 +95,7 @@ Strong **with** different style {MD050}
|
|||
|
||||
[Missing link fragment](#missing) {MD051}
|
||||
|
||||
[Missing link][label] {MD052}
|
||||
[unused]: link-destination {MD053}
|
||||
|
||||
EOF {MD047}
|
||||
|
|
@ -24,7 +24,7 @@ This long line includes a simple [reference][label] link and is long enough to v
|
|||
|
||||
[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}"
|
||||
|
||||
|
|
|
|||
|
|
@ -125,12 +125,16 @@ function excludeGlobs(rootDir, ...globs) {
|
|||
}
|
||||
|
||||
// Run markdownlint the same way the corresponding repositories do
|
||||
/* eslint-disable max-len */
|
||||
|
||||
test("https://github.com/eslint/eslint", (t) => {
|
||||
const rootDir = "./test-repos/eslint-eslint";
|
||||
const globPatterns = [ join(rootDir, "docs/**/*.md") ];
|
||||
const configPath = join(rootDir, ".markdownlint.yml");
|
||||
const ignoreRes = [ /^[^:]+: \d+: MD051\/.*$\r?\n?/gm ];
|
||||
const ignoreRes = [
|
||||
/^[^:]+: \d+: MD051\/.*$\r?\n?/gm,
|
||||
/^test-repos\/eslint-eslint\/docs\/src\/developer-guide\/nodejs-api\.md: \d+: MD053\/.*$\r?\n?/gm
|
||||
];
|
||||
return lintTestRepo(t, globPatterns, configPath, ignoreRes);
|
||||
});
|
||||
|
||||
|
|
@ -148,7 +152,19 @@ test("https://github.com/mkdocs/mkdocs", (t) => {
|
|||
)
|
||||
];
|
||||
const configPath = join(rootDir, ".markdownlintrc");
|
||||
const ignoreRes = [ /^[^:]+: \d+: MD051\/.*$\r?\n?/gm ];
|
||||
const ignoreRes = [
|
||||
/^[^:]+: \d+: MD051\/.*$\r?\n?/gm,
|
||||
/^test-repos\/mkdocs-mkdocs\/docs\/about\/release-notes\.md: \d+: MD053\/.*$\r?\n?/gm,
|
||||
/^test-repos\/mkdocs-mkdocs\/docs\/dev-guide\/plugins\.md: \d+: MD053\/.*$\r?\n?/gm,
|
||||
/^test-repos\/mkdocs-mkdocs\/docs\/dev-guide\/themes\.md: \d+: MD053\/.*$\r?\n?/gm,
|
||||
/^test-repos\/mkdocs-mkdocs\/docs\/dev-guide\/translations\.md: \d+: MD053\/.*$\r?\n?/gm,
|
||||
/^test-repos\/mkdocs-mkdocs\/docs\/getting-started\.md: \d+: MD053\/.*$\r?\n?/gm,
|
||||
/^test-repos\/mkdocs-mkdocs\/docs\/user-guide\/configuration\.md: \d+: MD053\/.*$\r?\n?/gm,
|
||||
/^test-repos\/mkdocs-mkdocs\/docs\/user-guide\/customizing-your-theme\.md: \d+: MD053\/.*$\r?\n?/gm,
|
||||
/^test-repos\/mkdocs-mkdocs\/docs\/user-guide\/deploying-your-docs\.md: \d+: MD053\/.*$\r?\n?/gm,
|
||||
/^test-repos\/mkdocs-mkdocs\/docs\/user-guide\/installation\.md: \d+: MD053\/.*$\r?\n?/gm,
|
||||
/^test-repos\/mkdocs-mkdocs\/docs\/user-guide\/writing-your-docs\.md: \d+: MD053\/.*$\r?\n?/gm
|
||||
];
|
||||
return lintTestRepo(t, globPatterns, configPath, ignoreRes);
|
||||
});
|
||||
|
||||
|
|
@ -163,7 +179,10 @@ test("https://github.com/mochajs/mocha", (t) => {
|
|||
join(rootDir, "example/**/*.md")
|
||||
];
|
||||
const configPath = join(rootDir, ".markdownlint.json");
|
||||
const ignoreRes = [ /^[^:]+: \d+: MD051\/.*$\r?\n?/gm ];
|
||||
const ignoreRes = [
|
||||
/^[^:]+: \d+: MD051\/.*$\r?\n?/gm,
|
||||
/^test-repos\/mochajs-mocha\/docs\/index\.md: \d+: MD053\/.*$\r?\n?/gm
|
||||
];
|
||||
return lintTestRepo(t, globPatterns, configPath, ignoreRes);
|
||||
});
|
||||
|
||||
|
|
@ -171,7 +190,10 @@ test("https://github.com/pi-hole/docs", (t) => {
|
|||
const rootDir = "./test-repos/pi-hole-docs";
|
||||
const globPatterns = [ join(rootDir, "**/*.md") ];
|
||||
const configPath = join(rootDir, ".markdownlint.json");
|
||||
const ignoreRes = [ /^[^:]+: \d+: MD051\/.*$\r?\n?/gm ];
|
||||
const ignoreRes = [
|
||||
/^[^:]+: \d+: MD051\/.*$\r?\n?/gm,
|
||||
/^test-repos\/pi-hole-docs\/docs\/guides\/dns\/cloudflared\.md: \d+: MD053\/.*$\r?\n?/gm
|
||||
];
|
||||
return lintTestRepo(t, globPatterns, configPath, ignoreRes);
|
||||
});
|
||||
|
||||
|
|
@ -182,14 +204,38 @@ test("https://github.com/webhintio/hint", (t) => {
|
|||
...excludeGlobs(rootDir, "**/CHANGELOG.md")
|
||||
];
|
||||
const configPath = join(rootDir, ".markdownlintrc");
|
||||
return lintTestRepo(t, globPatterns, configPath);
|
||||
const ignoreRes = [
|
||||
/test-repos\/webhintio-hint\/packages\/hint-apple-touch-icons\/README\.md: \d+: MD053\/.*$\r?\n?/gm,
|
||||
/test-repos\/webhintio-hint\/packages\/hint-axe\/README\.md: \d+: MD053\/.*$\r?\n?/gm,
|
||||
/test-repos\/webhintio-hint\/packages\/hint-compat-api\/README\.md: \d+: MD053\/.*$\r?\n?/gm,
|
||||
/test-repos\/webhintio-hint\/packages\/hint-compat-api\/docs\/html\.md: \d+: MD053\/.*$\r?\n?/gm,
|
||||
/test-repos\/webhintio-hint\/packages\/hint-doctype\/README\.md: \d+: MD053\/.*$\r?\n?/gm,
|
||||
/test-repos\/webhintio-hint\/packages\/hint-highest-available-document-mode\/README\.md: \d+: MD053\/.*$\r?\n?/gm,
|
||||
/test-repos\/webhintio-hint\/packages\/hint-http-compression\/README\.md: \d+: MD053\/.*$\r?\n?/gm,
|
||||
/test-repos\/webhintio-hint\/packages\/hint-meta-viewport\/README\.md: \d+: MD053\/.*$\r?\n?/gm,
|
||||
/test-repos\/webhintio-hint\/packages\/hint-minified-js\/README\.md: \d+: MD053\/.*$\r?\n?/gm,
|
||||
/test-repos\/webhintio-hint\/packages\/hint-no-p3p\/README\.md: \d+: MD053\/.*$\r?\n?/gm,
|
||||
/test-repos\/webhintio-hint\/packages\/hint-performance-budget\/README\.md: \d+: MD053\/.*$\r?\n?/gm,
|
||||
/test-repos\/webhintio-hint\/packages\/hint-strict-transport-security\/README\.md: \d+: MD053\/.*$\r?\n?/gm,
|
||||
/test-repos\/webhintio-hint\/packages\/hint-x-content-type-options\/README\.md: \d+: MD053\/.*$\r?\n?/gm,
|
||||
/test-repos\/webhintio-hint\/packages\/hint\/docs\/about\/GOVERNANCE.md: \d+: MD053\/.*$\r?\n?/gm,
|
||||
/test-repos\/webhintio-hint\/packages\/hint\/docs\/contributor-guide\/getting-started\/architecture\.md: \d+: MD053\/.*$\r?\n?/gm,
|
||||
/test-repos\/webhintio-hint\/packages\/hint\/docs\/contributor-guide\/getting-started\/development-environment\.md: \d+: MD053\/.*$\r?\n?/gm,
|
||||
/test-repos\/webhintio-hint\/packages\/hint\/docs\/contributor-guide\/how-to\/hint\.md: \d+: MD053\/.*$\r?\n?/gm,
|
||||
/test-repos\/webhintio-hint\/packages\/hint\/docs\/user-guide\/development-flow-integration\/local-server\.md: \d+: MD053\/.*$\r?\n?/gm,
|
||||
/test-repos\/webhintio-hint\/packages\/hint\/docs\/user-guide\/index\.md: \d+: MD053\/.*$\r?\n?/gm,
|
||||
/test-repos\/webhintio-hint\/packages\/hint\/docs\/user-guide\/troubleshoot\/summary\.md: \d+: MD053\/.*$\r?\n?/gm,
|
||||
/test-repos\/webhintio-hint\/packages\/parser-html\/README\.md: \d+: MD053\/.*$\r?\n?/gm
|
||||
];
|
||||
return lintTestRepo(t, globPatterns, configPath, ignoreRes);
|
||||
});
|
||||
|
||||
test("https://github.com/webpack/webpack.js.org", (t) => {
|
||||
const rootDir = "./test-repos/webpack-webpack-js-org";
|
||||
const globPatterns = [ join(rootDir, "**/*.md") ];
|
||||
const configPath = join(rootDir, ".markdownlint.json");
|
||||
return lintTestRepo(t, globPatterns, configPath);
|
||||
const ignoreRes = [ /^test-repos\/webpack-webpack-js-org\/README\.md: \d+: MD053\/.*$\r?\n?/gm ];
|
||||
return lintTestRepo(t, globPatterns, configPath, ignoreRes);
|
||||
});
|
||||
|
||||
// Optional repositories (very large)
|
||||
|
|
@ -200,7 +246,19 @@ if (existsSync(dotnetDocsDir)) {
|
|||
const rootDir = dotnetDocsDir;
|
||||
const globPatterns = [ join(rootDir, "**/*.md") ];
|
||||
const configPath = join(rootDir, ".markdownlint.json");
|
||||
const ignoreRes = [ /^[^:]+: \d+: MD051\/.*$\r?\n?/gm ];
|
||||
const ignoreRes = [
|
||||
/^[^:]+: \d+: MD051\/.*$\r?\n?/gm,
|
||||
/^test-repos\/dotnet-docs\/docs\/core\/diagnostics\/sos-debugging-extension\.md: \d+: MD052\/.*$\r?\n?/gm,
|
||||
/^test-repos\/dotnet-docs\/docs\/core\/install\/macos\.md: \d+: MD053\/.*$\r?\n?/gm,
|
||||
/^test-repos\/dotnet-docs\/docs\/framework\/data\/adonet\/dataset-datatable-dataview\/diffgrams\.md: \d+: MD052\/.*$\r?\n?/gm,
|
||||
/^test-repos\/dotnet-docs\/docs\/framework\/tools\/al-exe-assembly-linker\.md: \d+: MD052\/.*$\r?\n?/gm,
|
||||
/^test-repos\/dotnet-docs\/docs\/framework\/tools\/sos-dll-sos-debugging-extension\.md: \d+: MD052\/.*$\r?\n?/gm,
|
||||
/^test-repos\/dotnet-docs\/docs\/fsharp\/language-reference\/compiler-options\.md: \d+: MD052\/.*$\r?\n?/gm,
|
||||
/^test-repos\/dotnet-docs\/docs\/fundamentals\/code-analysis\/quality-rules\/ca2241\.md: \d+: MD052\/.*$\r?\n?/gm,
|
||||
/^test-repos\/dotnet-docs\/docs\/standard\/base-types\/composite-formatting\.md: \d+: MD052\/.*$\r?\n?/gm,
|
||||
/^test-repos\/dotnet-docs\/docs\/standard\/base-types\/standard-timespan-format-strings\.md: \d+: MD052\/.*$\r?\n?/gm,
|
||||
/^test-repos\/dotnet-docs\/docs\/standard\/native-interop\/tutorial-comwrappers\.md: \d+: MD053\/.*$\r?\n?/gm
|
||||
];
|
||||
return lintTestRepo(t, globPatterns, configPath, ignoreRes);
|
||||
});
|
||||
}
|
||||
|
|
@ -211,7 +269,10 @@ if (existsSync(v8v8DevDir)) {
|
|||
const rootDir = v8v8DevDir;
|
||||
const globPatterns = [ join(rootDir, "src/**/*.md") ];
|
||||
const configPath = join(rootDir, ".markdownlint.json");
|
||||
const ignoreRes = [ /^[^:]+: \d+: (MD049|MD051)\/.*$\r?\n?/gm ];
|
||||
const ignoreRes = [
|
||||
/^[^:]+: \d+: (MD049|MD051)\/.*$\r?\n?/gm,
|
||||
/^test-repos\/v8-v8-dev\/src\/blog\/oilpan-library\.md: \d+: MD053\/.*$\r?\n?/gm
|
||||
];
|
||||
return lintTestRepo(t, globPatterns, configPath, ignoreRes);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -488,11 +488,13 @@ test.cb("styleAll", (t) => {
|
|||
"MD042": [ 81 ],
|
||||
"MD045": [ 85 ],
|
||||
"MD046": [ 49, 73, 77 ],
|
||||
"MD047": [ 98 ],
|
||||
"MD047": [ 101 ],
|
||||
"MD048": [ 77 ],
|
||||
"MD049": [ 90 ],
|
||||
"MD050": [ 94 ],
|
||||
"MD051": [ 96 ]
|
||||
"MD051": [ 96 ],
|
||||
"MD052": [ 98 ],
|
||||
"MD053": [ 99 ]
|
||||
}
|
||||
};
|
||||
// @ts-ignore
|
||||
|
|
@ -534,11 +536,13 @@ test.cb("styleRelaxed", (t) => {
|
|||
"MD042": [ 81 ],
|
||||
"MD045": [ 85 ],
|
||||
"MD046": [ 49, 73, 77 ],
|
||||
"MD047": [ 98 ],
|
||||
"MD047": [ 101 ],
|
||||
"MD048": [ 77 ],
|
||||
"MD049": [ 90 ],
|
||||
"MD050": [ 94 ],
|
||||
"MD051": [ 96 ]
|
||||
"MD051": [ 96 ],
|
||||
"MD052": [ 98 ],
|
||||
"MD053": [ 99 ]
|
||||
}
|
||||
};
|
||||
// @ts-ignore
|
||||
|
|
@ -840,7 +844,7 @@ test.cb("customFileSystemAsync", (t) => {
|
|||
});
|
||||
|
||||
test.cb("readme", (t) => {
|
||||
t.plan(121);
|
||||
t.plan(125);
|
||||
const tagToRules = {};
|
||||
rules.forEach(function forRule(rule) {
|
||||
rule.tags.forEach(function forTag(tag) {
|
||||
|
|
@ -916,7 +920,7 @@ test.cb("readme", (t) => {
|
|||
});
|
||||
|
||||
test.cb("rules", (t) => {
|
||||
t.plan(359);
|
||||
t.plan(373);
|
||||
fs.readFile("doc/Rules.md", "utf8",
|
||||
(err, contents) => {
|
||||
t.falsy(err);
|
||||
|
|
@ -1093,7 +1097,7 @@ test("validateConfigExampleJson", async(t) => {
|
|||
});
|
||||
|
||||
test("allBuiltInRulesHaveValidUrl", (t) => {
|
||||
t.plan(141);
|
||||
t.plan(147);
|
||||
rules.forEach(function forRule(rule) {
|
||||
t.truthy(rule.information);
|
||||
t.true(Object.getPrototypeOf(rule.information) === URL.prototype);
|
||||
|
|
|
|||
164
test/reference-links-and-images.md
Normal file
164
test/reference-links-and-images.md
Normal file
|
|
@ -0,0 +1,164 @@
|
|||
# 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:
|
||||
[label]: {MD053}
|
||||
|
||||
Unused:
|
||||
[unused]: {MD053}
|
||||
|
||||
Unused footnote:
|
||||
[^3]: {MD053}
|
||||
|
||||
[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}
|
||||
|
|
@ -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
|
||||
|
|
|
|||
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue