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:
fiddlosopher
2009-11-29 19:31:58 +00:00
parent 93d202cbd1
commit 80a4a03df7
+7
View File
@@ -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 '_' >>