Skip to content

Commit

Permalink
Fix crash on nested footnotes
Browse files Browse the repository at this point in the history
  • Loading branch information
rlidwka committed May 20, 2021
1 parent cab6665 commit 82d559e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,9 @@
3.0.3 / WIP
------------------

- Fix crash on nested footnotes, #42.


3.0.2 / 2019-07-09
------------------

Expand Down
2 changes: 1 addition & 1 deletion index.js
Expand Up @@ -334,7 +334,7 @@ module.exports = function footnote_plugin(md) {
tokens = refTokens[':' + list[i].label];
}

state.tokens = state.tokens.concat(tokens);
if (tokens) state.tokens = state.tokens.concat(tokens);
if (state.tokens[state.tokens.length - 1].type === 'paragraph_close') {
lastParagraph = state.tokens.pop();
} else {
Expand Down
18 changes: 18 additions & 0 deletions test/fixtures/footnote.txt
Expand Up @@ -264,3 +264,21 @@ Example^[this is another example https://github.com]
</ol>
</section>
.


Regression test for #42
.
foo[^1] bar[^2].

[^1]:[^2]: baz
.
<p>foo<sup class="footnote-ref"><a href="#fn1" id="fnref1">[1]</a></sup> bar<sup class="footnote-ref"><a href="#fn2" id="fnref2">[2]</a></sup>.</p>
<hr class="footnotes-sep">
<section class="footnotes">
<ol class="footnotes-list">
<li id="fn1" class="footnote-item"> <a href="#fnref1" class="footnote-backref">↩︎</a></li>
<li id="fn2" class="footnote-item"><p>baz <a href="#fnref2" class="footnote-backref">↩︎</a></p>
</li>
</ol>
</section>
.

0 comments on commit 82d559e

Please sign in to comment.