Keep chapter content from dropping out of the PDF - #35
Merged
Conversation
The forced page break on `section + section` did not just pad a subsection out to a full page. When a nav section groups several pages, mkdocs-with-pdf emits one article of stacked `section` elements, and the forced break silently dropped everything after each section's first paragraph: a 22-row table, a 14-item list, an admonition and an 18-row table were all absent from the rendered PDF. Relaxing the break restores them. Splitting the rules apart, `min-height` is not involved -- `page-break-before: always` is the whole cause. Relax `break-inside` only. The inherited `break-before: avoid` is what keeps a table or list attached to the sentence or bold-only label that introduces it, so clearing it stranded those labels at the foot of a page. Bordered containers keep `break-inside: avoid`, because an admonition split across a page boundary renders as an open box with no left or right edge. Guards on the first and last two list items and table rows keep a split from stranding a lone item, and `orphans`/`widows` bound the same case for prose and code. No `!important` is needed: nothing these rules compete with carries it. `styles/pdf.css` forbade the fragmentation `pdf/styles.scss` now allows, so browser print and PDF export broke a page at different points. Both files now describe the same behaviour. A PDF build exiting 0 was never evidence the chapter was in it, which is how the dropped content went unnoticed: both samples are a single page, so the `section + section` path is taken by nothing in the repository. `pdf-test.sh` gains a nav-grouped fixture and reads the rendered pages back with pdftotext, asserting that a subsection's table, list and admonition all arrive, that a top-level chapter still starts on its own page, that a subsection is no longer padded onto one, that a bold-only label keeps the first items of its list, and that a split table leaves at least two rows behind. The check fails against the previous stylesheet. Closes #11 Co-Authored-By: jinjoolee07 <jinjoolee07@gmail.com>
sehkone
force-pushed
the
sehkone/issue-11
branch
from
August 8, 2026 02:05
d267f43 to
5392414
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.
Supersedes #12, rebased onto
mainand carried the rest of the way. Squashed into one commit, withjinjoolee07credited as co-author for the original work.What #12 found, and what it turns out to be
The forced page break
mkdocs-with-pdfputs onsection + sectiondoes more than pad a subsection out to a full page. When a nav section groups several pages, the plugin emits one article of stackedsectionelements, and the forced break silently drops everything after each section's first paragraph from the render.Built against a nav-grouped fixture,
mainproduces a 5-page PDF in which a 22-row table, a 14-item list, an admonition and an 18-row table are all simply absent. With the break relaxed, the same document renders 7 pages with the content intact.This never showed up because both samples are a single page, so
mkdocs-with-pdfreportsConverting 1 articlesand thesection + sectionpath is never taken.Isolated by rule:
section + sectionmainas-ismin-height: autoonlybreak-before: autoonlySo the culprit is
page-break-before: always, notmin-height.Changes on top of #12
Relax
break-insideonly. #12 also clearedbreak-before, but that is the declaration keeping a table or list attached to the sentence — or the bold-only label — that introduces it. Clearing it left labels such as**Key inputs**stranded at the foot of a page, which is one of the symptoms #11 lists.Keep bordered containers whole. Under #12 as written, an admonition splits across a page boundary and renders as an open box with no left or right edge — the title bar and an empty half-box at the foot of one page, the body with no border on the next.
div.admonitionanddiv.tabbed-content--wrapkeepbreak-inside: avoid.Guard against lone items. Allowing a list or table to split introduces a new case: a break right after the first item, or right before the last. Guards on the first and last two list items and table rows forbid exactly those two positions, and
orphans/widowsbound the same case for prose and code.Drop
!important. Nothing it was competing with is!important, andarticle:not(#doc-cover):not(#doc-toc) …already outspecifies both the plugin's_paging.scssandstyles/pdf.css. Verified: these rules win without it.Align
styles/pdf.css. It forbade the fragmentationpdf/styles.scssnow allows, so browser print and PDF export broke a page at different points. The README documents that file as the PDF print guardrails, so it is aligned rather than removed.Regression coverage
A build exiting 0 is not evidence the chapter is in the PDF — that is exactly how this bug stayed invisible.
tests/pdf-test.shgains a nav-grouped fixture whose markers are read back out of the rendered pages withpdftotext, asserting that:Confirmed as a real control, not just a passing test: run against
main's stylesheet the suite exits 1 onnot ok - a subsection's list: 'option-omega' is missing, and on this branch all 22 checks pass.Verification
manual,api-reference×en,ko)mainsamples/manualmarkdownlint-cli2CHANGELOG
#12's entry predated the move to area-grouped headings, and rebasing it produced a second
## [Unreleased]section below the real one, under the abandoned### Changedheading, plus an[Unreleased]:link this file deliberately does not carry — all without a merge conflict. It is rewritten under## Unreleasedin### manualand### api-reference, wrapped to 80 columns, whichmainnow enforces sinceMD013: falsewas dropped.Closes #11