summaryrefslogtreecommitdiff
path: root/crates/typst-library/src/model/reference.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/typst-library/src/model/reference.rs')
-rw-r--r--crates/typst-library/src/model/reference.rs15
1 files changed, 7 insertions, 8 deletions
diff --git a/crates/typst-library/src/model/reference.rs b/crates/typst-library/src/model/reference.rs
index 17f93b7c..2d04a97a 100644
--- a/crates/typst-library/src/model/reference.rs
+++ b/crates/typst-library/src/model/reference.rs
@@ -175,7 +175,6 @@ pub struct RefElem {
/// in @intro[Part], it is done
/// manually.
/// ```
- #[borrowed]
pub supplement: Smart<Option<Supplement>>,
/// The kind of reference to produce.
@@ -207,12 +206,12 @@ impl Synthesize for Packed<RefElem> {
let citation = to_citation(self, engine, styles)?;
let elem = self.as_mut();
- elem.push_citation(Some(citation));
- elem.push_element(None);
+ elem.citation = Some(Some(citation));
+ elem.element = Some(None);
if !BibliographyElem::has(engine, elem.target) {
if let Ok(found) = engine.introspector.query_label(elem.target).cloned() {
- elem.push_element(Some(found));
+ elem.element = Some(Some(found));
return Ok(());
}
}
@@ -227,7 +226,7 @@ impl Show for Packed<RefElem> {
let elem = engine.introspector.query_label(self.target);
let span = self.span();
- let form = self.form(styles);
+ let form = self.form.get(styles);
if form == RefForm::Page {
let elem = elem.at(span)?;
let elem = elem.clone();
@@ -299,7 +298,7 @@ impl Show for Packed<RefElem> {
.hint(eco_format!(
"you can enable {} numbering with `#set {}(numbering: \"1.\")`",
elem.func().name(),
- if elem.func() == EquationElem::elem() {
+ if elem.func() == EquationElem::ELEM {
"math.equation"
} else {
elem.func().name()
@@ -332,7 +331,7 @@ fn show_reference(
let loc = elem.location().unwrap();
let numbers = counter.display_at_loc(engine, loc, styles, &numbering.trimmed())?;
- let supplement = match reference.supplement(styles).as_ref() {
+ let supplement = match reference.supplement.get_ref(styles) {
Smart::Auto => supplement,
Smart::Custom(None) => Content::empty(),
Smart::Custom(Some(supplement)) => supplement.resolve(engine, styles, [elem])?,
@@ -353,7 +352,7 @@ fn to_citation(
styles: StyleChain,
) -> SourceResult<Packed<CiteElem>> {
let mut elem = Packed::new(CiteElem::new(reference.target).with_supplement(
- match reference.supplement(styles).clone() {
+ match reference.supplement.get_cloned(styles) {
Smart::Custom(Some(Supplement::Content(content))) => Some(content),
_ => None,
},