fix: force box-mode rendering for left-only paragraph borders (#61)#62
Merged
Conversation
When only a left border is specified in w:pBdr, Word anchors the border at the paragraph indent position (flush with text), ignoring BorderSpace as a horizontal gap. Adding Nil borders for the unspecified sides forces Word into box-mode rendering, which anchors the left border at the page content area edge so that LeftIndent creates a visible gap between the border line and the text. Add three unit tests covering: - left-only border produces Nil on top/bottom/right (box-mode forced) - all-four borders remain Single (no Nil added) - bottom-only border produces no Nil borders (box-mode not triggered)
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #62 +/- ##
==========================================
+ Coverage 94.08% 94.21% +0.12%
==========================================
Files 25 25
Lines 1201 1209 +8
Branches 138 142 +4
==========================================
+ Hits 1130 1139 +9
+ Misses 42 41 -1
Partials 29 29 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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
When
BorderPosition: "left"is used on headings, Word anchors the left border at the paragraph's indent position (flush with the text). TheBorderSpaceattribute controls vertical extent only, not horizontal gap. As a result, the border line touches the text with zero visible gap regardless ofLeftIndent.Root Cause
Word uses two rendering modes for
w:pBdr:leftdefined): border anchored atind.left— flush with textind.leftbecomes the visible gapQuote blocks work correctly because they define all four sides, triggering box mode.
Fix
In
CreateBordersFromPositions(), when onlyleftis specified, addBorderValues.Nilborders fortop,bottom, andright. This forces Word into box-mode rendering, makingLeftIndentproduce a visible gap between the border line and the text.Tests
Three new unit tests added:
AddHeading_WithLeftBorderOnly_ShouldAddNilBordersForBoxModeAddHeading_WithAllFourBorders_ShouldNotAddNilBordersAddHeading_WithBottomBorderOnly_ShouldNotAddNilBordersResult
279 → 282 tests, all passing.
Closes #61