Repository navigation
fix: write one w:pBdr for a paragraph with both border and thematicBreak - #3935
yschoi9733 wants to merge 1 commit into
Conversation
A paragraph with both options got a w:pBdr from each, and CT_PPrBase has one, so the Open XML SDK validator rejects the document. The same went for paragraph styles, and for htmlToContent with an <hr> in a <div> with a border. The thematic break's line is now written in the w:pBdr of border, in place of its bottom, as Word reads the two elements: ThematicBreak extends Border and takes the paragraph's other borders. The layout module, which read only the first w:pBdr, now gives the line its room, as Word does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3935 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 576 576
Lines 27894 27892 -2
Branches 10204 10205 +1
=========================================
- Hits 27894 27892 -2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
A paragraph with both
borderandthematicBreakgot aw:pBdrfrom each:CT_PPrBasehas onepBdr(line 1099 ofooxml-schemas/ISO-IEC29500-4_2016/wml.xsd), so the Open XML SDK validator that the Demos workflow runs rejects the document for every Office version from 2010 to Microsoft 365: "The element has unexpected child element ... pBdr". A paragraph style with both options gets the same two elements instyles.xml, and so doeshtmlToContentfor an<hr>in a<div>with a border, as the<hr>'s paragraph takes the box'sborderandthematicBreak.Changes
ParagraphPropertieswrites onew:pBdrwhen both are set:border's sides, with the thematic break's line as the bottom border, in place ofborder.bottomif there is one.ThematicBreakextendsBorderand takes the paragraph's other borders as an optional argument, anOmit<IBordersOptions, "bottom">. Without it, it writes what it wrote before.borderandThematicBreak, and the Thematic Break section ofdocs/usage/paragraph.md, say how the two go together, and that ofthematicBreaksays the line is the paragraph's bottom border.Why the line takes the place of
border.bottomThat's how Word reads the two
w:pBdrdocx wrote: as one, with the sides of the first and the bottom of the second in place of the first one's. Word for Mac 16.115.1 draws a paragraph with red top, left and right borders andthematicBreakas a red box with a black bottom line. It draws one with a red top, a blue doubleborder.bottomandthematicBreakwith the red top and the black line, and no blue line. So this change keeps what Word shows: I exported five test documents to PDF from Word before and after the change, and each one's first page is the same, pixel for pixel. If you'd ratherborder.bottomwon, it's a small change inThematicBreak.Layout
readParagraphFormatreads only the firstw:pBdr, so the layout module left out the thematic break's line under a paragraph with a border. With a top border andthematicBreakon every other paragraph of the layout tests' 80-line probe, it put 48 lines on the first page. Word puts 45 there, as with top and bottom borders, and so does the layout module now: the test of top and bottom borders checks that case too.For an
<hr>in a<div>with a border, that means the layout module, like Word before and after this change, gives the<hr>'s paragraph a box of its own, as its bottom border isn't the same as those of the paragraphs beside it. Before, it kept the<hr>'s paragraph in one box with the paragraphs beside it, and left out the line. This PR doesn't change howhtmlToContentconverts an<hr>.Checked
npm run test:ci(coverage stays at 100%),npm run lint,npm run prettier,npm run cspellandnpm run check-api(no breaking changes against 9.16.0) pass.borderwithout a bottom andthematicBreak, one withborder.bottomandthematicBreak, a paragraph style with both andhtmlToContentof an<hr>in a<div>with a border fail before the change and pass after it. A fifth document, with a paragraph with onlythematicBreakand one with onlyborder, passes before and after, with the samedocument.xml. The five demos that set a paragraph'sthematicBreakorborderpass after the change.properties.tstoo, in other lines, and each applies to this branch without conflicts.🤖 Generated with Claude Code
Summary by CodeRabbit