fix(print): flex-fallback grids with a grid-heading for WeasyPrint#2
Open
ntheanh201 wants to merge 1 commit into
Open
fix(print): flex-fallback grids with a grid-heading for WeasyPrint#2ntheanh201 wants to merge 1 commit into
ntheanh201 wants to merge 1 commit into
Conversation
WeasyPrint mis-sizes 1fr grid tracks when a full-width spanning grid-heading (grid-column: 1 / -1) is present, collapsing sibling cards to near-zero width — metric/ecosystem layouts render as narrow columns with text wrapping one character per line in the PDF. Fall back to flexbox for .grid:has(> .grid-heading) in @media print only; grids without a grid-heading keep the CSS grid path, and screen rendering is unchanged. Signed-off-by: The Anh Nguyen <ntheanh201@gmail.com>
ntheanh201
force-pushed
the
fix/print-grid-heading-weasyprint
branch
from
July 24, 2026 02:08
622544f to
7f951f4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
In PDF (WeasyPrint) output, any slide with a
::: gridthat contains a::: card {grid-heading}renders broken: the spanning heading (grid-column: 1 / -1) makes WeasyPrint mis-size the1frtracks, so the sibling metric/content cards collapse to ~0 width and text wraps one character per line. Browsers render the same markup correctly, so it only shows in the PDF.This hits the metric/ecosystem layouts (e.g. a community-stats slide:
grid {cols=5}with a grid-heading + metric cards).Fix
In
@media printonly, fall back to flexbox for.grid:has(> .grid-heading): the grid-heading spans a full row (flex: 0 0 100%) and sibling cards share the next row equally. Grids without a grid-heading keep the CSS-grid path, and screen rendering is unchanged.Test
Added a regression guard in
tests/test_html.pyasserting the print stylesheet contains the flex fallback. Verified by rendering an affected slide to PDF before/after (collapsed columns → proper metric cards).