git.iko.soy/typeable/pandoc
on master help sign in
markdown2pdf: Fixed filename encoding issues.

With help from Paulo Tanimoto. Resolves Issue #286.

commit78cd41c5975bdc69830ea4dfb127b50f19778adb authorJohn MacFarlane <jgm@berkeley.edu> dateSun 13 Feb 2011, 08:28 (16 years ago) parent84bf846
1 file changed+9−7
src/markdown2pdf.hs+9−7
src/markdown2pdf.hs+9−7
@@ -14,11 +14,13 @@ import System.Exit (ExitCode (..), exitWith)
1414import System.FilePath
1515import System.Directory
1616import System.Process (readProcessWithExitCode)
17−
17+import Codec.Binary.UTF8.String (decodeString, encodeString)
18+import Control.Monad (liftM)
1819
1920run :: FilePath -> [String] -> IO (Either String String)
2021run file opts = do
21− (code, out, err) <- readProcessWithExitCode file opts ""
22+ (code, out, err) <- readProcessWithExitCode (encodeString file)
23+ (map encodeString opts) ""
2224 let msg = out ++ err
2325 case code of
2426 ExitFailure _ -> return $ Left $! msg
@@ -122,30 +124,30 @@ saveStdin :: FilePath -> IO (Either String FilePath)
122124saveStdin file = do
123125 text <- UTF8.getContents
124126 UTF8.writeFile file text
125− fileExist <- doesFileExist file
127+ fileExist <- doesFileExist (encodeString file)
126128 case fileExist of
127129 False -> return $ Left $! "Could not create " ++ file
128130 True -> return $ Right file
129131
130132saveOutput :: FilePath -> FilePath -> IO ()
131133saveOutput input output = do
132− copyFile input output
134+ copyFile (encodeString input) (encodeString output)
133135 UTF8.hPutStrLn stderr $! "Created " ++ output
134136
135137main :: IO ()
136138main = bracket
137139 -- acquire resource
138− (do dir <- getTemporaryDirectory
140+ (do dir <- return "testtmp" -- TODO -- getTemporaryDirectory
139141 let tmp = dir </> "pandoc"
140142 createDirectoryIfMissing True tmp
141143 return tmp)
142144
143145 -- release resource
144− ( \tmp -> removeDirectoryRecursive tmp)
146+ ( \tmp -> return () )-- TODO -- removeDirectoryRecursive tmp)
145147
146148 -- run computation
147149 $ \tmp -> do
148− args <- getArgs
150+ args <- liftM (map decodeString) getArgs
149151 -- check for invalid arguments and print help message if needed
150152 let goodopts = ["-f","-r","-N", "-p","-R","-H","-B","-A", "-C","-o","-V"]
151153 let goodoptslong = ["--from","--read","--strict",