@@ -106,7 +106,6 @@ import Text.Pandoc.Readers.TWiki
106import Text.Pandoc.Readers.Txt2Tags
106import Text.Pandoc.Readers.Txt2Tags
107import Text.Pandoc.Readers.Vimwiki
107import Text.Pandoc.Readers.Vimwiki
108import Text.Pandoc.Readers.Man
108import Text.Pandoc.Readers.Man
109−import Text.Pandoc.Shared (mapLeft)
110import qualified Text.Pandoc.UTF8 as UTF8
109import qualified Text.Pandoc.UTF8 as UTF8
111import Text.Parsec.Error
110import Text.Parsec.Error
@@ -116,10 +115,7 @@ data Reader m = TextReader (ReaderOptions -> Text -> m Pandoc)
116-- | Association list of formats and readers.
115-- | Association list of formats and readers.
117readers :: PandocMonad m => [(String, Reader m)]
116readers :: PandocMonad m => [(String, Reader m)]
118readers = [ ("native" , TextReader readNative)
117readers = [ ("native" , TextReader readNative)
119− ,("json" , TextReader $ \o s ->
118+ ,("json" , TextReader readJSON)
120− case readJSON o s of
121− Right doc -> return doc
122− Left _ -> throwError $ PandocParseError "JSON parse error")
123 ,("markdown" , TextReader readMarkdown)
119 ,("markdown" , TextReader readMarkdown)
124 ,("markdown_strict" , TextReader readMarkdown)
120 ,("markdown_strict" , TextReader readMarkdown)
125 ,("markdown_phpextra" , TextReader readMarkdown)
121 ,("markdown_phpextra" , TextReader readMarkdown)
@@ -162,6 +158,9 @@ getReader s =
162 getDefaultExtensions readerName)
158 getDefaultExtensions readerName)
164-- | Read pandoc document from JSON format.
160-- | Read pandoc document from JSON format.
161+readJSON :: PandocMonad m
165−readJSON :: ReaderOptions -> Text -> Either PandocError Pandoc
162+ => ReaderOptions -> Text -> m Pandoc
166−readJSON _ =
163+readJSON _ t =
167− mapLeft PandocParseError . eitherDecode' . BL.fromStrict . UTF8.fromText
164+ case eitherDecode' . BL.fromStrict . UTF8.fromText $ t of
165+ Right doc -> return doc
166+ Left _ -> throwError $ PandocParseError "JSON parse error"