From c95a73bdb331abd37a8273869ccd8bab5e947137 Mon Sep 17 00:00:00 2001 From: Paulo Tanimoto Date: Wed, 20 Jul 2011 22:54:26 -0500 Subject: markdown2pdf: Fix issue reading log with non-UTF8 characters. Replaced 'UTF8.readFile logFile' with 'liftM toString $ BS.readFile logFile' --- src/markdown2pdf.hs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/markdown2pdf.hs b/src/markdown2pdf.hs index 4ead10479..c2c5c9623 100644 --- a/src/markdown2pdf.hs +++ b/src/markdown2pdf.hs @@ -2,8 +2,10 @@ module Main where import Data.List (isInfixOf, intercalate, isPrefixOf) import Data.Maybe (isNothing) - -import Control.Monad (unless, guard) +import qualified Data.ByteString as BS +import Codec.Binary.UTF8.String (decodeString, encodeString) +import Data.ByteString.UTF8 (toString) +import Control.Monad (unless, guard, liftM) import Control.Exception (tryJust, bracket) import System.IO (stderr) @@ -14,8 +16,6 @@ import System.Exit (ExitCode (..), exitWith) import System.FilePath import System.Directory import System.Process (readProcessWithExitCode) -import Codec.Binary.UTF8.String (decodeString, encodeString) -import Control.Monad (liftM) run :: FilePath -> [String] -> IO (Either String String) run file opts = do @@ -52,7 +52,8 @@ runLatexRaw latexProgram file = do takeDirectory file, dropExtension file] >> return () let pdfFile = replaceExtension file "pdf" let logFile = replaceExtension file "log" - txt <- tryJust (guard . isDoesNotExistError) (UTF8.readFile logFile) + txt <- tryJust (guard . isDoesNotExistError) + (liftM toString $ BS.readFile logFile) let checks = checkLatex $ either (const "") id txt case checks of -- err , bib , ref , msg -- cgit v1.2.3