diff --git a/src/attr.rs b/src/attr.rs index ef0e42c..3bc4e86 100644 --- a/src/attr.rs +++ b/src/attr.rs @@ -145,7 +145,7 @@ impl<'s> Attributes<'s> { if let Some(attrs0) = &mut self.0 { if let Some(mut attrs1) = other.0 { for (key, val) in attrs1.drain(..) { - if !attrs0.iter().any(|(k, _)| *k == key) { + if key == "class" || !attrs0.iter().any(|(k, _)| *k == key) { attrs0.push((key, val)); } } diff --git a/src/lib.rs b/src/lib.rs index 97c8247..9dce59c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1776,6 +1776,37 @@ mod test { ); } + #[test] + fn link_reference_attrs_class() { + test_parse!( + concat!( + "[text][tag]{.link}\n", + "\n", + "{.def}\n", + "[tag]: url\n", + "para\n", + ), + Start(Paragraph, Attributes::new()), + Start( + Link("url".into(), LinkType::Span(SpanLinkType::Reference)), + [("class", "link"), ("class", "def")].into_iter().collect(), + ), + Str("text".into()), + End(Link("url".into(), LinkType::Span(SpanLinkType::Reference))), + End(Paragraph), + Blankline, + Start( + LinkDefinition { label: "tag" }, + [("class", "def")].into_iter().collect() + ), + Str("url".into()), + End(LinkDefinition { label: "tag" }), + Start(Paragraph, Attributes::new()), + Str("para".into()), + End(Paragraph), + ); + } + #[test] fn autolink() { test_parse!(