From f4bff5d3599d0b6874c6b6604fb11016f8e038a9 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Wed, 9 Aug 2017 21:15:54 -0700 Subject: RST reader: reorganize block parsers for ~20% faster parsing. --- src/Text/Pandoc/Readers/RST.hs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/Text') diff --git a/src/Text/Pandoc/Readers/RST.hs b/src/Text/Pandoc/Readers/RST.hs index 02812dbd9..3b1eee010 100644 --- a/src/Text/Pandoc/Readers/RST.hs +++ b/src/Text/Pandoc/Readers/RST.hs @@ -215,10 +215,10 @@ block :: PandocMonad m => RSTParser m Blocks block = choice [ codeBlock , blockQuote , fieldList - , include , directive , anchor , comment + , include , header , hrule , lineBlock -- must go before definitionList @@ -352,7 +352,8 @@ singleHeader = do singleHeader' :: PandocMonad m => RSTParser m (Inlines, Char) singleHeader' = try $ do notFollowedBy' whitespace - txt <- trimInlines . mconcat <$> many1 (do {notFollowedBy blankline; inline}) + lookAhead $ anyLine >> oneOf underlineChars + txt <- trimInlines . mconcat <$> many1 (do {notFollowedBy newline; inline}) pos <- getPosition let len = (sourceColumn pos) - 1 blankline @@ -630,7 +631,7 @@ comment :: Monad m => RSTParser m Blocks comment = try $ do string ".." skipMany1 spaceChar <|> (() <$ lookAhead newline) - notFollowedBy' directiveLabel + -- notFollowedBy' directiveLabel -- comment comes after directive so unnec. manyTill anyChar blanklines optional indentedBlock return mempty -- cgit v1.2.3