git.iko.soy/typeable/pandoc
on master help sign in
Use lookAhead parser for the "first pass" looking for
d3efa4afiddlosopher
src/Text/Pandoc/Readers/Markdown.hs+3−5
@@ -171,12 +171,10 @@ parseMarkdown = do
171 -- need to parse raw HTML, since markdown allows it
171 -- need to parse raw HTML, since markdown allows it
172 (title, author, date) <- option ([],[],"") titleBlock
172 (title, author, date) <- option ([],[],"") titleBlock
173 oldState <- getState
173 oldState <- getState
174− oldInput <- getInput
175 -- go through once just to get list of reference keys
174 -- go through once just to get list of reference keys
176− manyTill (referenceKey <|> (do{anyLine; return Null})) eof
175+ keysUsed <- lookAhead $ (do {manyTill (referenceKey <|> (do{anyLine; return Null})) eof;
177− newState <- getState
176+ newState <- getState;
178− let keysUsed = stateKeysUsed newState
177+ return $ stateKeysUsed newState})
179− setInput oldInput
180 setState (oldState { stateKeysUsed = keysUsed })
178 setState (oldState { stateKeysUsed = keysUsed })
181 blocks <- parseBlocks -- go through again, for real
179 blocks <- parseBlocks -- go through again, for real
182 let blocks' = filter (/= Null) blocks
180 let blocks' = filter (/= Null) blocks