summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/typst-library/src/layout/grid/mod.rs10
-rw-r--r--crates/typst-library/src/layout/grid/resolve.rs10
-rw-r--r--crates/typst-library/src/model/table.rs10
3 files changed, 26 insertions, 4 deletions
diff --git a/crates/typst-library/src/layout/grid/mod.rs b/crates/typst-library/src/layout/grid/mod.rs
index 52621c64..589799e5 100644
--- a/crates/typst-library/src/layout/grid/mod.rs
+++ b/crates/typst-library/src/layout/grid/mod.rs
@@ -496,6 +496,16 @@ pub struct GridFooter {
#[default(true)]
pub repeat: bool,
+ /// The level of the footer. Must not be zero.
+ ///
+ /// This allows repeating multiple footers at once. Footers with different
+ /// levels can repeat together, as long as they have descending levels.
+ ///
+ /// Notably, when a footer with a lower level stops repeating, all higher
+ /// or equal level headers start repeating, replacing the previous footer.
+ #[default(NonZeroU32::ONE)]
+ pub level: NonZeroU32,
+
/// The cells and lines within the footer.
#[variadic]
pub children: Vec<GridItem>,
diff --git a/crates/typst-library/src/layout/grid/resolve.rs b/crates/typst-library/src/layout/grid/resolve.rs
index fc1d1356..c51db2d1 100644
--- a/crates/typst-library/src/layout/grid/resolve.rs
+++ b/crates/typst-library/src/layout/grid/resolve.rs
@@ -54,6 +54,7 @@ pub fn grid_to_cellgrid<'a>(
},
GridChild::Footer(footer) => ResolvableGridChild::Footer {
repeat: footer.repeat(styles),
+ level: footer.level(styles),
span: footer.span(),
items: footer.children.iter().map(resolve_item),
},
@@ -108,6 +109,7 @@ pub fn table_to_cellgrid<'a>(
},
TableChild::Footer(footer) => ResolvableGridChild::Footer {
repeat: footer.repeat(styles),
+ level: footer.level(styles),
span: footer.span(),
items: footer.children.iter().map(resolve_item),
},
@@ -647,7 +649,7 @@ impl<'a> Entry<'a> {
/// Any grid child, which can be either a header or an item.
pub enum ResolvableGridChild<T: ResolvableCell, I> {
Header { repeat: bool, level: NonZeroU32, span: Span, items: I },
- Footer { repeat: bool, span: Span, items: I },
+ Footer { repeat: bool, level: NonZeroU32, span: Span, items: I },
Item(ResolvableGridItem<T>),
}
@@ -1213,7 +1215,7 @@ impl<'x> CellGridResolver<'_, '_, 'x> {
let mut first_available_row = 0;
let (header_footer_items, simple_item) = match child {
- ResolvableGridChild::Header { repeat, level, span, items, .. } => {
+ ResolvableGridChild::Header { repeat, level, span, items } => {
row_group_data = Some(RowGroupData {
range: None,
span,
@@ -1240,13 +1242,13 @@ impl<'x> CellGridResolver<'_, '_, 'x> {
(Some(items), None)
}
- ResolvableGridChild::Footer { repeat, span, items, .. } => {
+ ResolvableGridChild::Footer { repeat, level, span, items } => {
row_group_data = Some(RowGroupData {
range: None,
span,
repeat,
kind: RowGroupKind::Footer,
- repeatable_level: NonZeroU32::ONE,
+ repeatable_level: level,
top_hlines_start: pending_hlines.len(),
top_hlines_end: None,
});
diff --git a/crates/typst-library/src/model/table.rs b/crates/typst-library/src/model/table.rs
index 0b905bd5..685f78ae 100644
--- a/crates/typst-library/src/model/table.rs
+++ b/crates/typst-library/src/model/table.rs
@@ -590,6 +590,16 @@ pub struct TableFooter {
#[default(true)]
pub repeat: bool,
+ /// The level of the footer. Must not be zero.
+ ///
+ /// This allows repeating multiple footers at once. Footers with different
+ /// levels can repeat together, as long as they have descending levels.
+ ///
+ /// Notably, when a footer with a lower level stops repeating, all higher
+ /// or equal level headers start repeating, replacing the previous footer.
+ #[default(NonZeroU32::ONE)]
+ pub level: NonZeroU32,
+
/// The cells and lines within the footer.
#[variadic]
pub children: Vec<TableItem>,