diff options
author | fiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> | 2007-09-01 02:01:12 +0000 |
---|---|---|
committer | fiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> | 2007-09-01 02:01:12 +0000 |
commit | bdf78fe33f09979cc0542623e0023a0c3750ba55 (patch) | |
tree | c222f634ef6f9b9cde0043961ff46b1353af4a6c /src/Text/Pandoc/Readers/Markdown.hs | |
parent | f55d62c04ae0f6ca9b0bb7050ab9ce72f21a67df (diff) | |
download | pandoc-bdf78fe33f09979cc0542623e0023a0c3750ba55.tar.gz |
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
Diffstat (limited to 'src/Text/Pandoc/Readers/Markdown.hs')
-rw-r--r-- | src/Text/Pandoc/Readers/Markdown.hs | 6 |
1 files changed, 5 insertions, 1 deletions
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 |