HTML writer: fix implicit_figure at end of footnotes.

Closes #7006.
This commit is contained in:
John MacFarlane 2021-01-05 12:07:02 -08:00
parent 385b6a3b21
commit 15ba184e6e
2 changed files with 27 additions and 3 deletions

View file

@ -1455,11 +1455,15 @@ blockListToNote opts ref blocks = do
else let lastBlock = last blocks else let lastBlock = last blocks
otherBlocks = init blocks otherBlocks = init blocks
in case lastBlock of in case lastBlock of
(Para lst) -> otherBlocks ++ Para [Image _ _ (_,tit)]
| "fig:" `T.isPrefixOf` tit
-> otherBlocks ++ [lastBlock,
Plain backlink]
Para lst -> otherBlocks ++
[Para (lst ++ backlink)] [Para (lst ++ backlink)]
(Plain lst) -> otherBlocks ++ Plain lst -> otherBlocks ++
[Plain (lst ++ backlink)] [Plain (lst ++ backlink)]
_ -> otherBlocks ++ [lastBlock, _ -> otherBlocks ++ [lastBlock,
Plain backlink] Plain backlink]
contents <- blockListToHtml opts blocks' contents <- blockListToHtml opts blocks'
let noteItem = H.li ! prefixedId opts ("fn" <> ref) $ contents let noteItem = H.li ! prefixedId opts ("fn" <> ref) $ contents

20
test/command/7006.md Normal file
View file

@ -0,0 +1,20 @@
```
% pandoc -t html
Test.[^fn]
[^fn]: Foo:
![Caption.](/image.jpg)
^D
<p>Test.<a href="#fn1" class="footnote-ref" id="fnref1" role="doc-noteref"><sup>1</sup></a></p>
<section class="footnotes" role="doc-endnotes">
<hr />
<ol>
<li id="fn1" role="doc-endnote"><p>Foo:</p>
<figure>
<img src="/image.jpg" alt="Caption." /><figcaption aria-hidden="true">Caption.</figcaption>
</figure>
<a href="#fnref1" class="footnote-back" role="doc-backlink">↩︎</a></li>
</ol>
</section>
```