summaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/typst/src/model/footnote.rs9
-rw-r--r--crates/typst/src/model/reference.rs4
2 files changed, 11 insertions, 2 deletions
diff --git a/crates/typst/src/model/footnote.rs b/crates/typst/src/model/footnote.rs
index f8f36eb2..2aeaad1a 100644
--- a/crates/typst/src/model/footnote.rs
+++ b/crates/typst/src/model/footnote.rs
@@ -93,6 +93,15 @@ impl FootnoteElem {
Self::new(FootnoteBody::Reference(label))
}
+ /// Creates a new footnote referencing the footnote with the specified label,
+ /// with the other fields from the current footnote cloned.
+ pub fn into_ref(&self, label: Label) -> Self {
+ Self {
+ body: FootnoteBody::Reference(label),
+ ..self.clone()
+ }
+ }
+
/// Tests if this footnote is a reference to another footnote.
pub fn is_ref(&self) -> bool {
matches!(self.body(), FootnoteBody::Reference(_))
diff --git a/crates/typst/src/model/reference.rs b/crates/typst/src/model/reference.rs
index 511ca3d9..8194eec5 100644
--- a/crates/typst/src/model/reference.rs
+++ b/crates/typst/src/model/reference.rs
@@ -177,8 +177,8 @@ impl Show for Packed<RefElem> {
let elem = elem.at(span)?;
- if elem.func() == FootnoteElem::elem() {
- return Ok(FootnoteElem::with_label(target).pack().spanned(span));
+ if let Some(footnote) = elem.to_packed::<FootnoteElem>() {
+ return Ok(footnote.into_ref(target).pack().spanned(span));
}
let elem = elem.clone();