diff --git a/tests/draw/test_table.py b/tests/draw/test_table.py
index 166c0618b0..99ee46c9a3 100644
--- a/tests/draw/test_table.py
+++ b/tests/draw/test_table.py
@@ -1176,3 +1176,25 @@ def test_tables_18():
td { border: 1px red solid; padding: 1px; line-height: 1; }
a a a a |
''')
+
+
+@assert_no_logs
+def test_tables_19():
+ # Regression test: https://github.com/Kozea/WeasyPrint/issues/1523
+ assert_pixels('table_split_crash', 2, 8, '''
+ RR
+ RR
+ RR
+ RR
+ RR
+ RR
+ RR
+ RR
+ ''', '''
+
+ ''')
diff --git a/weasyprint/layout/table.py b/weasyprint/layout/table.py
index b28e7890d6..223510e62a 100644
--- a/weasyprint/layout/table.py
+++ b/weasyprint/layout/table.py
@@ -261,14 +261,13 @@ def group_layout(group, position_y, bottom_space, page_is_empty,
next_position_y += border_spacing_y
# Break if one cell was broken
+ break_cell = False
if resume_at:
values, = list(resume_at.values())
if len(row.children) == len(values):
for cell_resume_at in values.values():
if cell_resume_at != {0: None}:
- new_group_children.append(row)
- if table.style['border_collapse'] == 'collapse':
- table.skip_cell_border_bottom = True
+ break_cell = True
break
else:
# No cell was displayed, give up row
@@ -276,10 +275,7 @@ def group_layout(group, position_y, bottom_space, page_is_empty,
page_is_empty = False
resume_at = None
else:
- new_group_children.append(row)
- if table.style['border_collapse'] == 'collapse':
- table.skip_cell_border_bottom = True
- break
+ break_cell = True
# Break if this row overflows the page, unless there is no
# other content on the page.
@@ -308,7 +304,10 @@ def group_layout(group, position_y, bottom_space, page_is_empty,
page_is_empty = False
skip_stack = None
- if resume_at:
+ if break_cell and table.style['border_collapse'] == 'collapse':
+ table.skip_cell_border_bottom = True
+
+ if break_cell or resume_at:
break
# Do not keep the row group if we made a page break