From a274e15f0d236140fec7e4554117fcb55a219566 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sat, 30 Dec 2017 23:33:03 -0800 Subject: Markdown reader: Avoid parsing raw tex unless \ + letter seen. This seems to help with the performance problem, #4216. --- src/Text/Pandoc/Readers/Markdown.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/Text') diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index e7ad9d8ba..f5e6512f8 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -1120,6 +1120,7 @@ rawVerbatimBlock = htmlInBalanced isVerbTag rawTeXBlock :: PandocMonad m => MarkdownParser m (F Blocks) rawTeXBlock = do guardEnabled Ext_raw_tex + lookAhead $ try $ char '\\' >> letter result <- (B.rawBlock "context" . trim . concat <$> many1 ((++) <$> (rawConTeXtEnvironment <|> conTeXtCommand) <*> (blanklines <|> many spaceChar))) @@ -1906,7 +1907,7 @@ inlineNote = try $ do rawLaTeXInline' :: PandocMonad m => MarkdownParser m (F Inlines) rawLaTeXInline' = try $ do guardEnabled Ext_raw_tex - lookAhead (char '\\') + lookAhead $ try $ char '\\' >> letter notFollowedBy' rawConTeXtEnvironment s <- rawLaTeXInline return $ return $ B.rawInline "tex" s -- "tex" because it might be context -- cgit v1.2.3