From 6b7a7adcbf2415230ac866b56841b1017c5264eb Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Fri, 2 Nov 2018 20:26:36 -0700 Subject: Fix readWithM with Stream. --- src/Text/Pandoc/Parsing.hs | 6 ++---- src/Text/Pandoc/Readers/Roff.hs | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) (limited to 'src/Text') diff --git a/src/Text/Pandoc/Parsing.hs b/src/Text/Pandoc/Parsing.hs index d53ea129b..788744db3 100644 --- a/src/Text/Pandoc/Parsing.hs +++ b/src/Text/Pandoc/Parsing.hs @@ -198,7 +198,6 @@ where import Prelude import Control.Monad.Identity -import Control.Monad.Loops (unfoldM) import Control.Monad.Reader import Data.Char (chr, isAlphaNum, isAscii, isAsciiUpper, isPunctuation, isSpace, ord, toLower, toUpper) @@ -222,7 +221,6 @@ import Text.Pandoc.Shared import qualified Text.Pandoc.UTF8 as UTF8 (putStrLn) import Text.Pandoc.XML (fromEntities) import Text.Parsec hiding (token) -import qualified Text.Parsec (uncons) import Text.Parsec.Pos (initialPos, newPos, updatePosString) import Control.Monad.Except @@ -1056,10 +1054,10 @@ readWithM parser state input = do case res of Right x -> return $ Right x Left e -> do - inp <- map fst <$> unfoldM (Text.Parsec.uncons input) + inp <- either (const "") id + <$> runParserT (many1 anyChar) state "source" input return $ Left $ PandocParsecError inp e - -- | Parse a string with a given parser and state readWith :: Parser [Char] st a -> st diff --git a/src/Text/Pandoc/Readers/Roff.hs b/src/Text/Pandoc/Readers/Roff.hs index d46ddd103..632578da7 100644 --- a/src/Text/Pandoc/Readers/Roff.hs +++ b/src/Text/Pandoc/Readers/Roff.hs @@ -53,7 +53,7 @@ import Prelude import Safe (lastDef) import Control.Monad (void, mzero, mplus, guard) import Control.Monad.Except (throwError) -import Control.Monad.State.Strict (StateT(..), evalStateT, get, modify, put) +import Control.Monad.State (StateT(..), evalStateT, get, modify, put) import Text.Pandoc.Class (getResourcePath, readFileFromDirs, PandocMonad(..), report) import Data.Char (isLower, toLower, toUpper, chr, -- cgit v1.2.3