@@ -40,7 +40,6 @@ import qualified Data.Text as T
40import Data.Text (Text)
40import Data.Text (Text)
41import qualified Data.ByteString as BS
41import qualified Data.ByteString as BS
42import Data.ByteString.Lazy (ByteString)
42import Data.ByteString.Lazy (ByteString)
43−import qualified Data.ByteString.Lazy as B
44import qualified Data.ByteString.Lazy as BL
43import qualified Data.ByteString.Lazy as BL
45import qualified Data.ByteString.Lazy.Char8 as BC
44import qualified Data.ByteString.Lazy.Char8 as BC
46import Data.Maybe (fromMaybe)
45import Data.Maybe (fromMaybe)
@@ -197,7 +196,22 @@ tex2pdf' verbosity args tmpDir program source = do
198 return $ Left $ logmsg <> extramsg
197 return $ Left $ logmsg <> extramsg
199 (ExitSuccess, Nothing) -> return $ Left ""
198 (ExitSuccess, Nothing) -> return $ Left ""
200− (ExitSuccess, Just pdf) -> return $ Right pdf
199+ (ExitSuccess, Just pdf) -> do
200+ missingCharacterWarnings verbosity log'
203+missingCharacterWarnings :: Verbosity -> ByteString -> IO ()
204+missingCharacterWarnings verbosity log' = do
205+ let ls = BC.lines log'
206+ let isMissingCharacterWarning = BC.isPrefixOf "Missing character: "
207+ let warnings = [ UTF8.toStringLazy (BC.drop 19 l)
209+ , isMissingCharacterWarning l
212+ setVerbosity verbosity
213+ mapM_ (report . MissingCharacter) warnings
202-- parsing output
216-- parsing output
@@ -255,12 +269,12 @@ runTeXProgram verbosity program args runNumber numRuns tmpDir source = do
255 mapM_ print env''
269 mapM_ print env''
256 putStr "\n"
270 putStr "\n"
257 putStrLn $ "[makePDF] Contents of " ++ file' ++ ":"
271 putStrLn $ "[makePDF] Contents of " ++ file' ++ ":"
258− B.readFile file' >>= B.putStr
272+ BL.readFile file' >>= BL.putStr
259 putStr "\n"
273 putStr "\n"
260 (exit, out) <- pipeProcess (Just env'') program programArgs BL.empty
274 (exit, out) <- pipeProcess (Just env'') program programArgs BL.empty
261 when (verbosity >= INFO) $ do
275 when (verbosity >= INFO) $ do
262 putStrLn $ "[makePDF] Run #" ++ show runNumber
276 putStrLn $ "[makePDF] Run #" ++ show runNumber
263− B.hPutStr stdout out
277+ BL.hPutStr stdout out
264 putStr "\n"
278 putStr "\n"
265 if runNumber <= numRuns
279 if runNumber <= numRuns
266 then runTeXProgram verbosity program args (runNumber + 1) numRuns tmpDir source
280 then runTeXProgram verbosity program args (runNumber + 1) numRuns tmpDir source
@@ -271,9 +285,16 @@ runTeXProgram verbosity program args runNumber numRuns tmpDir source = do
271 -- We read PDF as a strict bytestring to make sure that the
285 -- We read PDF as a strict bytestring to make sure that the
272 -- temp directory is removed on Windows.
286 -- temp directory is removed on Windows.
273 -- See https://github.com/jgm/pandoc/issues/1192.
287 -- See https://github.com/jgm/pandoc/issues/1192.
274− then (Just . B.fromChunks . (:[])) `fmap` BS.readFile pdfFile
288+ then (Just . BL.fromChunks . (:[])) `fmap` BS.readFile pdfFile
275 else return Nothing
289 else return Nothing
290+ -- Note that some things like Missing character warnings
291+ -- appear in the log but not on stderr, so we prefer the log:
292+ let logFile = replaceExtension file ".log"
293+ logExists <- doesFileExist logFile
294+ log' <- if logExists
295+ then BL.readFile logFile
276− return (exit, out, pdf)
297+ return (exit, log', pdf)
278ms2pdf :: Verbosity
299ms2pdf :: Verbosity
279 -> [String]
300 -> [String]
@@ -294,7 +315,7 @@ ms2pdf verbosity args source = do
294 (exit, out) <- pipeProcess (Just env') "pdfroff" args
315 (exit, out) <- pipeProcess (Just env') "pdfroff" args
295 (BL.fromStrict $ UTF8.fromText source)
316 (BL.fromStrict $ UTF8.fromText source)
296 when (verbosity >= INFO) $ do
317 when (verbosity >= INFO) $ do
297− B.hPutStr stdout out
318+ BL.hPutStr stdout out
298 putStr "\n"
319 putStr "\n"
299 return $ case exit of
320 return $ case exit of
300 ExitFailure _ -> Left out
321 ExitFailure _ -> Left out
@@ -318,12 +339,12 @@ html2pdf verbosity args source = do
318 mapM_ print env'
339 mapM_ print env'
319 putStr "\n"
340 putStr "\n"
320 putStrLn $ "[makePDF] Contents of " ++ file ++ ":"
341 putStrLn $ "[makePDF] Contents of " ++ file ++ ":"
321− B.readFile file >>= B.putStr
342+ BL.readFile file >>= BL.putStr
322 putStr "\n"
343 putStr "\n"
323 (exit, out) <- pipeProcess (Just env') "wkhtmltopdf" programArgs BL.empty
344 (exit, out) <- pipeProcess (Just env') "wkhtmltopdf" programArgs BL.empty
324 removeFile file
345 removeFile file
325 when (verbosity >= INFO) $ do
346 when (verbosity >= INFO) $ do
326− B.hPutStr stdout out
347+ BL.hPutStr stdout out
327 putStr "\n"
348 putStr "\n"
328 pdfExists <- doesFileExist pdfFile
349 pdfExists <- doesFileExist pdfFile
329 mbPdf <- if pdfExists
350 mbPdf <- if pdfExists
@@ -331,7 +352,7 @@ html2pdf verbosity args source = do
331 -- temp directory is removed on Windows.
352 -- temp directory is removed on Windows.
332 -- See https://github.com/jgm/pandoc/issues/1192.
353 -- See https://github.com/jgm/pandoc/issues/1192.
334− res <- (Just . B.fromChunks . (:[])) `fmap` BS.readFile pdfFile
355+ res <- (Just . BL.fromChunks . (:[])) `fmap` BS.readFile pdfFile
335 removeFile pdfFile
356 removeFile pdfFile
336 return res
357 return res
337 else return Nothing
358 else return Nothing
@@ -365,11 +386,11 @@ context2pdf verbosity tmpDir source = inDirectory tmpDir $ do
365 mapM_ print env'
386 mapM_ print env'
366 putStr "\n"
387 putStr "\n"
367 putStrLn $ "[makePDF] Contents of " ++ file ++ ":"
388 putStrLn $ "[makePDF] Contents of " ++ file ++ ":"
368− B.readFile file >>= B.putStr
389+ BL.readFile file >>= BL.putStr
369 putStr "\n"
390 putStr "\n"
370 (exit, out) <- pipeProcess (Just env') "context" programArgs BL.empty
391 (exit, out) <- pipeProcess (Just env') "context" programArgs BL.empty
371 when (verbosity >= INFO) $ do
392 when (verbosity >= INFO) $ do
372− B.hPutStr stdout out
393+ BL.hPutStr stdout out
373 putStr "\n"
394 putStr "\n"
374 let pdfFile = replaceExtension file ".pdf"
395 let pdfFile = replaceExtension file ".pdf"
375 pdfExists <- doesFileExist pdfFile
396 pdfExists <- doesFileExist pdfFile
@@ -377,7 +398,7 @@ context2pdf verbosity tmpDir source = inDirectory tmpDir $ do
377 -- We read PDF as a strict bytestring to make sure that the
398 -- We read PDF as a strict bytestring to make sure that the
378 -- temp directory is removed on Windows.
399 -- temp directory is removed on Windows.
379 -- See https://github.com/jgm/pandoc/issues/1192.
400 -- See https://github.com/jgm/pandoc/issues/1192.
380− then (Just . B.fromChunks . (:[])) `fmap` BS.readFile pdfFile
401+ then (Just . BL.fromChunks . (:[])) `fmap` BS.readFile pdfFile
381 else return Nothing
402 else return Nothing
382 case (exit, mbPdf) of
403 case (exit, mbPdf) of
383 (ExitFailure _, _) -> do
404 (ExitFailure _, _) -> do