@@ -235,10 +235,10 @@ pub fn render_markdown_with_path(
235
235
// `count` is the number of references to this footnote (used for multiple
236
236
// linkbacks, and checking for unused footnotes).
237
237
let mut footnote_numbers = HashMap :: new ( ) ;
238
- // This is a list of ( name, Vec<Event>)
238
+ // This is a map of name -> Vec<Event>
239
239
// `name` is the name of the footnote.
240
240
// The events list is the list of events needed to build the footnote definition.
241
- let mut footnote_defs = Vec :: new ( ) ;
241
+ let mut footnote_defs = HashMap :: new ( ) ;
242
242
243
243
// The following are used when currently processing a footnote definition.
244
244
//
@@ -268,7 +268,16 @@ pub fn render_markdown_with_path(
268
268
Event :: End ( TagEnd :: FootnoteDefinition ) => {
269
269
let def_events = std:: mem:: take ( & mut in_footnote) ;
270
270
let name = std:: mem:: take ( & mut in_footnote_name) ;
271
- footnote_defs. push ( ( name, def_events) ) ;
271
+
272
+ if footnote_defs. contains_key ( & name) {
273
+ log:: warn!(
274
+ "footnote `{name}` in {} defined multiple times - \
275
+ not updating to new definition",
276
+ path. map_or_else( || Cow :: from( "<unknown>" ) , |p| p. to_string_lossy( ) )
277
+ ) ;
278
+ } else {
279
+ footnote_defs. insert ( name, def_events) ;
280
+ }
272
281
None
273
282
}
274
283
Event :: FootnoteReference ( name) => {
@@ -304,7 +313,12 @@ pub fn render_markdown_with_path(
304
313
html:: push_html ( & mut body, events) ;
305
314
306
315
if !footnote_defs. is_empty ( ) {
307
- add_footnote_defs ( & mut body, path, footnote_defs, & footnote_numbers) ;
316
+ add_footnote_defs (
317
+ & mut body,
318
+ path,
319
+ footnote_defs. into_iter ( ) . collect ( ) ,
320
+ & footnote_numbers,
321
+ ) ;
308
322
}
309
323
310
324
body
0 commit comments