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
This commit is contained in:
parent
ae19b94fd1
commit
d3efa4aa8a
1 changed files with 3 additions and 5 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue