mirror of
https://github.com/jgm/pandoc.git
synced 2026-09-24 15:44:59 +08:00
Markdown reader: treat 4 or more * or _ in a row as literal text.
(Instead of trying to parse as strong or emph, which leads to exponential performance problems.) git-svn-id: https://pandoc.googlecode.com/svn/trunk@1634 788f1e2b-df1e-0410-8736-df70ead52e1b
This commit is contained in:
@@ -824,6 +824,7 @@ inlineParsers = [ str
|
||||
, endline
|
||||
, code
|
||||
, charRef
|
||||
, (fourOrMore '*' <|> fourOrMore '_')
|
||||
, strong
|
||||
, emph
|
||||
, note
|
||||
@@ -921,6 +922,12 @@ mathInline = try $ do
|
||||
notFollowedBy digit
|
||||
return $ intercalate " " words'
|
||||
|
||||
-- to avoid performance problems, treat 4 or more _ or * in a row as a literal
|
||||
-- rather than attempting to parse for emph/strong
|
||||
fourOrMore :: Char -> GenParser Char st Inline
|
||||
fourOrMore c = try $ count 4 (char c) >> many (char c) >>= \s ->
|
||||
return (Str $ replicate 4 c ++ s)
|
||||
|
||||
emph :: GenParser Char ParserState Inline
|
||||
emph = ((enclosed (char '*') (notFollowedBy' strong >> char '*') inline) <|>
|
||||
(enclosed (char '_') (notFollowedBy' strong >> char '_' >>
|
||||
|
||||
Reference in New Issue
Block a user