aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2011-02-13 08:28:59 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2011-02-13 08:28:59 -0800
commit78cd41c5975bdc69830ea4dfb127b50f19778adb (patch)
tree8857a44d79effd9ddb8f9ae60734ee51ab656c21 /src
parent84bf84650353d42668a9e5c8ac9f9609c3f6da6a (diff)
downloadpandoc-78cd41c5975bdc69830ea4dfb127b50f19778adb.tar.gz
markdown2pdf: Fixed filename encoding issues.
With help from Paulo Tanimoto. Resolves Issue #286.
Diffstat (limited to 'src')
-rw-r--r--src/markdown2pdf.hs16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/markdown2pdf.hs b/src/markdown2pdf.hs
index c61aaa8cb..8dc5f273c 100644
--- a/src/markdown2pdf.hs
+++ b/src/markdown2pdf.hs
@@ -14,11 +14,13 @@ 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
- (code, out, err) <- readProcessWithExitCode file opts ""
+ (code, out, err) <- readProcessWithExitCode (encodeString file)
+ (map encodeString opts) ""
let msg = out ++ err
case code of
ExitFailure _ -> return $ Left $! msg
@@ -122,30 +124,30 @@ saveStdin :: FilePath -> IO (Either String FilePath)
saveStdin file = do
text <- UTF8.getContents
UTF8.writeFile file text
- fileExist <- doesFileExist file
+ fileExist <- doesFileExist (encodeString file)
case fileExist of
False -> return $ Left $! "Could not create " ++ file
True -> return $ Right file
saveOutput :: FilePath -> FilePath -> IO ()
saveOutput input output = do
- copyFile input output
+ copyFile (encodeString input) (encodeString output)
UTF8.hPutStrLn stderr $! "Created " ++ output
main :: IO ()
main = bracket
-- acquire resource
- (do dir <- getTemporaryDirectory
+ (do dir <- return "testtmp" -- TODO -- getTemporaryDirectory
let tmp = dir </> "pandoc"
createDirectoryIfMissing True tmp
return tmp)
-- release resource
- ( \tmp -> removeDirectoryRecursive tmp)
+ ( \tmp -> return () )-- TODO -- removeDirectoryRecursive tmp)
-- run computation
$ \tmp -> do
- args <- getArgs
+ args <- liftM (map decodeString) getArgs
-- check for invalid arguments and print help message if needed
let goodopts = ["-f","-r","-N", "-p","-R","-H","-B","-A", "-C","-o","-V"]
let goodoptslong = ["--from","--read","--strict",