diff options
author | Jesse Rosenthal <jrosenthal@jhu.edu> | 2016-11-28 17:13:46 -0500 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2017-01-25 17:07:40 +0100 |
commit | b53ebcdf8e8e1f7098a0c93ead4b5bf99971c77f (patch) | |
tree | 01e8d78b85f68e88a737baec9e6bbc932f0a84be /src/Text/Pandoc/Readers/Odt.hs | |
parent | 840439ab2a4d44bc4d295df0d66003fbcc9bb18e (diff) | |
download | pandoc-b53ebcdf8e8e1f7098a0c93ead4b5bf99971c77f.tar.gz |
Working on readers.
Diffstat (limited to 'src/Text/Pandoc/Readers/Odt.hs')
-rw-r--r-- | src/Text/Pandoc/Readers/Odt.hs | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/src/Text/Pandoc/Readers/Odt.hs b/src/Text/Pandoc/Readers/Odt.hs index 046fb4d6d..898dda077 100644 --- a/src/Text/Pandoc/Readers/Odt.hs +++ b/src/Text/Pandoc/Readers/Odt.hs @@ -39,6 +39,10 @@ import qualified Data.ByteString.Lazy as B import System.FilePath +import Control.Monad.Except (throwError) + +import Text.Pandoc.Class (PandocMonad, PandocExecutionError(..)) +import qualified Text.Pandoc.Class as P import Text.Pandoc.Definition import Text.Pandoc.Error import Text.Pandoc.Options @@ -52,11 +56,21 @@ import Text.Pandoc.Readers.Odt.Generic.XMLConverter import Text.Pandoc.Readers.Odt.Generic.Fallible import Text.Pandoc.Shared (filteredFilesFromArchive) --- -readOdt :: ReaderOptions +readOdt :: PandocMonad m + => ReaderOptions -> B.ByteString - -> Either PandocError (Pandoc, MediaBag) -readOdt _ bytes = bytesToOdt bytes-- of + -> m Pandoc +readOdt opts bytes = case readOdt' opts bytes of + Right (doc, mb) -> do + P.setMediaBag mb + return doc + Left _ -> throwError $ PandocParseError "couldn't parse odt" + +-- +readOdt' :: ReaderOptions + -> B.ByteString + -> Either PandocError (Pandoc, MediaBag) +readOdt' _ bytes = bytesToOdt bytes-- of -- Right (pandoc, mediaBag) -> Right (pandoc , mediaBag) -- Left err -> Left err |