@@ -198,6 +198,7 @@ where
199import Prelude
199import Prelude
200import Control.Monad.Identity
200import Control.Monad.Identity
201+import Control.Monad.Loops (unfoldM)
201import Control.Monad.Reader
202import Control.Monad.Reader
202import Data.Char (chr, isAlphaNum, isAscii, isAsciiUpper,
203import Data.Char (chr, isAlphaNum, isAscii, isAsciiUpper,
203 isPunctuation, isSpace, ord, toLower, toUpper)
204 isPunctuation, isSpace, ord, toLower, toUpper)
@@ -221,6 +222,7 @@ import Text.Pandoc.Shared
221import qualified Text.Pandoc.UTF8 as UTF8 (putStrLn)
222import qualified Text.Pandoc.UTF8 as UTF8 (putStrLn)
222import Text.Pandoc.XML (fromEntities)
223import Text.Pandoc.XML (fromEntities)
223import Text.Parsec hiding (token)
224import Text.Parsec hiding (token)
225+import qualified Text.Parsec (uncons)
224import Text.Parsec.Pos (initialPos, newPos, updatePosString)
226import Text.Parsec.Pos (initialPos, newPos, updatePosString)
226import Control.Monad.Except
228import Control.Monad.Except
@@ -1044,13 +1046,18 @@ gridTableFooter = blanklines
1046-- | Removes the ParsecT layer from the monad transformer stack
1048-- | Removes the ParsecT layer from the monad transformer stack
1047−readWithM :: Monad m
1049+readWithM :: (Monad m, Stream s m Char)
1048− => ParserT [Char] st m a -- ^ parser
1050+ => ParserT s st m a -- ^ parser
1049 -> st -- ^ initial state
1051 -> st -- ^ initial state
1050− -> String -- ^ input
1052+ -> s -- ^ input
1051 -> m (Either PandocError a)
1053 -> m (Either PandocError a)
1052−readWithM parser state input =
1054+readWithM parser state input = do
1053− mapLeft (PandocParsecError input) `liftM` runParserT parser state "source" input
1055+ res <- runParserT parser state "source" input
1057+ Right x -> return $ Right x
1059+ inp <- map fst <$> unfoldM (Text.Parsec.uncons input)
1060+ return $ Left $ PandocParsecError inp e
1056-- | Parse a string with a given parser and state
1063-- | Parse a string with a given parser and state