aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Parsing.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Text/Pandoc/Parsing.hs')
-rw-r--r--src/Text/Pandoc/Parsing.hs18
1 files changed, 6 insertions, 12 deletions
diff --git a/src/Text/Pandoc/Parsing.hs b/src/Text/Pandoc/Parsing.hs
index 788744db3..1c2c6408c 100644
--- a/src/Text/Pandoc/Parsing.hs
+++ b/src/Text/Pandoc/Parsing.hs
@@ -1044,19 +1044,13 @@ gridTableFooter = blanklines
---
-- | Removes the ParsecT layer from the monad transformer stack
-readWithM :: (Monad m, Stream s m Char)
- => ParserT s st m a -- ^ parser
- -> st -- ^ initial state
- -> s -- ^ input
+readWithM :: (Monad m, Stream s m Char, ToString s)
+ => ParserT s st m a -- ^ parser
+ -> st -- ^ initial state
+ -> s -- ^ input
-> m (Either PandocError a)
-readWithM parser state input = do
- res <- runParserT parser state "source" input
- case res of
- Right x -> return $ Right x
- Left e -> do
- inp <- either (const "") id
- <$> runParserT (many1 anyChar) state "source" input
- return $ Left $ PandocParsecError inp e
+readWithM parser state input =
+ mapLeft (PandocParsecError $ toString input) `liftM` runParserT parser state "source" input
-- | Parse a string with a given parser and state
readWith :: Parser [Char] st a