aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/ODT.hs21
-rw-r--r--src/pandoc.hs2
2 files changed, 13 insertions, 10 deletions
diff --git a/src/Text/Pandoc/ODT.hs b/src/Text/Pandoc/ODT.hs
index bd497d0b3..6d602fb2a 100644
--- a/src/Text/Pandoc/ODT.hs
+++ b/src/Text/Pandoc/ODT.hs
@@ -42,22 +42,25 @@ import System.Directory
import Control.Monad (liftM)
-- | Produce an ODT file from OpenDocument XML.
-saveOpenDocumentAsODT :: FilePath -- ^ Path of user data directory
- -> FilePath -- ^ Pathname of ODT file to be produced.
- -> FilePath -- ^ Relative directory of source file.
+saveOpenDocumentAsODT :: Maybe FilePath -- ^ Path of user data directory
+ -> FilePath -- ^ Pathname of ODT file to be produced
+ -> FilePath -- ^ Relative directory of source file
-> Maybe FilePath -- ^ Path specified by --reference-odt
- -> String -- ^ OpenDocument XML contents.
+ -> String -- ^ OpenDocument XML contents
-> IO ()
saveOpenDocumentAsODT datadir destinationODTPath sourceDirRelative mbRefOdt xml = do
refArchive <- liftM toArchive $
case mbRefOdt of
Just f -> B.readFile f
Nothing -> do
- let userRefOdt = datadir </> "reference.odt"
- userRefOdtExists <- doesFileExist userRefOdt
- if userRefOdtExists
- then B.readFile userRefOdt
- else getDataFileName "reference.odt" >>= B.readFile
+ let defaultODT = getDataFileName "reference.odt" >>= B.readFile
+ case datadir of
+ Nothing -> defaultODT
+ Just d -> do
+ exists <- doesFileExist (d </> "reference.odt")
+ if exists
+ then B.readFile (d </> "reference.odt")
+ else defaultODT
-- handle pictures
let (newContents, pics) =
case runParser pPictures [] "OpenDocument XML contents" xml of
diff --git a/src/pandoc.hs b/src/pandoc.hs
index 6ca3e3423..f64f218fe 100644
--- a/src/pandoc.hs
+++ b/src/pandoc.hs
@@ -747,7 +747,7 @@ main = do
let writerOutput = writer writerOptions doc' ++ "\n"
case writerName' of
- "odt" -> saveOpenDocumentAsODT datadir outputFile sourceDirRelative referenceODT writerOutput
+ "odt" -> saveOpenDocumentAsODT (Just datadir) outputFile sourceDirRelative referenceODT writerOutput
_ -> if outputFile == "-"
then putStr writerOutput
else writeFile outputFile writerOutput