diff options
| author | John MacFarlane <[email protected]> | 2025-08-01 12:05:58 -0700 |
|---|---|---|
| committer | John MacFarlane <[email protected]> | 2025-08-01 12:05:58 -0700 |
| commit | 110ed6a5ef4b65914c4c26cbc2c9c838a931fe9f (patch) | |
| tree | 1cf9d75989c10c7f1c81c6403b8c23b3e3bbc0d9 | |
| parent | 8907b0b300c372fea917c9de4ff310b9421eefdc (diff) | |
Text.Pandoc.PDF: avoid encoding errors when reading LaTeX logs.
Sometimes they are not all UTF-8, even in a UTF-8 locale.
Closes #10954.
| -rw-r--r-- | src/Text/Pandoc/PDF.hs | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/Text/Pandoc/PDF.hs b/src/Text/Pandoc/PDF.hs index ef37b8cab..0586eac93 100644 --- a/src/Text/Pandoc/PDF.hs +++ b/src/Text/Pandoc/PDF.hs @@ -365,7 +365,7 @@ runTectonic program args' tmpDir' source = do (exit, out) <- liftIO $ E.catch (pipeProcess (Just env) program programArgs sourceBL) (handlePDFProgramNotFound program) - report $ MakePDFInfo "tectonic output" (UTF8.toText $ BL.toStrict out) + report $ MakePDFInfo "tectonic output" (utf8ToText out) let pdfFile = tmpDir ++ "/texput.pdf" (_, pdf) <- getResultingPDF Nothing pdfFile return (exit, out, pdf) @@ -428,7 +428,7 @@ runTeXProgram program args tmpDir outDir = do (exit, out) <- liftIO $ E.catch (pipeProcess (Just env'') program programArgs BL.empty) (handlePDFProgramNotFound program) - report $ MakePDFInfo "LaTeX output" (UTF8.toText $ BL.toStrict out) + report $ MakePDFInfo "LaTeX output" (utf8ToText out) -- parse log to see if we need to rerun LaTeX let logFile = replaceExtension outfile ".log" logExists <- fileExists logFile @@ -442,8 +442,7 @@ runTeXProgram program args tmpDir outDir = do if not (null rerunWarnings') && runNumber < maxruns then do report $ MakePDFInfo "Rerun needed" - (T.intercalate "\n" - (map (UTF8.toText . BC.toStrict) rerunWarnings')) + (T.intercalate "\n" (map utf8ToText rerunWarnings')) go env'' programArgs (runNumber + 1) else do (log', pdf) <- getResultingPDF (Just logFile) outfile @@ -496,7 +495,7 @@ toPdfViaTempFile verbosity program args mkOutArgs extension source = (handlePDFProgramNotFound program) runIOorExplode $ do setVerbosity verbosity - report $ MakePDFInfo "pdf-engine output" (UTF8.toText $ BL.toStrict out) + report $ MakePDFInfo "pdf-engine output" (utf8ToText out) pdfExists <- doesFileExist pdfFile mbPdf <- if pdfExists -- We read PDF as a strict bytestring to make sure that the @@ -529,7 +528,7 @@ context2pdf program pdfargs tmpDir source = do (handlePDFProgramNotFound program) runIOorExplode $ do setVerbosity verbosity - report $ MakePDFInfo "ConTeXt run output" (UTF8.toText $ BL.toStrict out) + report $ MakePDFInfo "ConTeXt run output" (utf8ToText out) let pdfFile = replaceExtension file ".pdf" pdfExists <- doesFileExist pdfFile mbPdf <- if pdfExists |
