diff options
| author | Yip Coekjan <69834864+Coekjan@users.noreply.github.com> | 2024-07-02 22:46:25 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-02 14:46:25 +0000 |
| commit | 75246f930b9041c206a8a3c87e6db03bfc9111fd (patch) | |
| tree | b930396e9587f9177396f47d4aa6711ec6904260 /crates | |
| parent | 728fb7e475d024e7534aec1e47ea9b888671c1b3 (diff) | |
Fix footnote-reference numbering (#4456)
Diffstat (limited to 'crates')
| -rw-r--r-- | crates/typst/src/model/footnote.rs | 9 | ||||
| -rw-r--r-- | crates/typst/src/model/reference.rs | 4 |
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(); |
