Skip to content

feat: support paragraph between borders (w:pBdr/w:between)#2324

Open
caio-pizzol wants to merge 10 commits intomainfrom
caio/refactor-paragraph-borders-rendering
Open

feat: support paragraph between borders (w:pBdr/w:between)#2324
caio-pizzol wants to merge 10 commits intomainfrom
caio/refactor-paragraph-borders-rendering

Conversation

@caio-pizzol
Copy link
Contributor

No description provided.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 70de4d7213

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@caio-pizzol caio-pizzol force-pushed the caio/refactor-paragraph-borders-rendering branch from 70de4d7 to 4110a37 Compare March 7, 2026 18:49
gpardhivvarma and others added 4 commits March 7, 2026 16:01
Flow `w:between` borders through the rendering pipeline so consecutive
paragraphs sharing the same border definition display a horizontal
separator line between them.

- Add `between` to `ParagraphBorders` contract type
- Include `between` in `normalizeParagraphBorders` side iteration
- Add `bw:` segment to `hashParagraphBorders` in both hash util files
- Add `computeBetweenBorderFlags` to pre-compute which fragments need
  the between border, following the `computeSdtBoundaries` pattern
- Render between border as CSS `border-bottom` on decoration overlay
- Handle header/footer sections, page splits, and patch invalidation
- Add 55+ tests covering edge cases
Cover the patch path in renderer.ts where a fragment switches in/out of
a between-border group, verifying the DOM node is rebuilt when the
betweenBorderMismatch flag flips.
Extract paragraph border rendering into feature module at
features/paragraph-borders/ with improved between-border support.

- BetweenBorderInfo type replaces boolean flag, carrying gap extension
  and top suppression data per fragment
- Border layers extend into spacing gaps for continuous group borders
- Top borders suppressed for non-first group members
- nil/none between borders no longer form groups
- Feature registry maps OOXML elements to rendering modules
@caio-pizzol caio-pizzol force-pushed the caio/refactor-paragraph-borders-rendering branch from 4110a37 to 80eff63 Compare March 7, 2026 19:01
- Extract getFragmentHeight from renderer.ts, reuse from group-analysis
- Extract stampBetweenBorderDataset helper for consistent dataset stamping
- Move BlockLookup types to single source of truth in types.ts
- Add column break guard (frag.x !== next.x) to prevent cross-column grouping
- Add tests for suppressTopBorder, gap extension, and column breaks
- 16 tests for indent-aware border box sizing (left, right, firstLine,
  hanging, NaN/Infinity clamping, combined indents)
- Remove orphaned between-borders-comprehensive.docx from test-data/
Word groups consecutive paragraphs with matching borders into a single
bordered box even when w:between is nil/none — it just omits the
separator. SuperDoc was skipping grouping entirely for nil/none between,
rendering each paragraph as a separate bordered box.

- Preserve between: {style: 'none'} during normalization so downstream
  can distinguish "explicitly nil/none" from "no between element"
- Change grouping check to allow nil/none between through
- Add suppressBottomBorder flag for nil/none groups (extend gap without
  drawing a separator)
The OOXML `space` attribute on w:pBdr sides specifies the distance
between the border line and the paragraph text (in points). Word uses
this to create visible padding inside bordered paragraphs.

- Add computeBorderSpaceExpansion() to convert space values to px
- Expand the border/shading layers outward by the space amount
- Suppress top/bottom space within between-border groups where those
  sides are already handled by gap extension
With box-sizing: border-box, CSS borders are drawn inside the element.
The border layer must expand by space + borderWidth (not just space) so
the border's inner edge sits at the correct distance from text. The
shading layer only needs space expansion since it has no CSS borders.
The between border was flush against the next paragraph's text. Now:
- First paragraph reduces gap extension by between.space, positioning
  the between border higher in the spacing gap
- Second paragraph extends upward by between.space to maintain
  continuous left/right borders through the gap
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants