From bdf78fe33f09979cc0542623e0023a0c3750ba55 Mon Sep 17 00:00:00 2001 From: fiddlosopher Date: Sat, 1 Sep 2007 02:01:12 +0000 Subject: 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 --- src/Text/Pandoc/Readers/Markdown.hs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/Text') diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index 1159d4269..0306ed7c5 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -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 -- cgit v1.2.3