question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

MD053 false-positive thrown over Pandoc/GitHub footnotes

See original GitHub issue

Rule MD053 is incorrectly thrown after referencing a link definition over a Pandoc/Github footnote (see Pandoc’s User Guide for syntax) (and GitHub’s).

However, the rule isn’t thrown on (indented) lines directly after, i.e. on long footnotes. Though, for Pandoc to render a new line on a (long) footnote, a blank line has to be entered within two blocks of text; and creating a new (indented) block that references a link does throw the same rule violation; likely because it’s considered by Markdownlint as a code block.

As I’m not gonna bother checking the code: From what I can infer, Markdownlint checks if a link is used based on the first character(s) of a line, such as to check if a line represents a code block, and that’s why link references aren’t checked/found on footnotes.

Reproduction

$ markdownlint -V
0.32.2

0.32.2 is the latest version for CLI, which uses the latest version of the API (i.e. 0.26.2) using the following Markdown file:

<!-- pandoc.md -->

# 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][Pandoc]

[^1]: I am a footnote!
[^2]: I reference a [PCWorld][PCW] article!
[^name]: I am a footnote with name!
[^name2]: I am also a named footnote! I also reference the [PCWorld][PCW] article!

[PCW]: https://www.pcworld.com/article/395018/how-much-ram-do-you-need-in-a-laptop.html#4gb-ram
[Pandoc]: https://pandoc.org/MANUAL.html#extension-citations

the CLI outputs:

$ markdownlint pandoc.md
pandoc.md:12:1 MD053/link-image-reference-definitions Link and image reference definitions should be needed [Unused link or image reference definition: "pcw"] [Context: "[PCW]: https://www.pcworld.com..."]

as you can see, using a link reference on a sentence doesn’t throw the rule.


While not using footnotes at all, obviously doesn’t throw any error.

Just a superfluous example

With the file:

<!-- no-pandoc.md -->

# Example without Pandoc Footnotes

A sentence that references a [PCWorld][PCW] article.

[PCW]: https://www.pcworld.com/article/395018/how-much-ram-do-you-need-in-a-laptop.html#4gb-ram

the CLI doesn’t output anything (i.e. any rule violation):

$ markdownlint no-pandoc.md 

On the case of long footnotes (i.e. those that contain multiple lines/blocks of text), attempting to reference a link on a new (indented) line doesn’t throw the error. nor on further (indented) lines of text:

<!-- long.md -->

# Example with Long 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 [PCWorld][PCW] article.
    I do harm. Though, not here: [Pandoc's User Guide][Pandoc]
[^longest]: I am the longest footnote. I also reference the [PCWorld][PCW] article.

    I am a harmful new block of text: [Rule MD053][Rule]

[PCW]: https://www.pcworld.com/article/395018/how-much-ram-do-you-need-in-a-laptop.html#4gb-ram
[Pandoc]: https://pandoc.org/MANUAL.html#extension-citations
[Rule]: https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md#md053---link-and-image-reference-definitions-should-be-needed

of which CLI outputs:

$ markdownlint long.md
long.md:13:1 MD053/link-image-reference-definitions Link and image reference definitions should be needed [Unused link or image reference definition: "pcw"] [Context: "[PCW]: https://www.pcworld.com..."]
long.md:15:1 MD053/link-image-reference-definitions Link and image reference definitions should be needed [Unused link or image reference definition: "rule"] [Context: "[Rule]: https://github.com/Dav..."]

but, as you can see, the new block of text does throw the rule violation, as already explained.

Looks like this as a PDF with Pandoc

2022-10-05T22:01:46,483395811-05:00

Like said, the new block text (i.e. blank line) does print a new line on the PDF.

Have to say, a lot of reproduction; but, hope it was helpful

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
DavidAnsoncommented, Oct 6, 2022

Thank you for the exceptionally detailed issue! I don’t think I realized you could have references within definitions - and I need to understand the rules for footnotes better to see why four spaces doesn’t make a code block in your example.

0reactions
LeCodingWolfiecommented, Oct 6, 2022

By the way, it’s good remarking that this is not only behavior from Pandoc, but GitHub does something similar, but not exactly the same, i.e. you can create a new line two ways, either by indenting the new line with two spaces:

[^1]: A line
  A new line

or just creating a block of text with a 4-space indent:

[^note]:
    I am a new block of text
    With a new line as well

which I think is weirder, at least compared to Pandoc.

And, using code blocks on footnotes? They don’t work on GitHub, but they should theoretically work if GitHub applied the “alignment rule” on footnotes. [^1] [^2]

Here's how I tried to indent code blocks on the footnotes, by the way:
[^1]: I am a footnote with 2-space indent rule
  Here a new line
      Am I a code block?

[^2]: 
    I am another footnote, but with 4-space alignment
        Am I also a code block?

[^1]: I am a footnote with 2-space indent rule Here a new line Am I a code block?

[^2]: I am another footnote, but with 4-space alignment Am I also a code block?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Bug; footnotes produce wrong markdown syntax? · Issue #6348
Problem Hey there! I'm trying to convert JATS to markdown and I think Pandoc is producing incorrect markdown sytnax.
Read more >
The Org Manual
Org files can serve as a single source authoring system with export to many different formats such as HTML, LaTeX, Open Document, and...
Read more >
huxtable.pdf
BugReports https://github.com/hughjonesd/huxtable/issues ... The first cell contains the footnote; it spans all table columns ... add_rownames is FALSE.
Read more >
nbconvert Documentation
1.3 Installing Pandoc. For converting markdown to formats other than HTML, nbconvert uses Pandoc (1.12.1 or later). To install pandoc on ...
Read more >
R News - Microsoft R Application Network
By default, keep.parse.data.pkgs is now FALSE , which changes previous behavior and ... All packages are by default byte-compiled on installation.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found