Update MD053/link-image-reference-definitions to handle references within references (i.e., Pandoc-style footnotes), verify Pandoc footnote indent is not treated as comment when markdown-it-footnote plugin is used (fixes #599).

This commit is contained in:
David Anson 2022-10-19 21:12:51 -07:00
parent 7d1fa55cc4
commit 592a42b0cb
8 changed files with 169 additions and 2 deletions

View file

@ -32084,6 +32084,80 @@ Generated by [AVA](https://avajs.dev).
`,
}
## pandoc-footnotes.md
> 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/Rules.md#md053',
ruleNames: [
'MD053',
'link-image-reference-definitions',
],
},
],
fixed: `# Pandoc Footnotes␊
> Examples taken from [GitHub issue 599](https://github.com/DavidAnson/markdownlint/issues/599)␊
## Example with Pandoc Footnotes␊
A sentence with footnotes: [^1] [^2]␊
A sentence with named footnotes: [^name] [^name2]␊
A sentence with a link reference: [Pandoc's User Guide][Pandoc1]␊
[^1]: I am a footnote!␊
[^2]: I reference a [PCW][PCW1] article!␊
[^name]: I am a footnote with name!␊
[^name2]: I am also a named footnote! I also reference the [PCW][PCW1] article!␊
[PCW1]: https://www.example.com/article.html␊
[Pandoc1]: https://pandoc.org/MANUAL.html#extension-footnotes␊
## Example with Long Pandoc Footnotes␊
A sentence with a long footnotes: [^long] [^longer] [^longest]␊
[^long]: I am a long footnote!␊
I don't do any harm :)␊
[^longer]: I am a longer footnote. I do reference the [PCW][PCW2] article.␊
I do harm. Though, not here: [Pandoc's User Guide][Pandoc2]␊
[^longest]: I am the longest footnote. I also reference the [PCW][PCW2] article.␊
I am a harmful new block of text: [Another][Another2]␊
> The previous line of text is treated by CommonMark as an indented code block.␊
> To handle it as a Pandoc footnote, consider the \`markdown-it-footnote\` plugin.␊
[PCW2]: https://www.example.com/article.html␊
[Pandoc2]: https://pandoc.org/MANUAL.html#extension-footnotes␊
## GitHub Footnotes␊
Sample footnotes [^3] [^note3]␊
[^3]: A line␊
A new line␊
[^note3]:␊
I am a new block of text␊
With a new line as well␊
`,
}
## proper-names-alternate.md
> Snapshot 1
@ -34592,6 +34666,14 @@ Generated by [AVA](https://avajs.dev).
Unmatched [ in text␊
Hidden reference: [hidden][] {MD052}␊
## Link references inside reference definitions␊
Text with a [^footnote] in it␊
[^footnote]: Footnote with an [embedded-reference][] in it␊
[embedded-reference]: https://example.com/embedded-reference␊
`,
}