From f9c988e7037dcff6588a62025bb9fed2afee76b7 Mon Sep 17 00:00:00 2001 From: fiddlosopher Date: Fri, 6 Jul 2007 06:46:31 +0000 Subject: 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 --- src/Text/Pandoc/Readers/Markdown.hs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/Text/Pandoc/Readers') diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index 767d07a34..0acd72fad 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -161,18 +161,24 @@ titleBlock = try (do return (title, author, date)) parseMarkdown = do - updateState (\state -> state { stateParseRaw = True }) -- parse raw HTML: markdown allows it + updateState (\state -> state { stateParseRaw = True }) -- markdown allows raw HTML (title, author, date) <- option ([],[],"") titleBlock -- go through once just to get list of reference keys - refs <- manyTill (noteBlock <|> referenceKey <|> (do l <- lineClump - return (LineClump l))) eof + refs <- manyTill (referenceKey <|> (do l <- lineClump + return (LineClump l))) eof let keys = map (\(KeyBlock label target) -> (label, target)) $ filter isKeyBlock refs + let rawlines = map (\(LineClump ln) -> ln) $ filter isLineClump refs + setInput $ concat rawlines -- with keys stripped out + updateState (\state -> state { stateKeys = keys }) + -- now go through for notes + refs <- manyTill (noteBlock <|> (do l <- lineClump + return (LineClump l))) eof let notes = map (\(NoteBlock label blocks) -> (label, blocks)) $ filter isNoteBlock refs let rawlines = map (\(LineClump ln) -> ln) $ filter isLineClump refs setInput $ concat rawlines -- with note blocks and keys stripped out - updateState (\state -> state { stateKeys = keys, stateNotes = notes }) + updateState (\state -> state { stateNotes = notes }) blocks <- parseBlocks -- go through again, for real let blocks' = filter (/= Null) blocks return (Pandoc (Meta title author date) blocks') -- cgit v1.2.3