aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2011-07-21 14:49:39 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2011-07-21 14:49:39 -0700
commit4ffb78721443c7bfa9308a8f21bf6d1fe41e8ae1 (patch)
tree61980fa002469c14f010ac499594c6e21f610bd4 /src
parentfe14bf9447248d4be15bfcbff88b3fab51af0a5e (diff)
parentc95a73bdb331abd37a8273869ccd8bab5e947137 (diff)
downloadpandoc-4ffb78721443c7bfa9308a8f21bf6d1fe41e8ae1.tar.gz
Merge pull request #278 from tanimoto/master
markdown2pdf: reading log with non-UTF8 characters
Diffstat (limited to 'src')
-rw-r--r--src/markdown2pdf.hs11
1 files changed, 6 insertions, 5 deletions
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