diff options
| -rw-r--r-- | crates/typst-library/src/layout/mod.rs | 15 | ||||
| -rw-r--r-- | tests/ref/bugs/cite-show-set.png | bin | 0 -> 2193 bytes | |||
| -rw-r--r-- | tests/typ/bugs/cite-show-set.typ | 9 |
3 files changed, 18 insertions, 6 deletions
diff --git a/crates/typst-library/src/layout/mod.rs b/crates/typst-library/src/layout/mod.rs index 77e62dd3..bcbe3b2b 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<CiteElem>, /// 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::<CiteElem>() { + if self.items.is_empty() { + self.styles = styles; + } self.staged.retain(|(elem, _)| !elem.is::<SpaceElem>()); - 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 Binary files differnew file mode 100644 index 00000000..566186a4 --- /dev/null +++ b/tests/ref/bugs/cite-show-set.png diff --git a/tests/typ/bugs/cite-show-set.typ b/tests/typ/bugs/cite-show-set.typ new file mode 100644 index 00000000..a4111c9a --- /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(<netwok>) #cite(<arrgh>). + +#show bibliography: none +#bibliography("/files/works.bib") |
