git.iko.soy/typeable/pandoc
on master help sign in
Text.Pandoc.Parsing: Added getOption.
commit8b380a464e7cd27f992e26d861d5e451e90e9600 authorJohn MacFarlane <fiddlosopher@gmail.com> dateWed 25 Jul 2012, 11:27 (14 years ago) parentdfa1906
1 file changed+6−4
src/Text/Pandoc/Parsing.hs+6−4
src/Text/Pandoc/Parsing.hs+6−4
@@ -61,6 +61,7 @@ module Text.Pandoc.Parsing ( (>>~),
6161 readWith,
6262 testStringWith,
6363 ParserState (..),
64+ getOption,
6465 defaultParserState,
6566 HeaderType (..),
6667 ParserContext (..),
@@ -390,9 +391,7 @@ nullBlock = anyChar >> return Null
390391
391392-- | Fail if reader is in strict markdown syntax mode.
392393failIfStrict :: Parsec [a] ParserState ()
393−failIfStrict = do
394− state <- getState
395− if readerStrict (stateOptions state) then fail "strict mode" else return ()
394+failIfStrict = getOption readerStrict >>= guard . not
396395
397396-- | Fail unless we're in literate haskell mode.
398397failUnlessLHS :: Parsec [tok] ParserState ()
@@ -750,6 +749,9 @@ defaultParserState =
750749 stateMacros = [],
751750 stateRstDefaultRole = "title-reference"}
752751
752+getOption :: (ReaderOptions -> a) -> Parser [t] ParserState a
753+getOption f = (f . stateOptions) `fmap` getState
754+
753755data HeaderType
754756 = SingleHeader Char -- ^ Single line of characters underneath
755757 | DoubleHeader Char -- ^ Lines of characters above and below
@@ -795,7 +797,7 @@ lookupKeySrc table key = case M.lookup key table of
795797
796798-- | Fail unless we're in "smart typography" mode.
797799failUnlessSmart :: Parsec [tok] ParserState ()
798−failUnlessSmart = getState >>= guard . readerSmart . stateOptions
800+failUnlessSmart = getOption readerSmart >>= guard
799801
800802smartPunctuation :: Parsec [Char] ParserState Inline
801803 -> Parsec [Char] ParserState Inline