git.iko.soy/typeable/pandoc
on master help sign in
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

commit80a4a03df7cae09c73453322729653f9bffbdd75 authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> dateSun 29 Nov 2009, 19:31 (17 years ago) parent93d202c
1 file changed+7
src/Text/Pandoc/Readers/Markdown.hs+7
src/Text/Pandoc/Readers/Markdown.hs+7
@@ -824,6 +824,7 @@ inlineParsers = [ str
824824 , endline
825825 , code
826826 , charRef
827+ , (fourOrMore '*' <|> fourOrMore '_')
827828 , strong
828829 , emph
829830 , note
@@ -921,6 +922,12 @@ mathInline = try $ do
921922 notFollowedBy digit
922923 return $ intercalate " " words'
923924
925+-- to avoid performance problems, treat 4 or more _ or * in a row as a literal
926+-- rather than attempting to parse for emph/strong
927+fourOrMore :: Char -> GenParser Char st Inline
928+fourOrMore c = try $ count 4 (char c) >> many (char c) >>= \s ->
929+ return (Str $ replicate 4 c ++ s)
930+
924931emph :: GenParser Char ParserState Inline
925932emph = ((enclosed (char '*') (notFollowedBy' strong >> char '*') inline) <|>
926933 (enclosed (char '_') (notFollowedBy' strong >> char '_' >>