diff options
author | fiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> | 2007-07-06 06:46:31 +0000 |
---|---|---|
committer | fiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> | 2007-07-06 06:46:31 +0000 |
commit | f9c988e7037dcff6588a62025bb9fed2afee76b7 (patch) | |
tree | 9bebe10a833d9a664d933e0feafc0345b24fe8fe /src/Text/Pandoc | |
parent | 1ca8a731bc7ecb36bbb7416fbe52bb5fccf42692 (diff) | |
download | pandoc-f9c988e7037dcff6588a62025bb9fed2afee76b7.tar.gz |
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
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r-- | src/Text/Pandoc/Readers/Markdown.hs | 14 |
1 files changed, 10 insertions, 4 deletions
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') |