Fix export to pdf#161
Open
roniaxe wants to merge 2 commits into
Open
Conversation
added 2 commits
May 21, 2026 08:54
The exported PDF previously had three issues: - The first few characters of the first line were hidden behind the top-fade-mask gradient overlay. - The TOC overlay, TOC toggle button, and find bar (if open) were visible in the exported PDF. - Long lines inside code blocks were trimmed at the right edge because .viewer-content kept overflow: hidden during print, and the invalid `word-break: break-word` did not actually wrap long tokens. Extend the @media print block in styles.css to hide the overlays, release overflow on .viewer-content, and replace the bad word-break rule with overflow-wrap: anywhere on pre / pre code.
Reduce content getting split unnaturally across pages in the exported PDF: - Headings get `break-after: avoid` so they no longer get stranded at the bottom of a page with their content on the next. - Code blocks, blockquotes, tables, figures, images, mermaid diagrams, and KaTeX displays get `break-inside: avoid` so they stay on one page when they fit. - Paragraphs and list items use `orphans: 3; widows: 3;` so prose can still split across pages but never with only one or two stranded lines at the top or bottom. Note: blocks taller than a single page will still split (the browser ignores break-inside in that case), but this fixes the common "first line of a paragraph alone at the bottom" pattern.
Owner
|
looks good! is it ready to merge/did all the tests pass? |
Author
|
@alecdotdev yes, it's ready and tests passes. it's all css changes. |
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.
Fixes #158
Summary
they no longer appear in the exported PDF or mask leading characters.
word-break: break-wordwithoverflow-wrap: anywhere.orphans/widowsandbreak-inside: avoidrules so paragraphs,headings, code blocks, and other block elements don't break across
pages in ugly ways.
Test plan