diff options
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r-- | src/Text/Pandoc/Readers.hs | 15 | ||||
-rw-r--r-- | src/Text/Pandoc/Writers.hs | 6 |
2 files changed, 10 insertions, 11 deletions
diff --git a/src/Text/Pandoc/Readers.hs b/src/Text/Pandoc/Readers.hs index 76492b0aa..630b8b858 100644 --- a/src/Text/Pandoc/Readers.hs +++ b/src/Text/Pandoc/Readers.hs @@ -106,7 +106,6 @@ import Text.Pandoc.Readers.TWiki import Text.Pandoc.Readers.Txt2Tags import Text.Pandoc.Readers.Vimwiki import Text.Pandoc.Readers.Man -import Text.Pandoc.Shared (mapLeft) import qualified Text.Pandoc.UTF8 as UTF8 import Text.Parsec.Error @@ -116,10 +115,7 @@ data Reader m = TextReader (ReaderOptions -> Text -> m Pandoc) -- | Association list of formats and readers. readers :: PandocMonad m => [(String, Reader m)] readers = [ ("native" , TextReader readNative) - ,("json" , TextReader $ \o s -> - case readJSON o s of - Right doc -> return doc - Left _ -> throwError $ PandocParseError "JSON parse error") + ,("json" , TextReader readJSON) ,("markdown" , TextReader readMarkdown) ,("markdown_strict" , TextReader readMarkdown) ,("markdown_phpextra" , TextReader readMarkdown) @@ -162,6 +158,9 @@ getReader s = getDefaultExtensions readerName) -- | Read pandoc document from JSON format. -readJSON :: ReaderOptions -> Text -> Either PandocError Pandoc -readJSON _ = - mapLeft PandocParseError . eitherDecode' . BL.fromStrict . UTF8.fromText +readJSON :: PandocMonad m + => ReaderOptions -> Text -> m Pandoc +readJSON _ t = + case eitherDecode' . BL.fromStrict . UTF8.fromText $ t of + Right doc -> return doc + Left _ -> throwError $ PandocParseError "JSON parse error" diff --git a/src/Text/Pandoc/Writers.hs b/src/Text/Pandoc/Writers.hs index 5d4a9122a..b61404238 100644 --- a/src/Text/Pandoc/Writers.hs +++ b/src/Text/Pandoc/Writers.hs @@ -132,7 +132,7 @@ data Writer m = TextWriter (WriterOptions -> Pandoc -> m Text) writers :: PandocMonad m => [ ( String, Writer m) ] writers = [ ("native" , TextWriter writeNative) - ,("json" , TextWriter $ \o d -> return $ writeJSON o d) + ,("json" , TextWriter $ \o d -> writeJSON o d) ,("docx" , ByteStringWriter writeDocx) ,("odt" , ByteStringWriter writeODT) ,("pptx" , ByteStringWriter writePowerpoint) @@ -193,5 +193,5 @@ getWriter s Just r -> Right (r, setExts $ getDefaultExtensions writerName) -writeJSON :: WriterOptions -> Pandoc -> Text -writeJSON _ = UTF8.toText . BL.toStrict . encode +writeJSON :: PandocMonad m => WriterOptions -> Pandoc -> m Text +writeJSON _ = return . UTF8.toText . BL.toStrict . encode |