aboutsummaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2017-08-09 21:15:54 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2017-08-09 21:16:17 -0700
commitf4bff5d3599d0b6874c6b6604fb11016f8e038a9 (patch)
tree87145fdb1fd337b7efc20422a2a7b2051f577620 /src/Text
parent8c1ae7ddafc483d993d86161a93a1bf10d84f045 (diff)
downloadpandoc-f4bff5d3599d0b6874c6b6604fb11016f8e038a9.tar.gz
RST reader: reorganize block parsers for ~20% faster parsing.
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc/Readers/RST.hs7
1 files changed, 4 insertions, 3 deletions
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