mirror of
https://github.com/typst/typst
synced 2025-08-23 11:14:13 +08:00
Compare commits
No commits in common. "9c49bd507a2aff63c0240b6e45433f862b4a5c8b" and "71ae276071f7b47aa65419e2d7dac5e8e08a369a" have entirely different histories.
9c49bd507a
...
71ae276071
@ -1486,18 +1486,12 @@ impl<'a> GridLayouter<'a> {
|
|||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
} else if let Some(Repeatable::Repeated(_)) = &self.grid.footer {
|
} else if let Some(Repeatable::Repeated(footer)) = &self.grid.footer {
|
||||||
// If no rows other than the footer have been laid out so far,
|
// If no rows other than the footer have been laid out so far,
|
||||||
// and there are rows beside the footer, then don't lay it out
|
// and there are rows beside the footer, then don't lay it out
|
||||||
// at all. (Similar check from above, but for the case without
|
// at all. (Similar check from above, but for the case without
|
||||||
// headers.)
|
// headers.)
|
||||||
//
|
// TODO: widow prevention for non-repeated footers with a
|
||||||
// It is worth noting that the footer is made non-repeatable at
|
|
||||||
// the grid resolving stage if it is short-lived, that is, if
|
|
||||||
// it is at the start of the table (or right after headers at
|
|
||||||
// the start of the table).
|
|
||||||
// TODO(subfooters): explicitly check for short-lived footers.
|
|
||||||
// TODO(subfooters): widow prevention for non-repeated footers with a
|
|
||||||
// similar mechanism / when implementing multiple footers.
|
// similar mechanism / when implementing multiple footers.
|
||||||
self.lrows.is_empty()
|
self.lrows.is_empty()
|
||||||
&& may_progress_with_offset(
|
&& may_progress_with_offset(
|
||||||
@ -1508,6 +1502,7 @@ impl<'a> GridLayouter<'a> {
|
|||||||
// zero anyway.
|
// zero anyway.
|
||||||
self.current.header_height + self.current.footer_height,
|
self.current.header_height + self.current.footer_height,
|
||||||
)
|
)
|
||||||
|
&& footer.start != 0
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
};
|
};
|
||||||
|
@ -1063,10 +1063,6 @@ impl<'x> CellGridResolver<'_, '_, 'x> {
|
|||||||
let mut footer: Option<(usize, Span, Footer)> = None;
|
let mut footer: Option<(usize, Span, Footer)> = None;
|
||||||
let mut repeat_footer = false;
|
let mut repeat_footer = false;
|
||||||
|
|
||||||
// If true, there has been at least one cell besides headers and
|
|
||||||
// footers. When false, footers at the end are forced to not repeat.
|
|
||||||
let mut at_least_one_cell = false;
|
|
||||||
|
|
||||||
// We can't just use the cell's index in the 'cells' vector to
|
// We can't just use the cell's index in the 'cells' vector to
|
||||||
// determine its automatic position, since cells could have arbitrary
|
// determine its automatic position, since cells could have arbitrary
|
||||||
// positions, so the position of a cell in 'cells' can differ from its
|
// positions, so the position of a cell in 'cells' can differ from its
|
||||||
@ -1108,7 +1104,6 @@ impl<'x> CellGridResolver<'_, '_, 'x> {
|
|||||||
&mut repeat_footer,
|
&mut repeat_footer,
|
||||||
&mut auto_index,
|
&mut auto_index,
|
||||||
&mut resolved_cells,
|
&mut resolved_cells,
|
||||||
&mut at_least_one_cell,
|
|
||||||
child,
|
child,
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
@ -1130,7 +1125,6 @@ impl<'x> CellGridResolver<'_, '_, 'x> {
|
|||||||
footer,
|
footer,
|
||||||
repeat_footer,
|
repeat_footer,
|
||||||
row_amount,
|
row_amount,
|
||||||
at_least_one_cell,
|
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
Ok(CellGrid::new_internal(
|
Ok(CellGrid::new_internal(
|
||||||
@ -1163,7 +1157,6 @@ impl<'x> CellGridResolver<'_, '_, 'x> {
|
|||||||
repeat_footer: &mut bool,
|
repeat_footer: &mut bool,
|
||||||
auto_index: &mut usize,
|
auto_index: &mut usize,
|
||||||
resolved_cells: &mut Vec<Option<Entry<'x>>>,
|
resolved_cells: &mut Vec<Option<Entry<'x>>>,
|
||||||
at_least_one_cell: &mut bool,
|
|
||||||
child: ResolvableGridChild<T, I>,
|
child: ResolvableGridChild<T, I>,
|
||||||
) -> SourceResult<()>
|
) -> SourceResult<()>
|
||||||
where
|
where
|
||||||
@ -1247,13 +1240,7 @@ impl<'x> CellGridResolver<'_, '_, 'x> {
|
|||||||
|
|
||||||
(Some(items), None)
|
(Some(items), None)
|
||||||
}
|
}
|
||||||
ResolvableGridChild::Item(item) => {
|
ResolvableGridChild::Item(item) => (None, Some(item)),
|
||||||
if matches!(item, ResolvableGridItem::Cell(_)) {
|
|
||||||
*at_least_one_cell = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
(None, Some(item))
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let items = header_footer_items.into_iter().flatten().chain(simple_item);
|
let items = header_footer_items.into_iter().flatten().chain(simple_item);
|
||||||
@ -1797,7 +1784,6 @@ impl<'x> CellGridResolver<'_, '_, 'x> {
|
|||||||
footer: Option<(usize, Span, Footer)>,
|
footer: Option<(usize, Span, Footer)>,
|
||||||
repeat_footer: bool,
|
repeat_footer: bool,
|
||||||
row_amount: usize,
|
row_amount: usize,
|
||||||
at_least_one_cell: bool,
|
|
||||||
) -> SourceResult<Option<Repeatable<Footer>>> {
|
) -> SourceResult<Option<Repeatable<Footer>>> {
|
||||||
// Repeat the gutter below a header (hence why we don't
|
// Repeat the gutter below a header (hence why we don't
|
||||||
// subtract 1 from the gutter case).
|
// subtract 1 from the gutter case).
|
||||||
@ -1870,11 +1856,7 @@ impl<'x> CellGridResolver<'_, '_, 'x> {
|
|||||||
})
|
})
|
||||||
.transpose()?
|
.transpose()?
|
||||||
.map(|footer| {
|
.map(|footer| {
|
||||||
// Don't repeat footers when the table only has headers and
|
if repeat_footer {
|
||||||
// footers.
|
|
||||||
// TODO(subfooters): Switch this to marking the last N
|
|
||||||
// consecutive footers as short lived.
|
|
||||||
if repeat_footer && at_least_one_cell {
|
|
||||||
Repeatable::Repeated(footer)
|
Repeatable::Repeated(footer)
|
||||||
} else {
|
} else {
|
||||||
Repeatable::NotRepeated(footer)
|
Repeatable::NotRepeated(footer)
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 378 B After Width: | Height: | Size: 377 B |
Binary file not shown.
Before Width: | Height: | Size: 382 B |
@ -788,19 +788,3 @@
|
|||||||
[a],
|
[a],
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
--- grid-subheaders-alone-with-gutter-and-footer-no-orphan-prevention ---
|
|
||||||
#set page(height: 5.5em)
|
|
||||||
#table(
|
|
||||||
gutter: 4pt,
|
|
||||||
table.header(
|
|
||||||
[L1]
|
|
||||||
),
|
|
||||||
table.header(
|
|
||||||
level: 2,
|
|
||||||
[L2]
|
|
||||||
),
|
|
||||||
table.footer(
|
|
||||||
[a],
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user