git.iko.soy/typeable/pandoc
on master help sign in
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

commitd3efa4aa8a7a051c87734be3f923490913d3f2d9 authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> dateThu 15 Feb 2007, 01:22 (20 years ago) parentae19b94
1 file changed+3−5
src/Text/Pandoc/Readers/Markdown.hs+3−5
src/Text/Pandoc/Readers/Markdown.hs+3−5
@@ -171,12 +171,10 @@ parseMarkdown = do
171171 -- need to parse raw HTML, since markdown allows it
172172 (title, author, date) <- option ([],[],"") titleBlock
173173 oldState <- getState
174− oldInput <- getInput
175174 -- go through once just to get list of reference keys
176− manyTill (referenceKey <|> (do{anyLine; return Null})) eof
177− newState <- getState
178− let keysUsed = stateKeysUsed newState
179− setInput oldInput
175+ keysUsed <- lookAhead $ (do {manyTill (referenceKey <|> (do{anyLine; return Null})) eof;
176+ newState <- getState;
177+ return $ stateKeysUsed newState})
180178 setState (oldState { stateKeysUsed = keysUsed })
181179 blocks <- parseBlocks -- go through again, for real
182180 let blocks' = filter (/= Null) blocks