Skip to content
Merged
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
2 changes: 1 addition & 1 deletion src/mistune/plugins/footnotes.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def md_footnotes_hook(
return result

children = [parse_footnote_item(md.block, k, i + 1, state) for i, k in enumerate(notes)]
state = BlockState()
state = BlockState(parent=state)
state.tokens = [{"type": "footnotes", "children": children}]
output = md.render_state(state)
return result + output # type: ignore[operator]
Expand Down
34 changes: 34 additions & 0 deletions tests/fixtures/footnotes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,37 @@ third
</ol>
</section>
````````````````````````````````

```````````````````````````````` example
This is a foo [^foo].

This is a bar [^bar].

[^foo]: A foo is beautiful. This is in contrast to a bar [^bar].

[^bar]: A bar is very common.
.
<p>This is a foo <sup class="footnote-ref" id="fnref-1"><a href="#fn-1">1</a></sup>.</p>
<p>This is a bar <sup class="footnote-ref" id="fnref-2"><a href="#fn-2">2</a></sup>.</p>
<section class="footnotes">
<ol>
<li id="fn-1"><p>A foo is beautiful. This is in contrast to a bar <sup class="footnote-ref" id="fnref-2"><a href="#fn-2">2</a></sup>.<a href="#fnref-1" class="footnote">&#8617;</a></p></li>
<li id="fn-2"><p>A bar is very common.<a href="#fnref-2" class="footnote">&#8617;</a></p></li>
</ol>
</section>
````````````````````````````````

```````````````````````````````` example
This is body text, and a footnote.[^f]

[^f]: The footnote includes [a link][1].

[1]: https://example.com
.
<p>This is body text, and a footnote.<sup class="footnote-ref" id="fnref-1"><a href="#fn-1">1</a></sup></p>
<section class="footnotes">
<ol>
<li id="fn-1"><p>The footnote includes <a href="https://example.com">a link</a>.<a href="#fnref-1" class="footnote">&#8617;</a></p></li>
</ol>
</section>
````````````````````````````````