diff options
author | John MacFarlane <jgm@berkeley.edu> | 2019-01-07 20:24:22 -0800 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2019-01-07 20:24:22 -0800 |
commit | f9d9880325454e51948518d54e36cc6a6e91bde2 (patch) | |
tree | 4b21026ce88f33abb3d5ad29cbb407c6e1fbffe2 /src/Text | |
parent | 20bce07dd828a1d112839c37a2b8870969739cdf (diff) | |
download | pandoc-f9d9880325454e51948518d54e36cc6a6e91bde2.tar.gz |
TWiki reader: fix performance issue with underscores.
Underscore emphasis can't cross table cell boundaries,
but the parser wasn't respecting this, leading to exponential
behavior in documents with table cells containing underscores.
This fixes the original sample; it's possible that there
are other performance issues involving underscores.
Closes #3921.
Diffstat (limited to 'src/Text')
-rw-r--r-- | src/Text/Pandoc/Readers/TWiki.hs | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Readers/TWiki.hs b/src/Text/Pandoc/Readers/TWiki.hs index c3cfedcfb..191343203 100644 --- a/src/Text/Pandoc/Readers/TWiki.hs +++ b/src/Text/Pandoc/Readers/TWiki.hs @@ -424,7 +424,9 @@ strongAndEmph :: PandocMonad m => TWParser m B.Inlines strongAndEmph = try $ B.emph . B.strong <$> enclosed (string "__") nestedInlines emph :: PandocMonad m => TWParser m B.Inlines -emph = try $ B.emph <$> enclosed (char '_') nestedInlines +emph = try $ B.emph <$> enclosed (char '_') + (\p -> notFollowedBy (char '|') >> nestedInlines p) +-- emphasis closers can't cross table cell boundaries, see #3921 emphHtml :: PandocMonad m => TWParser m B.Inlines emphHtml = B.emph . mconcat <$> (parseHtmlContent "em" inline <|> parseHtmlContent "i" inline) |