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.
This commit is contained in:
John MacFarlane
2023-12-24 12:26:35 -08:00
parent 4672f35143
commit 3c178690e3
+11 -6
View File
@@ -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