diff options
author | fiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> | 2007-02-15 01:22:02 +0000 |
---|---|---|
committer | fiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> | 2007-02-15 01:22:02 +0000 |
commit | d3efa4aa8a7a051c87734be3f923490913d3f2d9 (patch) | |
tree | a27c9311530c3f790fb2bcb92c406f6a63076ee9 | |
parent | ae19b94fd17cb3983d10b9b0af372b68d353db6d (diff) | |
download | pandoc-d3efa4aa8a7a051c87734be3f923490913d3f2d9.tar.gz |
Use lookAhead parser for the "first pass" looking for
reference keys in Markdown parser, instead of parsing
normally, then using setInput to reset input. Slight
performance improvement.
git-svn-id: https://pandoc.googlecode.com/svn/trunk@536 788f1e2b-df1e-0410-8736-df70ead52e1b
-rw-r--r-- | src/Text/Pandoc/Readers/Markdown.hs | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index a94a0a06e..91f437372 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -171,12 +171,10 @@ parseMarkdown = do -- need to parse raw HTML, since markdown allows it (title, author, date) <- option ([],[],"") titleBlock oldState <- getState - oldInput <- getInput -- go through once just to get list of reference keys - manyTill (referenceKey <|> (do{anyLine; return Null})) eof - newState <- getState - let keysUsed = stateKeysUsed newState - setInput oldInput + keysUsed <- lookAhead $ (do {manyTill (referenceKey <|> (do{anyLine; return Null})) eof; + newState <- getState; + return $ stateKeysUsed newState}) setState (oldState { stateKeysUsed = keysUsed }) blocks <- parseBlocks -- go through again, for real let blocks' = filter (/= Null) blocks |