Skip to content

Don't add an empty footnotes block when no footnote is referenced - #758

Open
RavSinghChandan wants to merge 2 commits into
trentm:masterfrom
RavSinghChandan:footnotes-without-references
Open

RavSinghChandan wants to merge 2 commits into
trentm:masterfrom
RavSinghChandan:footnotes-without-references

Conversation

@RavSinghChandan

Copy link
Copy Markdown

With the footnotes extra, a footnote that is defined but never referenced still makes markdown2 append the footnotes block, with an empty list:

>>> markdown2.markdown("Text.\n\n[^1]: A note.\n", extras=["footnotes"])
'<p>Text.</p>\n\n<div class="footnotes">\n<hr />\n<ol>\n</ol>\n</div>\n'

_add_footnotes checks self.footnotes (the definitions) but only lists self.footnote_ids (the referenced ones), so the block is empty when nothing is referenced. It now checks the referenced ids, so the output is just <p>Text.</p>. Documents with referenced footnotes are unchanged, and unreferenced definitions were already left out of the list.

Added the footnotes_unreferenced test case

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant