git.iko.soy/typeable/pandoc
on master help sign in
Use local encoding for input/output rather than forcing UTF8.

Note that system templates are stored as UTF8 and will still be read as such, even if the local encoding is different. Text downloaded from URLs will also be treated as UTF-8.

commitc69837adb648a479167be5e2d37279a02be8060c authorJohn MacFarlane <fiddlosopher@gmail.com> dateSun 23 Sep 2012, 11:01 (14 years ago) parent4d65063
2 files changed+12−13
src/Text/Pandoc/Parsing.hs+1−2 src/pandoc.hs+11−11
src/Text/Pandoc/Parsing.hs+1−2
@@ -146,7 +146,6 @@ where
146146import Text.Pandoc.Definition
147147import Text.Pandoc.Options
148148import Text.Pandoc.Builder (Blocks)
149−import qualified Text.Pandoc.UTF8 as UTF8 (putStrLn)
150149import Text.Parsec
151150import Text.Parsec.Pos (newPos)
152151import Data.Char ( toLower, toUpper, ord, isAscii, isAlphaNum, isDigit, isPunctuation )
@@ -708,7 +707,7 @@ readWith parser state input =
708707testStringWith :: (Show a) => Parser [Char] ParserState a
709708 -> String
710709 -> IO ()
711−testStringWith parser str = UTF8.putStrLn $ show $
710+testStringWith parser str = putStrLn $ show $
712711 readWith parser defaultParserState str
713712
714713-- | Parsing options.
src/pandoc.hs+11−11
@@ -363,7 +363,7 @@ options =
363363 , Option "H" ["include-in-header"]
364364 (ReqArg
365365 (\arg opt -> do
366− text <- UTF8.readFile arg
366+ text <- readFile arg
367367 -- add new ones to end, so they're included in order specified
368368 let newvars = optVariables opt ++ [("header-includes",text)]
369369 return opt { optVariables = newvars,
@@ -374,7 +374,7 @@ options =
374374 , Option "B" ["include-before-body"]
375375 (ReqArg
376376 (\arg opt -> do
377− text <- UTF8.readFile arg
377+ text <- readFile arg
378378 -- add new ones to end, so they're included in order specified
379379 let newvars = optVariables opt ++ [("include-before",text)]
380380 return opt { optVariables = newvars,
@@ -385,7 +385,7 @@ options =
385385 , Option "A" ["include-after-body"]
386386 (ReqArg
387387 (\arg opt -> do
388− text <- UTF8.readFile arg
388+ text <- readFile arg
389389 -- add new ones to end, so they're included in order specified
390390 let newvars = optVariables opt ++ [("include-after",text)]
391391 return opt { optVariables = newvars,
@@ -528,7 +528,7 @@ options =
528528 , Option "" ["epub-stylesheet"]
529529 (ReqArg
530530 (\arg opt -> do
531− text <- UTF8.readFile arg
531+ text <- readFile arg
532532 return opt { optEPUBStylesheet = Just text })
533533 "FILENAME")
534534 "" -- "Path of epub.css"
@@ -544,7 +544,7 @@ options =
544544 , Option "" ["epub-metadata"]
545545 (ReqArg
546546 (\arg opt -> do
547− text <- UTF8.readFile arg
547+ text <- readFile arg
548548 return opt { optEPUBMetadata = text })
549549 "FILENAME")
550550 "" -- "Path of epub metadata file"
@@ -756,7 +756,7 @@ defaultWriterName x =
756756main :: IO ()
757757main = do
758758
759− rawArgs <- liftM (map decodeArg) getArgs
759+ rawArgs <- liftM (map UTF8.decodeArg) getArgs
760760 prg <- getProgName
761761 let compatMode = (prg == "hsmarkdown")
762762
@@ -888,7 +888,7 @@ main = do
888888 let tp' = case takeExtension tp of
889889 "" -> tp <.> format
890890 _ -> tp
891− E.catch (UTF8.readFile tp')
891+ E.catch (readFile tp')
892892 (\e -> if isDoesNotExistError e
893893 then E.catch
894894 (readDataFile datadir $
@@ -982,11 +982,11 @@ main = do
982982
983983 let readSources [] = mapM readSource ["-"]
984984 readSources srcs = mapM readSource srcs
985− readSource "-" = UTF8.getContents
985+ readSource "-" = getContents
986986 readSource src = case parseURI src of
987987 Just u | uriScheme u `elem` ["http:","https:"] ->
988988 readURI u
989− _ -> UTF8.readFile src
989+ _ -> readFile src
990990 readURI uri = simpleHTTP (mkRequest GET uri) >>= getResponseBody >>=
991991 return . toString -- treat all as UTF8
992992
@@ -1026,8 +1026,8 @@ main = do
10261026 writeBinary = B.writeFile (UTF8.encodePath outputFile)
10271027
10281028 let writerFn :: FilePath -> String -> IO ()
1029− writerFn "-" = UTF8.putStr
1030− writerFn f = UTF8.writeFile f
1029+ writerFn "-" = putStr
1030+ writerFn f = writeFile (UTF8.encodePath f)
10311031
10321032 case getWriter writerName' of
10331033 Left e -> err 9 e