git.iko.soy/typeable/pandoc
on master help sign in
Markdown reader: Warn about duplicate note references.

Closes #375.

commit5d9fc469920ae7962c1fdde7efcb78b889010d24 authorJohn MacFarlane <fiddlosopher@gmail.com> dateFri 4 Jan 2013, 12:08 (14 years ago) parentef806f6
1 file changed+6−1
src/Text/Pandoc/Readers/Markdown.hs+6−1
src/Text/Pandoc/Readers/Markdown.hs+6−1
@@ -317,6 +317,7 @@ rawLines = do
317317
318318noteBlock :: MarkdownParser (F Blocks)
319319noteBlock = try $ do
320+ pos <- getPosition
320321 skipNonindentSpaces
321322 ref <- noteMarker
322323 char ':'
@@ -328,7 +329,11 @@ noteBlock = try $ do
328329 optional blanklines
329330 parsed <- parseFromString parseBlocks raw
330331 let newnote = (ref, parsed)
331− updateState $ \s -> s { stateNotes' = newnote : stateNotes' s }
332+ oldnotes <- stateNotes' <$> getState
333+ case lookup ref oldnotes of
334+ Just _ -> addWarning (Just pos) $ "Duplicate note reference `" ++ ref ++ "'"
335+ Nothing -> return ()
336+ updateState $ \s -> s { stateNotes' = newnote : oldnotes }
332337 return mempty
333338
334339--