From 15ba184e6e7825898ebae5a59e2c3a60e0992da0 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Tue, 5 Jan 2021 12:07:02 -0800 Subject: [PATCH] HTML writer: fix implicit_figure at end of footnotes. Closes #7006. --- src/Text/Pandoc/Writers/HTML.hs | 10 +++++++--- test/command/7006.md | 20 ++++++++++++++++++++ 2 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 test/command/7006.md diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs index c93322953..0b051c8f0 100644 --- a/src/Text/Pandoc/Writers/HTML.hs +++ b/src/Text/Pandoc/Writers/HTML.hs @@ -1455,11 +1455,15 @@ blockListToNote opts ref blocks = do else let lastBlock = last blocks otherBlocks = init blocks in case lastBlock of - (Para lst) -> otherBlocks ++ + Para [Image _ _ (_,tit)] + | "fig:" `T.isPrefixOf` tit + -> otherBlocks ++ [lastBlock, + Plain backlink] + Para lst -> otherBlocks ++ [Para (lst ++ backlink)] - (Plain lst) -> otherBlocks ++ + Plain lst -> otherBlocks ++ [Plain (lst ++ backlink)] - _ -> otherBlocks ++ [lastBlock, + _ -> otherBlocks ++ [lastBlock, Plain backlink] contents <- blockListToHtml opts blocks' let noteItem = H.li ! prefixedId opts ("fn" <> ref) $ contents diff --git a/test/command/7006.md b/test/command/7006.md new file mode 100644 index 000000000..e7951fb1a --- /dev/null +++ b/test/command/7006.md @@ -0,0 +1,20 @@ +``` +% pandoc -t html +Test.[^fn] + +[^fn]: Foo: + + ![Caption.](/image.jpg) +^D +

Test.1

+
+
+
    +
  1. Foo:

    +
    +Caption. +
    +↩︎
  2. +
+
+```