Export 'nested' in Parsing.
This commit is contained in:
parent
58a096c058
commit
167012daf7
2 changed files with 13 additions and 12 deletions
|
@ -82,6 +82,7 @@ module Text.Pandoc.Parsing ( (>>~),
|
|||
ellipses,
|
||||
apostrophe,
|
||||
dash,
|
||||
nested,
|
||||
macro,
|
||||
applyMacros',
|
||||
Parser,
|
||||
|
@ -925,6 +926,18 @@ emDashOld = do
|
|||
try (charOrRef "\8212\151") <|> (try $ string "--" >> optional (char '-') >> return '-')
|
||||
return (Str "\8212")
|
||||
|
||||
-- This is used to prevent exponential blowups for things like:
|
||||
-- a**a*a**a*a**a*a**a*a**a*a**a*a**
|
||||
nested :: Parser s ParserState a
|
||||
-> Parser s ParserState a
|
||||
nested p = do
|
||||
nestlevel <- stateMaxNestingLevel `fmap` getState
|
||||
guard $ nestlevel > 0
|
||||
updateState $ \st -> st{ stateMaxNestingLevel = stateMaxNestingLevel st - 1 }
|
||||
res <- p
|
||||
updateState $ \st -> st{ stateMaxNestingLevel = nestlevel }
|
||||
return res
|
||||
|
||||
--
|
||||
-- Macros
|
||||
--
|
||||
|
|
|
@ -1294,18 +1294,6 @@ inlinesBetween start end =
|
|||
where inner = innerSpace <|> (notFollowedBy' (() <$ whitespace) >> inline)
|
||||
innerSpace = try $ whitespace >>~ notFollowedBy' end
|
||||
|
||||
-- This is used to prevent exponential blowups for things like:
|
||||
-- a**a*a**a*a**a*a**a*a**a*a**a*a**
|
||||
nested :: Parser [Char] ParserState a
|
||||
-> Parser [Char] ParserState a
|
||||
nested p = do
|
||||
nestlevel <- stateMaxNestingLevel `fmap` getState
|
||||
guard $ nestlevel > 0
|
||||
updateState $ \st -> st{ stateMaxNestingLevel = stateMaxNestingLevel st - 1 }
|
||||
res <- p
|
||||
updateState $ \st -> st{ stateMaxNestingLevel = nestlevel }
|
||||
return res
|
||||
|
||||
emph :: Parser [Char] ParserState (F Inlines)
|
||||
emph = fmap B.emph <$> nested
|
||||
(inlinesBetween starStart starEnd <|> inlinesBetween ulStart ulEnd)
|
||||
|
|
Loading…
Reference in a new issue