diff options
author | John MacFarlane <fiddlosopher@gmail.com> | 2012-02-07 22:00:22 -0800 |
---|---|---|
committer | John MacFarlane <fiddlosopher@gmail.com> | 2012-02-07 22:00:22 -0800 |
commit | 12aa83f70eb5d5fa9f472be2347b4cefa7975b62 (patch) | |
tree | 5368c7c88ce1b5c3adadffbe5dde18ccd21d386e /src/Text | |
parent | 328c91e3071f34f798f472661469b561468713ed (diff) | |
download | pandoc-12aa83f70eb5d5fa9f472be2347b4cefa7975b62.tar.gz |
PDF: Only run latex twice if \tableofcontents is present.
Note: This will pick up on \tableofcontents even if it's
in a verbatim environment. But the worst that can happen is
that the document takes a bit longer to build.
Diffstat (limited to 'src/Text')
-rw-r--r-- | src/Text/Pandoc/PDF.hs | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/Text/Pandoc/PDF.hs b/src/Text/Pandoc/PDF.hs index 4b0dd9207..cc19e1c50 100644 --- a/src/Text/Pandoc/PDF.hs +++ b/src/Text/Pandoc/PDF.hs @@ -43,6 +43,7 @@ import System.IO (hClose) import Control.Concurrent (putMVar, takeMVar, newEmptyMVar, forkIO) import Text.Pandoc.UTF8 as UTF8 import Control.Monad (unless) +import Data.List (isInfixOf) tex2pdf :: String -- ^ tex program (pdflatex, lualatex, xelatex) -> String -- ^ latex source @@ -55,7 +56,9 @@ tex2pdf' :: FilePath -- ^ temp directory for output -> String -- ^ tex source -> IO (Either ByteString ByteString) tex2pdf' tmpDir program source = do - let numruns = 2 -- should suffice for toc and hyperrefs + let numruns = if "\\tableofcontents" `isInfixOf` source + then 2 + else 1 (exit, log', mbPdf) <- runTeXProgram program numruns tmpDir source let msg = "Error producing PDF from TeX source." case (exit, mbPdf) of |