diff options
author | John MacFarlane <jgm@berkeley.edu> | 2016-12-11 16:21:08 +0100 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2017-01-25 17:07:41 +0100 |
commit | 08110c371484cb74206a150fe9c2e06eeb32e475 (patch) | |
tree | 0736f75e3b16f3fd94d4859415bd0543acd9ea03 /src | |
parent | 143d1a21139cc7b32777e4154daf6c732037b625 (diff) | |
download | pandoc-08110c371484cb74206a150fe9c2e06eeb32e475.tar.gz |
Class: Removed getDefaultReferenceDocx/ODT from PandocMonad.
We don't need these, since the default docx and odt can be
retrieved using `readDataFile datadir "reference.docx"` (or odt).
Diffstat (limited to 'src')
-rw-r--r-- | src/Text/Pandoc/Class.hs | 24 | ||||
-rw-r--r-- | src/Text/Pandoc/Writers/Docx.hs | 5 | ||||
-rw-r--r-- | src/Text/Pandoc/Writers/ODT.hs | 3 |
3 files changed, 7 insertions, 25 deletions
diff --git a/src/Text/Pandoc/Class.hs b/src/Text/Pandoc/Class.hs index 402fe9dcf..7af9b8bdd 100644 --- a/src/Text/Pandoc/Class.hs +++ b/src/Text/Pandoc/Class.hs @@ -66,8 +66,6 @@ import Data.Unique (hashUnique) import qualified Data.Unique as IO (newUnique) import qualified Text.Pandoc.Shared as IO ( fetchItem , fetchItem' - , getDefaultReferenceDocx - , getDefaultReferenceODT , readDataFile , warn) import Text.Pandoc.Compat.Time (UTCTime) @@ -106,8 +104,6 @@ class (Functor m, Applicative m, Monad m, MonadError PandocError m) lookupEnv :: String -> m (Maybe String) getCurrentTime :: m UTCTime getCurrentTimeZone :: m TimeZone - getDefaultReferenceDocx :: Maybe FilePath -> m Archive - getDefaultReferenceODT :: Maybe FilePath -> m Archive newStdGen :: m StdGen newUniqueHash :: m Int readFileLazy :: FilePath -> m BL.ByteString @@ -215,8 +211,6 @@ instance PandocMonad PandocIO where lookupEnv = liftIO . IO.lookupEnv getCurrentTime = liftIO IO.getCurrentTime getCurrentTimeZone = liftIO IO.getCurrentTimeZone - getDefaultReferenceDocx = liftIO . IO.getDefaultReferenceDocx - getDefaultReferenceODT = liftIO . IO.getDefaultReferenceODT newStdGen = liftIO IO.newStdGen newUniqueHash = hashUnique <$> (liftIO IO.newUnique) readFileLazy s = do @@ -325,10 +319,6 @@ instance PandocMonad PandocPure where getCurrentTimeZone = getsPureState stTimeZone - getDefaultReferenceDocx _ = getsPureState stReferenceDocx - - getDefaultReferenceODT _ = getsPureState stReferenceODT - newStdGen = do g <- getsPureState stStdGen let (_, nxtGen) = next g @@ -348,9 +338,9 @@ instance PandocMonad PandocPure where Just bs -> return (BL.fromStrict bs) Nothing -> throwError $ PandocFileReadError fp readDataFile Nothing "reference.docx" = do - (B.concat . BL.toChunks . fromArchive) <$> (getDefaultReferenceDocx Nothing) + (B.concat . BL.toChunks . fromArchive) <$> getsPureState stReferenceDocx readDataFile Nothing "reference.odt" = do - (B.concat . BL.toChunks . fromArchive) <$> (getDefaultReferenceODT Nothing) + (B.concat . BL.toChunks . fromArchive) <$> getsPureState stReferenceODT readDataFile Nothing fname = do let fname' = if fname == "MANUAL.txt" then fname else "data" </> fname BL.toStrict <$> (readFileLazy fname') @@ -387,8 +377,6 @@ instance PandocMonad m => PandocMonad (ParserT s st m) where lookupEnv = lift . lookupEnv getCurrentTime = lift getCurrentTime getCurrentTimeZone = lift getCurrentTimeZone - getDefaultReferenceDocx = lift . getDefaultReferenceDocx - getDefaultReferenceODT = lift . getDefaultReferenceODT newStdGen = lift newStdGen newUniqueHash = lift newUniqueHash readFileLazy = lift . readFileLazy @@ -404,8 +392,6 @@ instance PandocMonad m => PandocMonad (ReaderT r m) where lookupEnv = lift . lookupEnv getCurrentTime = lift getCurrentTime getCurrentTimeZone = lift getCurrentTimeZone - getDefaultReferenceDocx = lift . getDefaultReferenceDocx - getDefaultReferenceODT = lift . getDefaultReferenceODT newStdGen = lift newStdGen newUniqueHash = lift newUniqueHash readFileLazy = lift . readFileLazy @@ -421,8 +407,6 @@ instance (PandocMonad m, Monoid w) => PandocMonad (WriterT w m) where lookupEnv = lift . lookupEnv getCurrentTime = lift getCurrentTime getCurrentTimeZone = lift getCurrentTimeZone - getDefaultReferenceDocx = lift . getDefaultReferenceDocx - getDefaultReferenceODT = lift . getDefaultReferenceODT newStdGen = lift newStdGen newUniqueHash = lift newUniqueHash readFileLazy = lift . readFileLazy @@ -438,8 +422,6 @@ instance (PandocMonad m, Monoid w) => PandocMonad (RWST r w st m) where lookupEnv = lift . lookupEnv getCurrentTime = lift getCurrentTime getCurrentTimeZone = lift getCurrentTimeZone - getDefaultReferenceDocx = lift . getDefaultReferenceDocx - getDefaultReferenceODT = lift . getDefaultReferenceODT newStdGen = lift newStdGen newUniqueHash = lift newUniqueHash readFileLazy = lift . readFileLazy @@ -455,8 +437,6 @@ instance PandocMonad m => PandocMonad (StateT st m) where lookupEnv = lift . lookupEnv getCurrentTime = lift getCurrentTime getCurrentTimeZone = lift getCurrentTimeZone - getDefaultReferenceDocx = lift . getDefaultReferenceDocx - getDefaultReferenceODT = lift . getDefaultReferenceODT newStdGen = lift newStdGen newUniqueHash = lift newUniqueHash readFileLazy = lift . readFileLazy diff --git a/src/Text/Pandoc/Writers/Docx.hs b/src/Text/Pandoc/Writers/Docx.hs index 662b4d3bb..07aed0c9b 100644 --- a/src/Text/Pandoc/Writers/Docx.hs +++ b/src/Text/Pandoc/Writers/Docx.hs @@ -224,10 +224,11 @@ writeDocx opts doc@(Pandoc meta _) = do let doc' = walk fixDisplayMath $ doc username <- P.lookupEnv "USERNAME" utctime <- P.getCurrentTime - distArchive <- P.getDefaultReferenceDocx datadir + distArchive <- (toArchive . BL.fromStrict) <$> + P.readDataFile datadir "reference.docx" refArchive <- case writerReferenceDoc opts of Just f -> toArchive <$> P.readFileLazy f - Nothing -> P.getDefaultReferenceDocx datadir + Nothing -> return distArchive parsedDoc <- parseXml refArchive distArchive "word/document.xml" let wname f qn = qPrefix qn == Just "w" && f (qName qn) diff --git a/src/Text/Pandoc/Writers/ODT.hs b/src/Text/Pandoc/Writers/ODT.hs index a1a1c4f62..0e4999712 100644 --- a/src/Text/Pandoc/Writers/ODT.hs +++ b/src/Text/Pandoc/Writers/ODT.hs @@ -79,7 +79,8 @@ pandocToODT opts doc@(Pandoc meta _) = do refArchive <- case writerReferenceDoc opts of Just f -> liftM toArchive $ lift $ P.readFileLazy f - Nothing -> lift $ P.getDefaultReferenceODT datadir + Nothing -> lift $ (toArchive . B.fromStrict) <$> + P.readDataFile datadir "reference.odt" -- handle formulas and pictures -- picEntriesRef <- P.newIORef ([] :: [Entry]) doc' <- walkM (transformPicMath opts) $ walk fixDisplayMath doc |