@@ -3,7 +3,7 @@ module Main where
33import Data.List (isInfixOf, intercalate, isPrefixOf)
44import Data.Maybe (isNothing)
55
6−import Control.Monad (unless, guard)
6+import Control.Monad (unless, guard, when)
77import Control.Exception (tryJust, bracket)
88
99import System.IO (stderr)
@@ -91,7 +91,7 @@ checkLatex txt = (err , bib, ref, unlines $! msgs ++ tips)
9191 ref = any (oneOf ["Warning: Reference"
9292 ,"Warning: Label"
9393 ,"Warning: There were undefined references"
94− ,"--toc", "--table-of-contents"]) msgs
94+ ]) msgs
9595
9696checkPackages :: [String] -> [String]
9797checkPackages = concatMap chks
@@ -201,6 +201,8 @@ main = bracket
201201 Left err -> exit err
202202 Right texFile -> do
203203 -- run pdflatex
204+ when ("--toc" `elem` opts || "--table-of-contents" `elem` opts) $
205+ runLatex latexProgram texFile >> return () -- toc requires extra run
204206 latexRes <- runLatex latexProgram texFile
205207 case latexRes of
206208 Left err -> exit err