mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-16 14:00:13 +01:00
Reimplement getReferenceLinkImageData using micromark tokens.
This commit is contained in:
parent
57c612cfa4
commit
97f99befb8
13 changed files with 1235 additions and 1068 deletions
|
|
@ -1433,9 +1433,8 @@ test("getReferenceLinkImageData().shortcuts", (t) => {
|
|||
"tags": [ "-" ],
|
||||
"function":
|
||||
(params) => {
|
||||
const lineMetadata = helpers.getLineMetadata(params);
|
||||
const { shortcuts } =
|
||||
helpers.getReferenceLinkImageData(lineMetadata);
|
||||
helpers.getReferenceLinkImageData(params);
|
||||
t.is(shortcuts.size, 0, [ ...shortcuts.keys() ].join(", "));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ const fs = require("node:fs");
|
|||
const path = require("node:path");
|
||||
const jsYaml = require("js-yaml");
|
||||
const md = require("markdown-it")();
|
||||
const pluginFootnote = require("markdown-it-footnote");
|
||||
const pluginInline = require("markdown-it-for-inline");
|
||||
const pluginSub = require("markdown-it-sub");
|
||||
const pluginSup = require("markdown-it-sup");
|
||||
|
|
@ -1154,7 +1153,7 @@ test("texmath test files with texmath plugin", (t) => new Promise((resolve) => {
|
|||
});
|
||||
}));
|
||||
|
||||
test("Pandoc footnote via footnote plugin", (t) => new Promise((resolve) => {
|
||||
test("Pandoc footnote", (t) => new Promise((resolve) => {
|
||||
t.plan(2);
|
||||
markdownlint({
|
||||
"strings": {
|
||||
|
|
@ -1170,7 +1169,6 @@ Text with: [^footnote]
|
|||
[reference]: https://example.com
|
||||
`
|
||||
},
|
||||
"markdownItPlugins": [ [ pluginFootnote ] ],
|
||||
"resultVersion": 0
|
||||
}, (err, actual) => {
|
||||
t.falsy(err);
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ A sentence with a long footnotes: [^long] [^longer] [^longest]
|
|||
|
||||
[PCW2]: https://www.example.com/article.html
|
||||
[Pandoc2]: https://pandoc.org/MANUAL.html#extension-footnotes
|
||||
[Another2]: https://www.example.com/another.{MD053}.html
|
||||
[Another2]: https://www.example.com/another.html
|
||||
|
||||
## GitHub Footnotes
|
||||
|
||||
|
|
|
|||
|
|
@ -155,7 +155,6 @@ Missing[^2]
|
|||
[image7]: https://example.com/image7
|
||||
[image8]: https://example.com/image8
|
||||
[`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
|
||||
|
|
@ -179,6 +178,7 @@ https://example.com/multi-line-label
|
|||
[unique8]: https://example.com/unique8
|
||||
[unique9]: https://example.com/unique9
|
||||
[unique10]: https://example.com/unique10
|
||||
[^1]: https://example.com/footnote
|
||||
|
||||
## Ignored Labels
|
||||
|
||||
|
|
@ -188,15 +188,16 @@ https://example.com/multi-line-label
|
|||
|
||||
## Invalid Labels
|
||||
|
||||
Duplicate:
|
||||
Duplicate/unused:
|
||||
|
||||
[label]: {MD053}
|
||||
|
||||
Unused:
|
||||
[blank-line-filler-0]: https://example.com
|
||||
[unused]: {MD053}
|
||||
|
||||
Unused footnote:
|
||||
[blank-line-filler-1]: https://example.com
|
||||
[^3]: {MD053}
|
||||
|
||||
[blank-line-filler-0][] [blank-line-filler-1][]
|
||||
|
||||
[Duplicate unused multi-line label {MD053}]:
|
||||
https://example.com/duplicate-unused-multi-line-label
|
||||
|
||||
|
|
|
|||
|
|
@ -32971,26 +32971,7 @@ Generated by [AVA](https://avajs.dev).
|
|||
> Snapshot 1
|
||||
|
||||
{
|
||||
errors: [
|
||||
{
|
||||
errorContext: '[Another2]: https://www.exampl...',
|
||||
errorDetail: 'Unused link or image reference definition: "another2"',
|
||||
errorRange: [
|
||||
1,
|
||||
56,
|
||||
],
|
||||
fixInfo: {
|
||||
deleteCount: -1,
|
||||
},
|
||||
lineNumber: 36,
|
||||
ruleDescription: 'Link and image reference definitions should be needed',
|
||||
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md053.md',
|
||||
ruleNames: [
|
||||
'MD053',
|
||||
'link-image-reference-definitions',
|
||||
],
|
||||
},
|
||||
],
|
||||
errors: [],
|
||||
fixed: `# Pandoc Footnotes␊
|
||||
␊
|
||||
> Examples taken from [GitHub issue 599](https://github.com/DavidAnson/markdownlint/issues/599)␊
|
||||
|
|
@ -33026,6 +33007,7 @@ Generated by [AVA](https://avajs.dev).
|
|||
␊
|
||||
[PCW2]: https://www.example.com/article.html␊
|
||||
[Pandoc2]: https://pandoc.org/MANUAL.html#extension-footnotes␊
|
||||
[Another2]: https://www.example.com/another.html␊
|
||||
␊
|
||||
## GitHub Footnotes␊
|
||||
␊
|
||||
|
|
@ -35306,7 +35288,7 @@ Generated by [AVA](https://avajs.dev).
|
|||
25,
|
||||
],
|
||||
fixInfo: null,
|
||||
lineNumber: 216,
|
||||
lineNumber: 217,
|
||||
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: [
|
||||
|
|
@ -35322,7 +35304,7 @@ Generated by [AVA](https://avajs.dev).
|
|||
10,
|
||||
],
|
||||
fixInfo: null,
|
||||
lineNumber: 230,
|
||||
lineNumber: 231,
|
||||
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: [
|
||||
|
|
@ -35340,7 +35322,7 @@ Generated by [AVA](https://avajs.dev).
|
|||
fixInfo: {
|
||||
deleteCount: -1,
|
||||
},
|
||||
lineNumber: 192,
|
||||
lineNumber: 193,
|
||||
ruleDescription: 'Link and image reference definitions should be needed',
|
||||
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md053.md',
|
||||
ruleNames: [
|
||||
|
|
@ -35376,7 +35358,7 @@ Generated by [AVA](https://avajs.dev).
|
|||
fixInfo: {
|
||||
deleteCount: -1,
|
||||
},
|
||||
lineNumber: 198,
|
||||
lineNumber: 197,
|
||||
ruleDescription: 'Link and image reference definitions should be needed',
|
||||
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md053.md',
|
||||
ruleNames: [
|
||||
|
|
@ -35392,7 +35374,7 @@ Generated by [AVA](https://avajs.dev).
|
|||
44,
|
||||
],
|
||||
fixInfo: null,
|
||||
lineNumber: 200,
|
||||
lineNumber: 201,
|
||||
ruleDescription: 'Link and image reference definitions should be needed',
|
||||
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md053.md',
|
||||
ruleNames: [
|
||||
|
|
@ -35408,7 +35390,7 @@ Generated by [AVA](https://avajs.dev).
|
|||
44,
|
||||
],
|
||||
fixInfo: null,
|
||||
lineNumber: 203,
|
||||
lineNumber: 204,
|
||||
ruleDescription: 'Link and image reference definitions should be needed',
|
||||
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md053.md',
|
||||
ruleNames: [
|
||||
|
|
@ -35574,7 +35556,6 @@ Generated by [AVA](https://avajs.dev).
|
|||
[image7]: https://example.com/image7␊
|
||||
[image8]: https://example.com/image8␊
|
||||
[\`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␊
|
||||
|
|
@ -35598,6 +35579,7 @@ Generated by [AVA](https://avajs.dev).
|
|||
[unique8]: https://example.com/unique8␊
|
||||
[unique9]: https://example.com/unique9␊
|
||||
[unique10]: https://example.com/unique10␊
|
||||
[^1]: https://example.com/footnote␊
|
||||
␊
|
||||
## Ignored Labels␊
|
||||
␊
|
||||
|
|
@ -35607,11 +35589,12 @@ Generated by [AVA](https://avajs.dev).
|
|||
␊
|
||||
## Invalid Labels␊
|
||||
␊
|
||||
Duplicate:␊
|
||||
Duplicate/unused:␊
|
||||
␊
|
||||
Unused:␊
|
||||
[blank-line-filler-0]: https://example.com␊
|
||||
[blank-line-filler-1]: https://example.com␊
|
||||
␊
|
||||
Unused footnote:␊
|
||||
[blank-line-filler-0][] [blank-line-filler-1][]␊
|
||||
␊
|
||||
[Duplicate unused multi-line label {MD053}]:␊
|
||||
https://example.com/duplicate-unused-multi-line-label␊
|
||||
|
|
|
|||
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue