Skip to content

Commit cb9540b

Browse files
committed
Correctly detect empty split lines at the end of tables
The previous detection was failing when some cells were empty (or fully rendered) and when the current rendering position was not overflowing the page. In this case, the line with empty cells was rendered and was visible for example when cells had padding.
1 parent 3bd9a8e commit cb9540b

File tree

2 files changed

+42
-11
lines changed

2 files changed

+42
-11
lines changed

tests/draw/test_table.py

+37
Original file line numberDiff line numberDiff line change
@@ -1198,3 +1198,40 @@ def test_tables_20(assert_pixels):
11981198
<col></col><col></col>
11991199
<tbody><tr></tr><tr><td></td></tr></tbody>
12001200
<tfoot></tfoot>''')
1201+
1202+
1203+
@assert_no_logs
1204+
def test_tables_21(assert_pixels):
1205+
assert_pixels('''
1206+
_________________________
1207+
_rrrrrrrrrrrrrrrrrrrrrrr_
1208+
_rBBBBBBBBBBrBBBBBBBBBBr_
1209+
_rBKKKKKKBBBrBKKKKKKBBBr_
1210+
_rBKKKKKKBBBrBKKKKKKBBBr_
1211+
_rBBBBBBBBBBrBBBBBBBBBBr_
1212+
_rrrrrrrrrrrrrrrrrrrrrrr_
1213+
_________________________
1214+
_________________________
1215+
_________________________
1216+
_________________________
1217+
_________________________
1218+
_rrrrrrrrrrrrrrrrrrrrrrr_
1219+
_rBBBBBBBBBBrBBBBBBBBBBr_
1220+
_rBKKKKKKBBBrBBBBBBBBBBr_
1221+
_rBKKKKKKBBBrBBBBBBBBBBr_
1222+
_rBBBBBBBBBBrBBBBBBBBBBr_
1223+
_rrrrrrrrrrrrrrrrrrrrrrr_
1224+
_________________________
1225+
_________________________
1226+
_________________________
1227+
_________________________
1228+
''', '''
1229+
<style>
1230+
@font-face { src: url(weasyprint.otf); font-family: weasyprint }
1231+
@page { size: 25px 11px; margin: 1px }
1232+
table { border-collapse: collapse; font: 2px weasyprint; width: 100% }
1233+
td { background: blue; padding: 1px; border: 1px solid red }
1234+
</style>
1235+
<table>
1236+
<tr><td>abc</td><td>abc</td></tr>
1237+
<tr><td>abc</td><td></td></tr>''')

weasyprint/layout/table.py

+5-11
Original file line numberDiff line numberDiff line change
@@ -272,17 +272,11 @@ def group_layout(group, position_y, bottom_space, page_is_empty,
272272
# Break if one cell was broken
273273
break_cell = False
274274
if resume_at:
275-
values, = list(resume_at.values())
276-
if len(row.children) == len(values):
277-
for cell_resume_at in values.values():
278-
if cell_resume_at != {0: None}:
279-
break_cell = True
280-
break
281-
else:
282-
# No cell was displayed, give up row
283-
next_position_y = inf
284-
page_is_empty = False
285-
resume_at = None
275+
if all(child.empty for child in row.children):
276+
# No cell was displayed, give up row
277+
next_position_y = inf
278+
page_is_empty = False
279+
resume_at = None
286280
else:
287281
break_cell = True
288282

0 commit comments

Comments
 (0)