From 3c178690e307f6f2e43d64c341712b1bf609e7fc Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sun, 24 Dec 2023 12:26:35 -0800 Subject: 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. --- src/Text/Pandoc/PDF.hs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'src/Text') diff --git a/src/Text/Pandoc/PDF.hs b/src/Text/Pandoc/PDF.hs index 060262449..bdbe019df 100644 --- a/src/Text/Pandoc/PDF.hs +++ b/src/Text/Pandoc/PDF.hs @@ -425,18 +425,23 @@ runTeXProgram program args tmpDir = do logContents <- if logExists then readFileLazy logFile else return mempty - needsRerun <- checkForRerun logContents - if needsRerun && runNumber < 3 - then go file env'' programArgs (runNumber + 1) + let rerunWarnings = checkForRerun logContents + if not (null rerunWarnings) && runNumber < 3 + then do + report $ MakePDFInfo "Rerun needed" + (T.intercalate "\n" + (map (UTF8.toText . BC.toStrict) rerunWarnings)) + go file env'' programArgs (runNumber + 1) else do let pdfFile = replaceExtension file ".pdf" (log', pdf) <- getResultingPDF (Just logFile) pdfFile return (exit, fromMaybe out log', pdf) - checkForRerun log' = pure $ any isRerunWarning $ BC.lines log' + checkForRerun log' = filter isRerunWarning $ BC.lines log' - isRerunWarning ln = BC.isPrefixOf "LaTeX Warning:" ln && - BS.isInfixOf "Rerun to" (BL.toStrict ln) + isRerunWarning ln = + let ln' = BL.toStrict ln + in BS.isInfixOf "Warning:" ln' && BS.isInfixOf "Rerun" ln' generic2pdf :: (PandocMonad m, MonadIO m) => String -- cgit v1.2.3