Repository navigation
fix(html): write page size, margins and tab advances in exact points (#1153) - #1161
Merged
Merged
Conversation
…1153) The @page size and margin, tab span widths, a line break's leading margin and tab segment widths were CSS inches rounded to hundredths or thousandths, so A4 came out a quarter point short and a 1417-twip stop became 0.98in. They are now written in points from the exact twip value, and tab advances are carried at six decimals of an inch internally. Existing assertions that pinned the inch strings now expect points.
…'s own width (#1153) Tab segment widths add several advances carried at six decimals of an inch, which could leave 70.8499pt for a 1417-twip stop; they now round back to the twip. The half-inch fallback for a tab past the last stop wrote 720 inches. Three default-tab-stop tests now read the tab span's own declarations, since the segment that wraps it prints the same width.
This was referenced Oct 16, 2026
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.
Closes #1153
First of a three-PR stack: this one (#1153), then #1154 on top of it, then #1155 on top of that. All three touch the HTML converter, so they are stacked to keep them from conflicting.
Why
The converter wrote a few lengths as CSS inches rounded to hundredths (a 0.72pt step). A4 paper (
11906 × 16838twips) came out as8.27in 11.69in, about a quarter point short, and a tab stop at 1417 twips came out as0.98ininstead of 70.85pt. #1128 and #1121 already removed this rounding from paragraph indents and row heights; these sites were left.How it works
@pagesize and margin (the single rule and the per-section named rules) are written with the converter's existingPointsCssformatter from the exact point values:size: 595.3pt 841.9pt.pt:TabWidthannotation, in inches. That annotation was itself rounded to 0.001in, so even a points formatter could not be exact. It now keeps six decimals, and the CSS writer rounds back to the whole twip. That rounding matters for the tab "segment" boxes, which add several advances together: without it,Aplus a tab to 1417 twips came out as70.8499pt.720in an attribute measured in inches (the comment says "put 1/2 inch in"). It is now half an inch.Nothing in C#, npm, the export package, Python or MCP parses these CSS values or the inch strings; the PDF export writes its own
@pagefrom PageMap points (#1138). Out of scope and unchanged: the paginator's page-geometrydata-*attributes still carry 0.1pt.Validation
PageAndTabLengthPrecisionTests: A4 size and margins in continuous and paginated@pagerules, named per-section rules, a plain and a leader tab to a 1417-twip stop, a line break's margin, and a segment after one glyph. All fail onmain. Reverting only the six-decimal annotation makes the three tab tests fail, and reverting only the twip rounding makes the segment test fail.HtmlConversionOpsTestsHCO058–060, HCO076–078, HCO088–090 and one more;HtmlConverterTestsHC052, HC053 and HC055, plus one tab assertion;FeatureVerificationTestsFV001 and FV099;TabAfterWrappingTextTests; and thePaginatedHeaderFooterContentTestssegment-width helper. HCO058–060 now read the tab span's own declarations. In points the tab span and the segment that wraps it print the same width, so a search of the whole page could no longer tell them apart.TrackedRangeDeletion_ScalesWithTheRange, a timing-scaled session test, while three suites ran at once; it passes alone. The 1,007 converter, border and tab tests pass at the top of the stack. The Release library build has no warnings. The Playwright tab-geometry specs run in CI.Adversarial review
One round of hostile review ran on this diff before opening. It found:
70.8499pt), now fixed;data-*attributes), now narrowed.It checked every other edited assertion by mutation, and it confirmed no consumer parses the changed values.