Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion markdown/extensions/footnotes.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,9 @@ def run(self, text):
text = text.replace(
FN_BACKLINK_TEXT, self.footnotes.getConfig("BACKLINK_TEXT")
)
return text.replace(NBSP_PLACEHOLDER, " ")
result = text.replace(NBSP_PLACEHOLDER, " ")
self.footnotes.reset()
return result


def makeExtension(*args, **kwargs):
Expand Down
37 changes: 37 additions & 0 deletions tests/test_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -858,3 +858,40 @@ def testCustomSubstitutions(self):
is the ‚mdash‘: \u2014
Must not be confused with &sbquo;ndash&lsquo; (\u2013) \u2026 ]</p>"""
self.assertEqual(self.md.convert(text), correct)


class TestFootnotes(unittest.TestCase):
""" Test Footnotes extension. """

def setUp(self):
self.md = markdown.Markdown(extensions=['markdown.extensions.footnotes'])

def testSimpleFootnotes(self):
""" Test Footnotes. """
text = "Foo[^1] Bar\n[^1]: Baz"
self.assertEqual(
self.md.convert(text),
'<p>Foo<sup id="fnref:1"><a class="footnote-ref" href="#fn:1" rel="footnote">1</a></sup> Bar</p>\n'
'<div class="footnote">\n'
'<hr />\n'
'<ol>\n'
'<li id="fn:1">\n'
'<p>Baz&#160;'
'<a class="footnote-backref" href="#fnref:1" rev="footnote" title="Jump back to footnote 1 in the text">'
'&#8617;'
'</a>'
'</p>\n'
'</li>\n'
'</ol>\n'
'</div>'
)

def testFootnotesReset(self):
""" Test whether FootnotesExtension got reset properly """
text1 = "Foo[^1] Bar\n[^1]: Baz"
text2 = "Foo"
self.md.convert(text1)
self.assertEqual(
self.md.convert(text2),
'<p>Foo</p>'
)