git.iko.soy/typeable/pandoc
on master help sign in
PDF: Changes to error reporting, to handle non-UTF8 error output.
3df75bcJohn MacFarlane
pandoc.hs+4−1
@@ -1172,7 +1172,10 @@ main = do
1172 res <- makePDF latexEngine f writerOptions doc2
1172 res <- makePDF latexEngine f writerOptions doc2
1173 case res of
1173 case res of
1174 Right pdf -> writeBinary pdf
1174 Right pdf -> writeBinary pdf
1175− Left err' -> err 43 $ UTF8.toStringLazy err'
1175+ Left err' -> do
1176+ B.hPutStr stderr $ err'
1177+ B.hPut stderr $ B.pack [10]
1178+ err 43 "Error producing PDF from TeX source"
1176 | otherwise -> selfcontain (f writerOptions doc2 ++
1179 | otherwise -> selfcontain (f writerOptions doc2 ++
1177 ['\n' | not standalone'])
1180 ['\n' | not standalone'])
1178 >>= writerFn outputFile . handleEntities
1181 >>= writerFn outputFile . handleEntities
src/Text/Pandoc/PDF.hs+2−3
@@ -116,7 +116,6 @@ tex2pdf' tmpDir program source = do
116 then 3 -- to get page numbers
116 then 3 -- to get page numbers
117 else 2 -- 1 run won't give you PDF bookmarks
117 else 2 -- 1 run won't give you PDF bookmarks
118 (exit, log', mbPdf) <- runTeXProgram program numruns tmpDir source
118 (exit, log', mbPdf) <- runTeXProgram program numruns tmpDir source
119− let msg = "Error producing PDF from TeX source.\n"
120 case (exit, mbPdf) of
119 case (exit, mbPdf) of
121 (ExitFailure _, _) -> do
120 (ExitFailure _, _) -> do
122 let logmsg = extractMsg log'
121 let logmsg = extractMsg log'
@@ -125,8 +124,8 @@ tex2pdf' tmpDir program source = do
125 x | "! Package inputenc Error" `BC.isPrefixOf` x ->
124 x | "! Package inputenc Error" `BC.isPrefixOf` x ->
126 "\nTry running pandoc with --latex-engine=xelatex."
125 "\nTry running pandoc with --latex-engine=xelatex."
127 _ -> ""
126 _ -> ""
128− return $ Left $ msg <> logmsg <> extramsg
127+ return $ Left $ logmsg <> extramsg
129− (ExitSuccess, Nothing) -> return $ Left msg
128+ (ExitSuccess, Nothing) -> return $ Left ""
130 (ExitSuccess, Just pdf) -> return $ Right pdf
129 (ExitSuccess, Just pdf) -> return $ Right pdf
131
130
132(<>) :: ByteString -> ByteString -> ByteString
131(<>) :: ByteString -> ByteString -> ByteString