Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix height of rows with no drawn cells being ignored #107

Merged
merged 3 commits into from
Dec 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/common.typ
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
int(0 <= x) - int(x < 0)
}

// Polyfill for array sum (.sum() is Typst 0.3.0+).
#let array-sum(arr, zero: 0) = {
arr.fold(zero, (a, x) => a + x)
}

// get the types of things so we can compare with them
// (0.2.0-0.7.0: they're strings; 0.8.0+: they're proper types)
#let _array-type = type(())
Expand Down
6 changes: 1 addition & 5 deletions src/renderer/old.typ
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,10 @@
let first-y = none
let rightmost-x = none

let row-heights = 0pt
let row-heights = array-sum(rows.slice(start-y, end-y + 1), zero: 0pt)

let first-row = true
for row in group-rows {
if row.len() > 0 {
let first-cell = row.at(0)
row-heights += rows.at(first-cell.cell.y)
}
for cell-box in row {
let x = cell-box.cell.x
let y = cell-box.cell.y
Expand Down
46 changes: 46 additions & 0 deletions tablex-test.typ
Original file line number Diff line number Diff line change
Expand Up @@ -1040,3 +1040,49 @@ Combining em and pt (with a stroke object):
vlinex(expand: -(2% + 2pt + 2em)),
)
)

*Full-width rowspans displayed with the wrong height (Issue \#105)*

#tablex(
columns: (auto, auto, auto, auto),
colspanx(4, rowspanx(3)[ONE]),
[TWO], [THREE], [FOUR], [FIVE],
)

#block(breakable: false)[
a

#tablex(
columns: 3,
colspanx(3, rowspanx(2)[a])
)

b
]

*More overlapping rowspans (Issue \#82)*

#tablex(
auto-lines: false,
stroke: 1pt,
columns: (auto,auto,auto,auto),
align:center,
//hlinex(),
//vlinex(), vlinex(), vlinex(),vlinex(),
[Name], [He],[Rack],[Beschreibung],
hlinex(),
cellx(rowspan:2,align:center)["mt01"], cellx(fill: rgb("#b9edffff"), align: left,rowspan:2)[42],
cellx(rowspan:2,align:center)["WAT"],
//hlinex(),
cellx(rowspan:2,align:center)["Löschgasflasche"],
cellx(rowspan:2,align:center)["mt2"], cellx(fill: rgb("#b9edffff"), align: left,rowspan:2)[41],
cellx(rowspan:2,align:center)["WAT"],"test",
(""),"","","","",
cellx(rowspan:2,align:center)["mt3"], cellx(fill: rgb("#b9edffff"), align: left,rowspan:2)[40],
cellx(rowspan:2,align:center)["WAT"],"test",
"","","","","",
cellx(rowspan:2,align:center)["mt3"], cellx(fill: rgb("#b9edffff"), align: left,rowspan:2)[40],
cellx(rowspan:2,align:center)["WAT"],"test",
"","","","","",

)