Use lookAhead in parsers for setext headers and

definition lists to see if the next line begins
appropriately; if not, don't waste any more time
parsing...


git-svn-id: https://pandoc.googlecode.com/svn/trunk@976 788f1e2b-df1e-0410-8736-df70ead52e1b
This commit is contained in:
fiddlosopher 2007-09-01 02:01:12 +00:00
parent f55d62c04a
commit bdf78fe33f

View file

@ -227,7 +227,7 @@ block = choice [ header
-- header blocks
--
header = setextHeader <|> atxHeader <?> "header"
header = atxHeader <|> setextHeader <?> "header"
atxHeader = try $ do
level <- many1 (char '#') >>= return . length
@ -239,6 +239,8 @@ atxHeader = try $ do
atxClosing = try $ skipMany (char '#') >> blanklines
setextHeader = try $ do
-- first, see if this block has any chance of being a setextHeader:
lookAhead (anyLine >> oneOf setextHChars)
text <- many1Till inline newline >>= return . normalizeSpaces
level <- choice $ zipWith
(\ch lev -> try (many1 $ char ch) >> blanklines >> return lev)
@ -406,6 +408,8 @@ bulletList = many1 (listItem bulletListStart) >>=
definitionListItem = try $ do
notFollowedBy blankline
notFollowedBy' indentSpaces
-- first, see if this has any chance of being a definition list:
lookAhead (anyLine >> char ':')
term <- manyTill inline newline
raw <- many1 defRawBlock
state <- getState