aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Text/Pandoc/Parsing.hs8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/Text/Pandoc/Parsing.hs b/src/Text/Pandoc/Parsing.hs
index 9239ed9a3..597c00081 100644
--- a/src/Text/Pandoc/Parsing.hs
+++ b/src/Text/Pandoc/Parsing.hs
@@ -62,6 +62,7 @@ module Text.Pandoc.Parsing ( (>>~),
getOption,
guardEnabled,
guardDisabled,
+ warning,
ParserState (..),
defaultParserState,
HeaderType (..),
@@ -725,6 +726,7 @@ data ParserState = ParserState
stateExamples :: M.Map String Int, -- ^ Map from example labels to numbers
stateHasChapters :: Bool, -- ^ True if \chapter encountered
stateMacros :: [Macro], -- ^ List of macros defined so far
+ stateWarnings :: [(SourcePos, String)], -- ^ List of warnings
stateRstDefaultRole :: String -- ^ Current rST default interpreted text role
}
@@ -751,11 +753,17 @@ defaultParserState =
stateExamples = M.empty,
stateHasChapters = False,
stateMacros = [],
+ stateWarnings = [],
stateRstDefaultRole = "title-reference"}
getOption :: (ReaderOptions -> a) -> Parser s ParserState a
getOption f = (f . stateOptions) `fmap` getState
+warning :: String -> Parser s ParserState ()
+warning msg = do
+ pos <- getPosition
+ modifyState $ \st -> st{ stateWarnings = stateWarnings st ++ [(pos,msg)] }
+
-- | Succeed only if the extension is enabled.
guardEnabled :: Extension -> Parser s ParserState ()
guardEnabled ext = getOption readerExtensions >>= guard . Set.member ext