From bf43da01c931f1fda936d6357aa3677804d80add Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Thu, 8 Jul 2010 17:31:55 -0700 Subject: Added writerUserDataDir to WriterOptions. --- src/Text/Pandoc/Shared.hs | 2 ++ src/Text/Pandoc/Writers/ODT.hs | 6 +++--- src/pandoc.hs | 6 +++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Text/Pandoc/Shared.hs b/src/Text/Pandoc/Shared.hs index 63285969a..6cb7a2b95 100644 --- a/src/Text/Pandoc/Shared.hs +++ b/src/Text/Pandoc/Shared.hs @@ -478,6 +478,7 @@ data WriterOptions = WriterOptions , writerEmailObfuscation :: ObfuscationMethod -- ^ How to obfuscate emails , writerIdentifierPrefix :: String -- ^ Prefix for section & note ids in HTML , writerSourceDirectory :: FilePath -- ^ Directory path of 1st source file + , writerUserDataDir :: Maybe FilePath -- ^ Path of user data directory } deriving Show -- | Default writer options. @@ -502,6 +503,7 @@ defaultWriterOptions = , writerEmailObfuscation = JavascriptObfuscation , writerIdentifierPrefix = "" , writerSourceDirectory = "." + , writerUserDataDir = Nothing } -- diff --git a/src/Text/Pandoc/Writers/ODT.hs b/src/Text/Pandoc/Writers/ODT.hs index f7acf8e08..5aa0fd310 100644 --- a/src/Text/Pandoc/Writers/ODT.hs +++ b/src/Text/Pandoc/Writers/ODT.hs @@ -42,12 +42,12 @@ import System.Directory import Control.Monad (liftM) -- | Produce an ODT file from a Pandoc document. -writeODT :: Maybe FilePath -- ^ Path of user data directory - -> Maybe FilePath -- ^ Path specified by --reference-odt +writeODT :: Maybe FilePath -- ^ Path specified by --reference-odt -> WriterOptions -- ^ Writer options -> Pandoc -- ^ Document to convert -> IO B.ByteString -writeODT datadir mbRefOdt opts doc = do +writeODT mbRefOdt opts doc = do + let datadir = writerUserDataDir opts refArchive <- liftM toArchive $ case mbRefOdt of Just f -> B.readFile f diff --git a/src/pandoc.hs b/src/pandoc.hs index a1b8244d7..dd2787e7b 100644 --- a/src/pandoc.hs +++ b/src/pandoc.hs @@ -701,8 +701,7 @@ main = do Just s -> return s Nothing -> readDataFile datadir "epub.css" return (writeEPUB epubstyle) - Just _ | writerName' == "odt" -> return - (writeODT datadir referenceODT) + Just _ | writerName' == "odt" -> return (writeODT referenceODT) Just r -> return $ \o d -> return $ fromString (r o d) Nothing -> error ("Unknown writer: " ++ writerName') @@ -782,7 +781,8 @@ main = do then ReferenceObfuscation else obfuscationMethod, writerIdentifierPrefix = idPrefix, - writerSourceDirectory = sourceDir } + writerSourceDirectory = sourceDir, + writerUserDataDir = datadir } when (isNonTextOutput writerName' && outputFile == "-") $ do UTF8.hPutStrLn stderr ("Error: Cannot write " ++ writerName ++ " output to stdout.\n" ++ -- cgit v1.2.3