diff options
author | John MacFarlane <fiddlosopher@gmail.com> | 2012-10-05 19:25:26 -0700 |
---|---|---|
committer | John MacFarlane <fiddlosopher@gmail.com> | 2012-10-05 19:25:26 -0700 |
commit | 5419b504cef0cc6e1a0f3e321b2fc0a66e12db3c (patch) | |
tree | 25042693e101a38ace41160e473263ddffab68c9 /src | |
parent | f232034ab0a97c71643901a116ed1c55c5fb7f29 (diff) | |
download | pandoc-5419b504cef0cc6e1a0f3e321b2fc0a66e12db3c.tar.gz |
Added stateWarnings to ParserState, added warning function.
This will be used to provide warnings for things like duplicate
footnote refs and link refs.
Diffstat (limited to 'src')
-rw-r--r-- | src/Text/Pandoc/Parsing.hs | 8 |
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 |