Tables are a useful way describe things in a single glance, particularly qunatifiable things. Though they don't work as well auditorily as they do visually, so I'm giving them extra interactivity in Rhapsode.

I've recently described how Rich handles them and how Weasyprint computes their size ranges, so now I'll finish describing with how it lays out tables!

(For Hephaestus I'll probably lower them to "display: grid" then treat those the same... Weasyprint doesn't support "display: grid")


Weasyprint starts by initializing it's layout parameters & computing the x-position of each of the table columns. These positions are reversed for right-to-left text. Then skips requested children for pagination.

Then comes the question: Do I render the table header/footer on this PDF page?

To answer that we need to size them up, ignoring them if they overflow the PDF page, then checks for "break-inside: avoid[-page]". Then sees if any rows fit.


To layout the header & footer, it starts by retrieving the layout parameters resolving any percentages, then for any non-skipped children:

1. Checks for any elements queued up for a page break.
2. Resolve percentage sizes.
3. Iterate over the cells in the row.
a) Compute x position & size from column size table.
b) Layout out it's internal children.
6. Retrieves vertical alignment.
7. Computes row height skipping "colspan".
8. Applies that height, determining whether to page break.


To layout each of the remaining (non-skipped for pagination) rows, Weasyprint:

1. Skips header & footer rows.
2. Checks CSS-requested pagebreaks.
3. Applies the same approach for header/footer rows.
4. Breaks page if that requests it, or tries finding an earlier page break.
5. Updates loop variables.


Once that bulk of the work is done, it asks did we manage to lay anything out on this page or should we pagebreak?

Then positions remaining stylable elements.


This whole algorithm requires the row/column sizes to have already been computed. I described how that was done yesterday, though there's additional refinements & a simpler algorithm for backwards compatibility slow dialup networks. This routine are called when the other layout algorithm require a width.

Then there's the trickiness of "baseline" vertical alignment... And expanding to fill excess whitespace...

5/5 Fin. Done with Weasyprint, though I am curious about Pyphen! Next: Pango, etc.

@alcinnz Just wanted to say it's really interesting reading your research and thoughts about accessibility. I have friends who work as.. whatever you call it, like transcribers maybe? Subtitles on the fly for TV stuff/streams and in person. I'll probably do some of that in the future. It's so important.

@human_equivalent That it is!

You're welcome. I'm glad there's people enjoying my technology dives!

Sign in to participate in the conversation
Eldritch Café

Une instance se voulant accueillante pour les personnes queers, féministes et anarchistes ainsi que pour leurs sympathisant·e·s. Nous sommes principalement francophones, mais vous êtes les bienvenu·e·s quelle que soit votre langue.

A welcoming instance for queer, feminist and anarchist people as well as their sympathizers. We are mainly French-speaking people, but you are welcome whatever your language might be.