git.iko.soy/typeable/pandoc
on master help sign in
Change to footnotes in HTML writer: Instead of putting the footnote

backlink on a line by itself, after the content of the note, we now put it at the end of the last paragraph of the footnote. This saves space and looks better. More specifically: + If the last block of the note is a Para or Plain block, the backlink is put at the end of that block's contents. + Otherwise, the backlink is put in a separate Plain block by itself, after the footnote's contents. git-svn-id: https://pandoc.googlecode.com/svn/trunk@697 788f1e2b-df1e-0410-8736-df70ead52e1b

commita786f43e8cfcbcd7252a13e36357d78a0bc1f4bf authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> dateSat 14 Jul 2007, 03:37 (19 years ago) parent8477f14
2 files changed+23−20
src/Text/Pandoc/Writers/HTML.hs+18−5 tests/writer.html+5−15
src/Text/Pandoc/Writers/HTML.hs+18−5
@@ -363,9 +363,22 @@ inlineToHtml opts inline =
363363
364364blockListToNote :: WriterOptions -> String -> [Block] -> State WriterState Html
365365blockListToNote opts ref blocks =
366− do contents <- blockListToHtml opts blocks
367− let backlink = anchor ! [href ("#fnref" ++ ref), theclass "footnoteBacklink",
368− title ("Jump back to footnote " ++ ref)] $
369− (primHtmlChar "#8617")
370− return $ li ! [identifier ("fn" ++ ref)] $ contents +++ backlink
366+ -- If last block is Para or Plain, include the backlink at the end of
367+ -- that block. Otherwise, insert a new Plain block with the backlink.
368+ let backlink = [HtmlInline $ " <a href=\"#fnref" ++ ref ++
369+ "\" class=\"footnoteBackLink\"" ++
370+ " title=\"Jump back to footnote " ++ ref ++ "\">&#8617;</a>"]
371+ blocks' = if null blocks
372+ then []
373+ else let lastBlock = last blocks
374+ otherBlocks = init blocks
375+ in case lastBlock of
376+ (Para lst) -> otherBlocks ++
377+ [Para (lst ++ backlink)]
378+ (Plain lst) -> otherBlocks ++
379+ [Plain (lst ++ backlink)]
380+ _ -> otherBlocks ++ [lastBlock,
381+ Plain backlink]
382+ in do contents <- blockListToHtml opts blocks'
383+ return $ li ! [identifier ("fn" ++ ref)] $ contents
371384
tests/writer.html+5−15
@@ -976,9 +976,7 @@ document.write('<a h'+'ref'+'="ma'+'ilto'+':'+e+'">'+e+'<\/'+'a'+'>');
976976 /><ol
977977 ><li id="fn1"
978978 ><p
979− >Here is the footnote. It can go anywhere after the footnote reference. It need not be placed at the end of the document.</p
980− ><a href="#fnref1" class="footnoteBacklink" title="Jump back to footnote 1"
981− >&#8617;</a
979+ >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">&#8617;</a></p
982980 ></li
983981 ><li id="fn2"
984982 ><p
@@ -991,9 +989,7 @@ document.write('<a h'+'ref'+'="ma'+'ilto'+':'+e+'">'+e+'<\/'+'a'+'>');
991989</code
992990 ></pre
993991 ><p
994− >If you want, you can indent every line, but you can also be lazy and just indent the first line of each block.</p
995− ><a href="#fnref2" class="footnoteBacklink" title="Jump back to footnote 2"
996− >&#8617;</a
992+ >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">&#8617;</a></p
997993 ></li
998994 ><li id="fn3"
999995 ><p
@@ -1003,21 +999,15 @@ document.write('<a h'+'ref'+'="ma'+'ilto'+':'+e+'">'+e+'<\/'+'a'+'>');
1003999 >links</a
10041000 > and <code
10051001 >]</code
1006− > verbatim characters, as well as [bracketed text].</p
1007− ><a href="#fnref3" class="footnoteBacklink" title="Jump back to footnote 3"
1008− >&#8617;</a
1002+ > verbatim characters, as well as [bracketed text]. <a href="#fnref3" class="footnoteBackLink" title="Jump back to footnote 3">&#8617;</a></p
10091003 ></li
10101004 ><li id="fn4"
10111005 ><p
1012− >In quote.</p
1013− ><a href="#fnref4" class="footnoteBacklink" title="Jump back to footnote 4"
1014− >&#8617;</a
1006+ >In quote. <a href="#fnref4" class="footnoteBackLink" title="Jump back to footnote 4">&#8617;</a></p
10151007 ></li
10161008 ><li id="fn5"
10171009 ><p
1018− >In list.</p
1019− ><a href="#fnref5" class="footnoteBacklink" title="Jump back to footnote 5"
1020− >&#8617;</a
1010+ >In list. <a href="#fnref5" class="footnoteBackLink" title="Jump back to footnote 5">&#8617;</a></p
10211011 ></li
10221012 ></ol
10231013 ></div