git.iko.soy/typeable/pandoc
on master help sign in
Fixed bug in Markdown reader: links in footnotes were not

being processed. Solution: three-stage parse. First, get all the reference keys and add information to state. Next, get all the notes and add information to state. (Reference keys may be needed at this stage.) Finally, parse everything else. git-svn-id: https://pandoc.googlecode.com/svn/trunk@625 788f1e2b-df1e-0410-8736-df70ead52e1b

commitf9c988e7037dcff6588a62025bb9fed2afee76b7 authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> dateFri 6 Jul 2007, 06:46 (19 years ago) parent1ca8a73
1 file changed+10−4
src/Text/Pandoc/Readers/Markdown.hs+10−4
src/Text/Pandoc/Readers/Markdown.hs+10−4
@@ -161,18 +161,24 @@ titleBlock = try (do
161161 return (title, author, date))
162162
163163parseMarkdown = do
164− updateState (\state -> state { stateParseRaw = True }) -- parse raw HTML: markdown allows it
164+ updateState (\state -> state { stateParseRaw = True }) -- markdown allows raw HTML
165165 (title, author, date) <- option ([],[],"") titleBlock
166166 -- go through once just to get list of reference keys
167− refs <- manyTill (noteBlock <|> referenceKey <|> (do l <- lineClump
168− return (LineClump l))) eof
167+ refs <- manyTill (referenceKey <|> (do l <- lineClump
168+ return (LineClump l))) eof
169169 let keys = map (\(KeyBlock label target) -> (label, target)) $
170170 filter isKeyBlock refs
171+ let rawlines = map (\(LineClump ln) -> ln) $ filter isLineClump refs
172+ setInput $ concat rawlines -- with keys stripped out
173+ updateState (\state -> state { stateKeys = keys })
174+ -- now go through for notes
175+ refs <- manyTill (noteBlock <|> (do l <- lineClump
176+ return (LineClump l))) eof
171177 let notes = map (\(NoteBlock label blocks) -> (label, blocks)) $
172178 filter isNoteBlock refs
173179 let rawlines = map (\(LineClump ln) -> ln) $ filter isLineClump refs
174180 setInput $ concat rawlines -- with note blocks and keys stripped out
175− updateState (\state -> state { stateKeys = keys, stateNotes = notes })
181+ updateState (\state -> state { stateNotes = notes })
176182 blocks <- parseBlocks -- go through again, for real
177183 let blocks' = filter (/= Null) blocks
178184 return (Pandoc (Meta title author date) blocks')