git.iko.soy/typeable/pandoc
on master help sign in
Cleaned up LaTeX footnotes:

+ Footnotes start on a separate line. A comment % is used at the end of the previous line to prevent unwanted spaces. This makes footnotes easier to see, delete, and move around. + The final } now only appears on a separate line if it needs to (i.e. if the note ends with a Verbatim environment). git-svn-id: https://pandoc.googlecode.com/svn/trunk@1061 788f1e2b-df1e-0410-8736-df70ead52e1b

commit40fa01765bbd41145372e4e6f01f375353f683d0 authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> dateThu 1 Nov 2007, 17:32 (19 years ago) parentd5adbcb
2 files changed+19−18
src/Text/Pandoc/Writers/LaTeX.hs+6−5 tests/writer.latex+13−13
src/Text/Pandoc/Writers/LaTeX.hs+6−5
@@ -31,7 +31,7 @@ module Text.Pandoc.Writers.LaTeX ( writeLaTeX ) where
3131import Text.Pandoc.Definition
3232import Text.Pandoc.Shared
3333import Text.Printf ( printf )
34−import Data.List ( (\\), isInfixOf, intersperse )
34+import Data.List ( (\\), isInfixOf, isSuffixOf, intersperse )
3535import Data.Char ( toLower )
3636import qualified Data.Set as S
3737import Control.Monad.State
@@ -303,7 +303,8 @@ inlineToLaTeX (Note contents) = do
303303 put (st {stInNote = True})
304304 contents' <- blockListToLaTeX contents
305305 modify (\st -> st {stInNote = False})
306− return $ text "\\footnote{" $$
307− (nest 11 $ text (stripTrailingNewlines $ render contents') <> text "\n}")
308− -- note: the \n before } is important; removing it causes problems
309− -- if a Verbatim environment occurs at the end of the footnote.
306+ let rawnote = stripTrailingNewlines $ render contents'
307+ -- note: a \n before } is needed when note ends with a Verbatim environment
308+ let optNewline = "\\end{Verbatim}" `isSuffixOf` rawnote
309+ return $ text "%\n\\footnote{" <>
310+ text rawnote <> (if optNewline then char '\n' else empty) <> char '}'
tests/writer.latex+13−13
@@ -792,11 +792,12 @@ Here is a movie \includegraphics{movie.jpg} icon.
792792\section{Footnotes}
793793
794794Here is a footnote
795−reference,\footnote{ Here is the footnote. It can go anywhere after the footnote
796−reference. It need not be placed at the end of the document.
797−}
795+reference,%
796+\footnote{Here is the footnote. It can go anywhere after the footnote
797+reference. It need not be placed at the end of the document.}
798798and
799−another.\footnote{ Here's the long note. This one contains multiple blocks.
799+another.%
800+\footnote{Here's the long note. This one contains multiple blocks.
800801
801802Subsequent blocks are indented to show that they belong to the
802803footnote (as with list items).
@@ -805,24 +806,23 @@ footnote (as with list items).
805806 { <code> }
806807\end{Verbatim}
807808If you want, you can indent every line, but you can also be lazy
808−and just indent the first line of each block.
809−}
809+and just indent the first line of each block.}
810810This should \emph{not} be a footnote reference, because it contains
811811a space.[\^{}my note] Here is an inline
812−note.\footnote{ This is \emph{easier} to type. Inline notes may contain
812+note.%
813+\footnote{This is \emph{easier} to type. Inline notes may contain
813814\href{http://google.com}{links} and \verb!]! verbatim characters,
814−as well as [bracketed text].
815−}
815+as well as [bracketed text].}
816816
817817\begin{quote}
818−Notes can go in quotes.\footnote{ In quote.
819−}
818+Notes can go in quotes.%
819+\footnote{In quote.}
820820
821821\end{quote}
822822\begin{enumerate}[1.]
823823\item
824− And in list items.\footnote{ In list.
825−}
824+ And in list items.%
825+\footnote{In list.}
826826\end{enumerate}
827827This paragraph should not be part of the note, as it is not
828828indented.