@@ -3,7 +3,7 @@ module Main where
3import Data.List (isInfixOf, intercalate, isPrefixOf)
3import Data.List (isInfixOf, intercalate, isPrefixOf)
4import Data.Maybe (isNothing)
4import Data.Maybe (isNothing)
6−import Control.Monad (unless, guard)
6+import Control.Monad (unless, guard, when)
7import Control.Exception (tryJust, bracket)
7import Control.Exception (tryJust, bracket)
9import System.IO (stderr)
9import System.IO (stderr)
@@ -91,7 +91,7 @@ checkLatex txt = (err , bib, ref, unlines $! msgs ++ tips)
91 ref = any (oneOf ["Warning: Reference"
91 ref = any (oneOf ["Warning: Reference"
92 ,"Warning: Label"
92 ,"Warning: Label"
93 ,"Warning: There were undefined references"
93 ,"Warning: There were undefined references"
94− ,"--toc", "--table-of-contents"]) msgs
94+ ]) msgs
96checkPackages :: [String] -> [String]
96checkPackages :: [String] -> [String]
97checkPackages = concatMap chks
97checkPackages = concatMap chks
@@ -201,6 +201,8 @@ main = bracket
201 Left err -> exit err
201 Left err -> exit err
202 Right texFile -> do
202 Right texFile -> do
203 -- run pdflatex
203 -- run pdflatex
204+ when ("--toc" `elem` opts || "--table-of-contents" `elem` opts) $
205+ runLatex latexProgram texFile >> return () -- toc requires extra run
204 latexRes <- runLatex latexProgram texFile
206 latexRes <- runLatex latexProgram texFile
205 case latexRes of
207 case latexRes of
206 Left err -> exit err
208 Left err -> exit err