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