diff options
author | John MacFarlane <fiddlosopher@gmail.com> | 2012-07-25 11:27:25 -0700 |
---|---|---|
committer | John MacFarlane <fiddlosopher@gmail.com> | 2012-07-25 11:27:25 -0700 |
commit | 8b380a464e7cd27f992e26d861d5e451e90e9600 (patch) | |
tree | 1273d29a034a4a87b60550bffb09a12dcee8af0d /src | |
parent | dfa19061abc24a3e95b9b37e4f9484d902110899 (diff) | |
download | pandoc-8b380a464e7cd27f992e26d861d5e451e90e9600.tar.gz |
Text.Pandoc.Parsing: Added getOption.
Diffstat (limited to 'src')
-rw-r--r-- | src/Text/Pandoc/Parsing.hs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/Text/Pandoc/Parsing.hs b/src/Text/Pandoc/Parsing.hs index 3ed2644ba..878194db7 100644 --- a/src/Text/Pandoc/Parsing.hs +++ b/src/Text/Pandoc/Parsing.hs @@ -61,6 +61,7 @@ module Text.Pandoc.Parsing ( (>>~), readWith, testStringWith, ParserState (..), + getOption, defaultParserState, HeaderType (..), ParserContext (..), @@ -390,9 +391,7 @@ nullBlock = anyChar >> return Null -- | Fail if reader is in strict markdown syntax mode. failIfStrict :: Parsec [a] ParserState () -failIfStrict = do - state <- getState - if readerStrict (stateOptions state) then fail "strict mode" else return () +failIfStrict = getOption readerStrict >>= guard . not -- | Fail unless we're in literate haskell mode. failUnlessLHS :: Parsec [tok] ParserState () @@ -750,6 +749,9 @@ defaultParserState = stateMacros = [], stateRstDefaultRole = "title-reference"} +getOption :: (ReaderOptions -> a) -> Parser [t] ParserState a +getOption f = (f . stateOptions) `fmap` getState + data HeaderType = SingleHeader Char -- ^ Single line of characters underneath | DoubleHeader Char -- ^ Lines of characters above and below @@ -795,7 +797,7 @@ lookupKeySrc table key = case M.lookup key table of -- | Fail unless we're in "smart typography" mode. failUnlessSmart :: Parsec [tok] ParserState () -failUnlessSmart = getState >>= guard . readerSmart . stateOptions +failUnlessSmart = getOption readerSmart >>= guard smartPunctuation :: Parsec [Char] ParserState Inline -> Parsec [Char] ParserState Inline |