Line 52 of Markdown::convert calls "array set" to initialize the _references variable; but "array set" does a merge rather than an assignment. You need to call "array unset ::Markdown::_references" just prior to eliminate old references:
array unset ::Markdown::_references
array set ::Markdown::_references [collect_references markdown]
Line 52 of Markdown::convert calls "array set" to initialize the _references variable; but "array set" does a merge rather than an assignment. You need to call "array unset ::Markdown::_references" just prior to eliminate old references: