Skip to content

Commit 3c17869

Browse files
committed
T.P.PDF: Ensure that we find all the LaTeX warnings requiring rerun.
This should fix a regression from 3.1.9 that led to incorrect alignments in tables (and possibly other issues). Closes #9284.
1 parent 4672f35 commit 3c17869

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/Text/Pandoc/PDF.hs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -425,18 +425,23 @@ runTeXProgram program args tmpDir = do
425425
logContents <- if logExists
426426
then readFileLazy logFile
427427
else return mempty
428-
needsRerun <- checkForRerun logContents
429-
if needsRerun && runNumber < 3
430-
then go file env'' programArgs (runNumber + 1)
428+
let rerunWarnings = checkForRerun logContents
429+
if not (null rerunWarnings) && runNumber < 3
430+
then do
431+
report $ MakePDFInfo "Rerun needed"
432+
(T.intercalate "\n"
433+
(map (UTF8.toText . BC.toStrict) rerunWarnings))
434+
go file env'' programArgs (runNumber + 1)
431435
else do
432436
let pdfFile = replaceExtension file ".pdf"
433437
(log', pdf) <- getResultingPDF (Just logFile) pdfFile
434438
return (exit, fromMaybe out log', pdf)
435439

436-
checkForRerun log' = pure $ any isRerunWarning $ BC.lines log'
440+
checkForRerun log' = filter isRerunWarning $ BC.lines log'
437441

438-
isRerunWarning ln = BC.isPrefixOf "LaTeX Warning:" ln &&
439-
BS.isInfixOf "Rerun to" (BL.toStrict ln)
442+
isRerunWarning ln =
443+
let ln' = BL.toStrict ln
444+
in BS.isInfixOf "Warning:" ln' && BS.isInfixOf "Rerun" ln'
440445

441446
generic2pdf :: (PandocMonad m, MonadIO m)
442447
=> String

0 commit comments

Comments
 (0)