diff --git a/crates/typst-library/src/layout/mod.rs b/crates/typst-library/src/layout/mod.rs index 77e62dd31..bcbe3b2b6 100644 --- a/crates/typst-library/src/layout/mod.rs +++ b/crates/typst-library/src/layout/mod.rs @@ -750,8 +750,10 @@ impl Default for ListBuilder<'_> { /// Accepts citations. #[derive(Default)] struct CiteGroupBuilder<'a> { + /// The styles. + styles: StyleChain<'a>, /// The citations. - items: StyleVecBuilder<'a, CiteElem>, + items: Vec, /// Trailing content for which it is unclear whether it is part of the list. staged: Vec<(&'a Content, StyleChain<'a>)>, } @@ -766,8 +768,11 @@ impl<'a> CiteGroupBuilder<'a> { } if let Some(citation) = content.to::() { + if self.items.is_empty() { + self.styles = styles; + } self.staged.retain(|(elem, _)| !elem.is::()); - self.items.push(citation.clone(), styles); + self.items.push(citation.clone()); return true; } @@ -775,9 +780,7 @@ impl<'a> CiteGroupBuilder<'a> { } fn finish(self) -> (Content, StyleChain<'a>) { - let (items, styles) = self.items.finish(); - let items = items.into_items(); - let span = items.first().map(|cite| cite.span()).unwrap_or(Span::detached()); - (CiteGroup::new(items).pack().spanned(span), styles) + let span = self.items.first().map(|cite| cite.span()).unwrap_or(Span::detached()); + (CiteGroup::new(self.items).pack().spanned(span), self.styles) } } diff --git a/tests/ref/bugs/cite-show-set.png b/tests/ref/bugs/cite-show-set.png new file mode 100644 index 000000000..566186a4c Binary files /dev/null and b/tests/ref/bugs/cite-show-set.png differ diff --git a/tests/typ/bugs/cite-show-set.typ b/tests/typ/bugs/cite-show-set.typ new file mode 100644 index 000000000..a4111c9a3 --- /dev/null +++ b/tests/typ/bugs/cite-show-set.typ @@ -0,0 +1,9 @@ +// Test show set rules on citations. + +--- +#show cite: set text(red) +A @netwok @arrgh. +B #cite() #cite(). + +#show bibliography: none +#bibliography("/files/works.bib")