diff options
-rw-r--r-- | src/Text/Pandoc/Writers/HTML.hs | 23 | ||||
-rw-r--r-- | tests/writer.html | 20 |
2 files changed, 23 insertions, 20 deletions
diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs index 4ed6a3ce9..ad31969ed 100644 --- a/src/Text/Pandoc/Writers/HTML.hs +++ b/src/Text/Pandoc/Writers/HTML.hs @@ -363,9 +363,22 @@ inlineToHtml opts inline = blockListToNote :: WriterOptions -> String -> [Block] -> State WriterState Html blockListToNote opts ref blocks = - do contents <- blockListToHtml opts blocks - let backlink = anchor ! [href ("#fnref" ++ ref), theclass "footnoteBacklink", - title ("Jump back to footnote " ++ ref)] $ - (primHtmlChar "#8617") - return $ li ! [identifier ("fn" ++ ref)] $ contents +++ backlink + -- If last block is Para or Plain, include the backlink at the end of + -- that block. Otherwise, insert a new Plain block with the backlink. + let backlink = [HtmlInline $ " <a href=\"#fnref" ++ ref ++ + "\" class=\"footnoteBackLink\"" ++ + " title=\"Jump back to footnote " ++ ref ++ "\">↩</a>"] + blocks' = if null blocks + then [] + else let lastBlock = last blocks + otherBlocks = init blocks + in case lastBlock of + (Para lst) -> otherBlocks ++ + [Para (lst ++ backlink)] + (Plain lst) -> otherBlocks ++ + [Plain (lst ++ backlink)] + _ -> otherBlocks ++ [lastBlock, + Plain backlink] + in do contents <- blockListToHtml opts blocks' + return $ li ! [identifier ("fn" ++ ref)] $ contents diff --git a/tests/writer.html b/tests/writer.html index 6d8a850bc..10d1c0c4f 100644 --- a/tests/writer.html +++ b/tests/writer.html @@ -976,9 +976,7 @@ document.write('<a h'+'ref'+'="ma'+'ilto'+':'+e+'">'+e+'<\/'+'a'+'>'); /><ol ><li id="fn1" ><p - >Here is the footnote. It can go anywhere after the footnote reference. It need not be placed at the end of the document.</p - ><a href="#fnref1" class="footnoteBacklink" title="Jump back to footnote 1" - >↩</a + >Here is the footnote. It can go anywhere after the footnote reference. It need not be placed at the end of the document. <a href="#fnref1" class="footnoteBackLink" title="Jump back to footnote 1">↩</a></p ></li ><li id="fn2" ><p @@ -991,9 +989,7 @@ document.write('<a h'+'ref'+'="ma'+'ilto'+':'+e+'">'+e+'<\/'+'a'+'>'); </code ></pre ><p - >If you want, you can indent every line, but you can also be lazy and just indent the first line of each block.</p - ><a href="#fnref2" class="footnoteBacklink" title="Jump back to footnote 2" - >↩</a + >If you want, you can indent every line, but you can also be lazy and just indent the first line of each block. <a href="#fnref2" class="footnoteBackLink" title="Jump back to footnote 2">↩</a></p ></li ><li id="fn3" ><p @@ -1003,21 +999,15 @@ document.write('<a h'+'ref'+'="ma'+'ilto'+':'+e+'">'+e+'<\/'+'a'+'>'); >links</a > and <code >]</code - > verbatim characters, as well as [bracketed text].</p - ><a href="#fnref3" class="footnoteBacklink" title="Jump back to footnote 3" - >↩</a + > verbatim characters, as well as [bracketed text]. <a href="#fnref3" class="footnoteBackLink" title="Jump back to footnote 3">↩</a></p ></li ><li id="fn4" ><p - >In quote.</p - ><a href="#fnref4" class="footnoteBacklink" title="Jump back to footnote 4" - >↩</a + >In quote. <a href="#fnref4" class="footnoteBackLink" title="Jump back to footnote 4">↩</a></p ></li ><li id="fn5" ><p - >In list.</p - ><a href="#fnref5" class="footnoteBacklink" title="Jump back to footnote 5" - >↩</a + >In list. <a href="#fnref5" class="footnoteBackLink" title="Jump back to footnote 5">↩</a></p ></li ></ol ></div |