Skip to content

test(html): pin physical paragraph borders on right-to-left paragraphs (#1154) - #1162

Merged
JSv4 merged 2 commits into
mainfrom
fix/issue-1154
Oct 16, 2026
Merged

JSv4 merged 2 commits into
mainfrom
fix/issue-1154

Conversation

@JSv4

@JSv4 JSv4 commented Oct 16, 2026

Copy link
Copy Markdown
Owner

Closes #1154

Second of a three-PR stack: #1161 (#1153), then this one, then #1155's PR. It is based on #1161's branch and will be retargeted to main when #1161 merges.

Why

#1147 mirrored the indents of right-to-left (w:bidi) bordered paragraphs, because Word reads w:ind's w:left/w:right on such a paragraph as start/end. The issue asked whether w:pBdr's w:left/w:right should be mirrored the same way, and said to verify before changing anything.

What I found

They should not be mirrored, and Docxodus already draws them correctly, so this PR changes no behaviour.

  • The standard is explicit. ISO/IEC 29500-1, quoted in the Open XML SDK's LeftBorder and RightBorder remarks, says the left paragraph border "shall be displayed on the left side of the page around the specified paragraph. This shall not change based on the paragraph direction". It says the same of the right border. The only swap it documents is the w:swapBordersFacingPages compatibility setting, which applies on odd-numbered pages of documents that also use mirrored margins and different even/odd headers.
  • LibreOffice agrees. LibreOffice 25.8.7.3 draws the issue's fixture (a thick double w:left, a thin single w:right, w:bidi, start=1440 end=360) with the double border on the left and the start indent mirrored to the right.
  • Not yet measured in Word. A Word reference PDF for that fixture would settle it. The corner-case table leaves that row open.

What changes

  • New RightToLeftParagraphBorderTests pin the behaviour. The borders keep their physical sides in both directions, and in a mirrored box each margin subtracts the width and spacing of the border physically on that side. A mutation that mirrors the borders for bidi paragraphs fails two of them.
  • A comment in CreateBorderDivs says why the sides are physical.
  • docs/ooxml_corner_cases.md records the spec text, the reproducer, and a spec / LibreOffice / Docxodus / Word table.
  • No CHANGELOG entry, because behaviour is unchanged.

Adversarial review

One round of hostile review ran before opening. It confirmed the spec quote and the LibreOffice render independently, and it checked that the tests fail if the borders are mirrored. Its two doc nits are fixed in the second commit. The table had said the spec was silent on w:right, but the RightBorder remarks say the same thing. The paraphrase of the facing-pages condition is replaced with the spec's actual conditions.

#1154)

The standard says a paragraph's left border is drawn on the left of the
page whatever the paragraph's direction, and LibreOffice draws it there.
Docxodus already did; pin it with tests that fail if the borders mirror,
and record the finding in the corner-case notes.
@JSv4
JSv4 merged commit 5248bf4 into main Oct 16, 2026
17 checks passed
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.

Right-to-left paragraphs draw w:pBdr left/right borders on their physical sides

1 participant