mirror of
https://github.com/typst/typst
synced 2025-05-20 20:15:29 +08:00
Fix footnote-reference numbering (#4456)
This commit is contained in:
parent
728fb7e475
commit
75246f930b
@ -93,6 +93,15 @@ impl FootnoteElem {
|
|||||||
Self::new(FootnoteBody::Reference(label))
|
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.
|
/// Tests if this footnote is a reference to another footnote.
|
||||||
pub fn is_ref(&self) -> bool {
|
pub fn is_ref(&self) -> bool {
|
||||||
matches!(self.body(), FootnoteBody::Reference(_))
|
matches!(self.body(), FootnoteBody::Reference(_))
|
||||||
|
@ -177,8 +177,8 @@ impl Show for Packed<RefElem> {
|
|||||||
|
|
||||||
let elem = elem.at(span)?;
|
let elem = elem.at(span)?;
|
||||||
|
|
||||||
if elem.func() == FootnoteElem::elem() {
|
if let Some(footnote) = elem.to_packed::<FootnoteElem>() {
|
||||||
return Ok(FootnoteElem::with_label(target).pack().spanned(span));
|
return Ok(footnote.into_ref(target).pack().spanned(span));
|
||||||
}
|
}
|
||||||
|
|
||||||
let elem = elem.clone();
|
let elem = elem.clone();
|
||||||
|
BIN
tests/ref/issue-4454-footnote-ref-numbering.png
Normal file
BIN
tests/ref/issue-4454-footnote-ref-numbering.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 830 B |
@ -187,3 +187,7 @@ B #footnote[b]
|
|||||||
#set page(height: 50pt)
|
#set page(height: 50pt)
|
||||||
#footnote[A]
|
#footnote[A]
|
||||||
#footnote[B]
|
#footnote[B]
|
||||||
|
|
||||||
|
--- issue-4454-footnote-ref-numbering ---
|
||||||
|
// Test that footnote references are numbered correctly.
|
||||||
|
A #footnote(numbering: "*")[B]<fn>, C @fn, D @fn, E @fn.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user