diff options
author | John MacFarlane <fiddlosopher@gmail.com> | 2013-01-04 12:08:18 -0800 |
---|---|---|
committer | John MacFarlane <fiddlosopher@gmail.com> | 2013-01-04 12:08:30 -0800 |
commit | 5d9fc469920ae7962c1fdde7efcb78b889010d24 (patch) | |
tree | a4d2c0954da92cd858660b2e70f408a82fcb0e73 /src/Text/Pandoc | |
parent | ef806f6a99dcb99b16282082e76d629f24dcafa8 (diff) | |
download | pandoc-5d9fc469920ae7962c1fdde7efcb78b889010d24.tar.gz |
Markdown reader: Warn about duplicate note references.
Closes #375.
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r-- | src/Text/Pandoc/Readers/Markdown.hs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index 16141369a..985d1d0f2 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -317,6 +317,7 @@ rawLines = do noteBlock :: MarkdownParser (F Blocks) noteBlock = try $ do + pos <- getPosition skipNonindentSpaces ref <- noteMarker char ':' @@ -328,7 +329,11 @@ noteBlock = try $ do optional blanklines parsed <- parseFromString parseBlocks raw let newnote = (ref, parsed) - updateState $ \s -> s { stateNotes' = newnote : stateNotes' s } + oldnotes <- stateNotes' <$> getState + case lookup ref oldnotes of + Just _ -> addWarning (Just pos) $ "Duplicate note reference `" ++ ref ++ "'" + Nothing -> return () + updateState $ \s -> s { stateNotes' = newnote : oldnotes } return mempty -- |