diff options
author | fiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> | 2009-11-29 19:31:58 +0000 |
---|---|---|
committer | fiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> | 2009-11-29 19:31:58 +0000 |
commit | 80a4a03df7cae09c73453322729653f9bffbdd75 (patch) | |
tree | 87485d988e42dce45a7a22e076fb96552b2032eb /src/Text | |
parent | 93d202cbd1d90949e3e744bf4b81ced7be2842b6 (diff) | |
download | pandoc-80a4a03df7cae09c73453322729653f9bffbdd75.tar.gz |
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
Diffstat (limited to 'src/Text')
-rw-r--r-- | src/Text/Pandoc/Readers/Markdown.hs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index adc41238c..f4384d493 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -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 '_' >> |