Skip to content

fix: force box-mode rendering for left-only paragraph borders (#61)#62

Merged
forest6511 merged 1 commit into
mainfrom
feature/h3-border-space-fix
Mar 15, 2026
Merged

fix: force box-mode rendering for left-only paragraph borders (#61)#62
forest6511 merged 1 commit into
mainfrom
feature/h3-border-space-fix

Conversation

@forest6511
Copy link
Copy Markdown
Owner

Problem

When BorderPosition: "left" is used on headings, Word anchors the left border at the paragraph's indent position (flush with the text). The BorderSpace attribute controls vertical extent only, not horizontal gap. As a result, the border line touches the text with zero visible gap regardless of LeftIndent.

Root Cause

Word uses two rendering modes for w:pBdr:

  • Single-side mode (only left defined): border anchored at ind.left — flush with text
  • Box mode (all four sides defined): border anchored at page content edge (position 0) — ind.left becomes the visible gap

Quote blocks work correctly because they define all four sides, triggering box mode.

Fix

In CreateBordersFromPositions(), when only left is specified, add BorderValues.Nil borders for top, bottom, and right. This forces Word into box-mode rendering, making LeftIndent produce a visible gap between the border line and the text.

Tests

Three new unit tests added:

  • AddHeading_WithLeftBorderOnly_ShouldAddNilBordersForBoxMode
  • AddHeading_WithAllFourBorders_ShouldNotAddNilBorders
  • AddHeading_WithBottomBorderOnly_ShouldNotAddNilBorders

Result

279 → 282 tests, all passing.

Closes #61

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
Copy link
Copy Markdown

codecov Bot commented Mar 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.21%. Comparing base (6c54a95) to head (a6df348).
⚠️ Report is 2 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@forest6511 forest6511 merged commit c92d362 into main Mar 15, 2026
3 checks passed
@forest6511 forest6511 deleted the feature/h3-border-space-fix branch March 15, 2026 23:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

H3 left border has no gap between border line and text (w:pBdr left border positioning)

1 participant