Fix text clipping and paragraph spacing in paginated rendering#117
Merged
Conversation
…cing (#114) Three root causes addressed: 1. lineRule default: when w:lineRule is absent but w:line is present, now defaults to "auto" per OOXML spec (ISO/IEC 29500). Previously the line value was silently ignored, causing accumulated line-height mismatches that clipped the last line on pages. 2. contextualSpacing: now suppresses both spacingAfter (margin-bottom) AND spacingBefore (margin-top) for consecutive same-style paragraphs. Previously only spacingAfter was suppressed, leaving incorrect inter-paragraph gaps where Word shows zero spacing. 3. Pagination engine: the last block's bottom margin is no longer counted against available page space since it's invisible (clipped by overflow:hidden). This prevents premature page breaks. https://claude.ai/code/session_01VoQ3xgQrJ1H1xe9t76GeoT
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.
Summary
This PR fixes three related issues affecting paginated rendering that caused text to be clipped at page bottoms and inconsistent paragraph spacing:
lineRuledefault handling per OOXML spec (ISO/IEC 29500)Key Changes
WmlToHtmlConverter.cs
suppressLeadingWhiteSpaceparameter toConvertToHtmlTransform(),ProcessParagraph(),ConvertParagraph(),DefineParagraphStyle(), andCreateStyleFromSpacing()methods to enable suppression of leading whitespace in paragraphsCreateStyleFromSpacing()to:spacingBeforeto 0 whensuppressLeadingWhiteSpaceis truelineRuledefault: whenw:lineRuleattribute is absent butw:lineis present, treat as "auto" per OOXML spec (previously the line value was ignored)GroupAndVerticallySpaceNumberedParagraphs()to:contextualSpacingto note it's handled viaGroupAndVerticallySpaceNumberedParagraphspagination.ts
block.marginBottomPtfromblockSpacecalculation since the last block's bottom margin extends beyond the content area and is clipped byoverflow: hiddenkeepWithNextlogic to exclude bottom margin from the next block's space calculationremainingHeightfor correct margin collapsing with subsequent blocksCHANGELOG.md
Implementation Details
The contextual spacing fix leverages the existing grouping mechanism in
GroupAndVerticallySpaceNumberedParagraphs()which already groups paragraphs by style. The newsuppressLeadingWhiteSpaceparameter threads through the conversion pipeline to suppressmargin-topat the CSS level for non-first paragraphs in contextual groups, while the existingsuppressTrailingWhiteSpaceparameter handlesmargin-bottomfor non-last paragraphs.The pagination fix recognizes that in a paginated layout with
overflow: hidden, the last block's bottom margin is invisible and should not count against available page space, preventing unnecessary page breaks when content would actually be visible.https://claude.ai/code/session_01VoQ3xgQrJ1H1xe9t76GeoT