diff options
| author | Eric Biedert <github@ericbiedert.de> | 2024-12-16 21:23:13 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-12-16 20:23:13 +0000 |
| commit | 51020fcf3cd6fbe62d148d2188b9aaac4445bf63 (patch) | |
| tree | c7f12a4f1f170aae2a734ab5696a3b078d31410f /crates/typst-library/src/introspection | |
| parent | 75273937f762ebeb05f71e91434b298b52b44670 (diff) | |
Get numbering of page counter from style chain (#5589)
Diffstat (limited to 'crates/typst-library/src/introspection')
| -rw-r--r-- | crates/typst-library/src/introspection/counter.rs | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/crates/typst-library/src/introspection/counter.rs b/crates/typst-library/src/introspection/counter.rs index b884844c..f67c6daa 100644 --- a/crates/typst-library/src/introspection/counter.rs +++ b/crates/typst-library/src/introspection/counter.rs @@ -366,20 +366,22 @@ impl Counter { .custom() .or_else(|| { let styles = styles?; - let CounterKey::Selector(Selector::Elem(func, _)) = self.0 else { - return None; - }; - - if func == HeadingElem::elem() { - HeadingElem::numbering_in(styles).clone() - } else if func == FigureElem::elem() { - FigureElem::numbering_in(styles).clone() - } else if func == EquationElem::elem() { - EquationElem::numbering_in(styles).clone() - } else if func == FootnoteElem::elem() { - Some(FootnoteElem::numbering_in(styles).clone()) - } else { - None + match self.0 { + CounterKey::Page => PageElem::numbering_in(styles).clone(), + CounterKey::Selector(Selector::Elem(func, _)) => { + if func == HeadingElem::elem() { + HeadingElem::numbering_in(styles).clone() + } else if func == FigureElem::elem() { + FigureElem::numbering_in(styles).clone() + } else if func == EquationElem::elem() { + EquationElem::numbering_in(styles).clone() + } else if func == FootnoteElem::elem() { + Some(FootnoteElem::numbering_in(styles).clone()) + } else { + None + } + } + _ => None, } }) .unwrap_or_else(|| NumberingPattern::from_str("1.1").unwrap().into()); |
