From 5d9fc469920ae7962c1fdde7efcb78b889010d24 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Fri, 4 Jan 2013 12:08:18 -0800 Subject: Markdown reader: Warn about duplicate note references. Closes #375. --- src/Text/Pandoc/Readers/Markdown.hs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/Text/Pandoc/Readers') 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 -- -- cgit v1.2.3