diff options
| author | PgBiel <9021226+PgBiel@users.noreply.github.com> | 2025-05-16 20:01:17 -0300 |
|---|---|---|
| committer | PgBiel <9021226+PgBiel@users.noreply.github.com> | 2025-06-28 22:39:35 -0300 |
| commit | 5292c5b198aaf39f6666fd9164d7fa2e1653b495 (patch) | |
| tree | bf1faf23255817b6820a9b9e3704fb9c20aa6c41 | |
| parent | cce5fe739a0d476b6d54ae7cd9385a2313eb639e (diff) | |
update html code for multiple footers
todo: test
| -rw-r--r-- | crates/typst-library/src/model/table.rs | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/crates/typst-library/src/model/table.rs b/crates/typst-library/src/model/table.rs index dcc77b0d..367d3e66 100644 --- a/crates/typst-library/src/model/table.rs +++ b/crates/typst-library/src/model/table.rs @@ -292,12 +292,33 @@ fn show_cellgrid_html(grid: CellGrid, styles: StyleChain) -> Content { elem(tag::tr, Content::sequence(row)) }; - // TODO(subfooters): similarly to headers, take consecutive footers from - // the end for 'tfoot'. - let footer = grid.footer.map(|ft| { - let rows = rows.drain(ft.start..); - elem(tag::tfoot, Content::sequence(rows.map(|row| tr(tag::td, row)))) - }); + // Store all consecutive headers at the start in 'tfoot'. All remaining + // headers are just normal rows across the table body. (There doesn't + // appear to be an equivalent of 'th' for footers in HTML.) + // TODO: test + let footer = { + let mut consecutive_footer_start = grid.footers.len(); + let footers_at_end = grid + .footers + .iter() + .rev() + .take_while(|ft| { + let is_consecutive = ft.end == consecutive_footer_start; + consecutive_footer_start = ft.start; + + is_consecutive + }) + .count(); + + if footers_at_end > 0 { + let last_mid_table_footer = grid.footers.len() - footers_at_end; + let rows = rows.drain(last_mid_table_footer..); + + Some(elem(tag::tfoot, Content::sequence(rows.map(|row| tr(tag::td, row))))) + } else { + None + } + }; // Store all consecutive headers at the start in 'thead'. All remaining // headers are just 'th' rows across the table body. |
