@@ -66,6 +66,7 @@ module Text.Pandoc.Parsing ( anyLine,
6666 gridTableWith,
6767 readWith,
6868 returnWarnings,
69+ returnState,
6970 readWithM,
7071 testStringWith,
7172 guardEnabled,
@@ -873,6 +874,10 @@ returnWarnings p = do
873874 warnings <- stateWarnings <$> getState
874875 return (doc, warnings)
875876
877+-- | Return the final internal state with the result of a parser
878+returnState :: (Stream s m c) => ParsecT s st m a -> ParsecT s st m (a, st)
879+returnState p = (,) <$> p <*> getState
880+
876881-- | Parse a string with @parser@ (for testing).
877882testStringWith :: (Show a, Stream [Char] Identity Char)
878883 => ParserT [Char] ParserState Identity a