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

Cell split over table boundary causes error with border-collapse: collapse #1523

Closed
aschmitz opened this issue Dec 13, 2021 · 2 comments
Closed
Labels
crash Problems preventing documents from being rendered
Milestone

Comments

@aschmitz
Copy link
Contributor

aschmitz commented Dec 13, 2021

In WeasyPrint 54.0b1, rendering the following HTML gives an error:

<style>
  table {
    border-collapse: collapse;
  }
</style>

<div style="height: 24cm"></div>

<table><tr><td>
  a<br>
  a<br>
  a<br>
  a
</td></tr></table>

(You may have to adjust the height of the spacing div to force the table to split over the page boundary depending on your font.)

The error is an IndexError: list index out of range on line 856 of draw.py, as it tries to index in to vertical_borders past its length. It appears as though build.py's collapse_table_borders returns one more horizontal border than there are columns, but only as many vertical borders as there are rows.

I can fix the error by changing line 889 of draw.py to for y in range(grid_height - 1):, but I suspect the correct behavior may be to extend the output of collapse_table_borders for an additional row.

@aschmitz
Copy link
Contributor Author

It appears adding this to your CSS is a temporary fix to revert back to the "pages can't split in the middle of a row" behavior from versions prior to 54:

td, th {
  break-inside: avoid;
}

(In particular, it appears as though tables breaking over the edge of a page are still not a problem, just rows.)

@liZe liZe added the crash Problems preventing documents from being rendered label Dec 18, 2021
@liZe liZe added this to the 54.0 milestone Dec 18, 2021
@liZe liZe closed this as completed in 8d2c549 Dec 20, 2021
@liZe
Copy link
Member

liZe commented Dec 20, 2021

Thanks a lot for the bug report.

It’s now fixed, with many other use cases of tables with collapsed cells.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crash Problems preventing documents from being rendered
Projects
None yet
Development

No branches or pull requests

2 participants