aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc
diff options
context:
space:
mode:
authorJohn MacFarlane <fiddlosopher@gmail.com>2013-01-04 12:08:18 -0800
committerJohn MacFarlane <fiddlosopher@gmail.com>2013-01-04 12:08:30 -0800
commit5d9fc469920ae7962c1fdde7efcb78b889010d24 (patch)
treea4d2c0954da92cd858660b2e70f408a82fcb0e73 /src/Text/Pandoc
parentef806f6a99dcb99b16282082e76d629f24dcafa8 (diff)
downloadpandoc-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.hs7
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
--