Skip to content

Commit 27642a2

Browse files
committed
ensure first link definition in a single block gets priority.
1 parent 680c6b1 commit 27642a2

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/parser/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1595,7 +1595,7 @@ where
15951595
}
15961596

15971597
for (lab, rr) in rrs_to_add {
1598-
self.refmap.map.insert(lab, rr);
1598+
self.refmap.map.entry(lab).or_insert(rr);
15991599
}
16001600

16011601
if seeked != 0 {

src/tests/core.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -945,3 +945,11 @@ fn ipv6_host_unescaped() {
945945
"<p><a href=\"https://[2402:1f00:89aa:300::5%25eth0]:9443?target=%3Cyes%3E\">henwo</a></p>\n",
946946
);
947947
}
948+
949+
#[test]
950+
fn link_ref_definition_priority() {
951+
html(
952+
"[foo]\n\n[foo]: first\n[foo]: second\n",
953+
"<p><a href=\"first\">foo</a></p>\n",
954+
);
955+
}

0 commit comments

Comments
 (0)