From d3efa4aa8a7a051c87734be3f923490913d3f2d9 Mon Sep 17 00:00:00 2001 From: fiddlosopher Date: Thu, 15 Feb 2007 01:22:02 +0000 Subject: 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 --- src/Text/Pandoc/Readers/Markdown.hs | 8 +++----- 1 file 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 -- cgit v1.2.3