Skip to content

feat(ppt-codec): read and write a paragraph's spacing and margins - #914

Merged
Mearman merged 3 commits into
mainfrom
feat/ppt-paragraph-spacing-margins
Sep 4, 2026
Merged

feat(ppt-codec): read and write a paragraph's spacing and margins#914
Mearman merged 3 commits into
mainfrom
feat/ppt-paragraph-spacing-margins

Conversation

@Mearman

@Mearman Mearman commented Sep 4, 2026

Copy link
Copy Markdown
Member

Part of #817.

Adds line spacing, spacing before/after, left margin, and first-line indent to ppt-codec's TextPFException read/write path, alongside the alignment field it already handled. Every optional field now reads and writes in the spec's declared order (masks, then textAlignment, lineSpacing, spaceBefore, spaceAfter, leftMargin, indent) — confirmed directly against the MS-PPT TextPFException specification page.

ParaSpacing has two mutually exclusive forms (percentage-of-line-height, or absolute master-units); document-schema.js's lineSpacing/spacingBeforePt/spacingAfterPt fields can each only express one form, so a paragraph stating the other form reports no value for that field rather than a wrong one. MarginOrIndent has no such ambiguity and converts cleanly in both directions, including a hanging (negative) first-line indent.

Verified via this package's own independent reader (write → read → equality) and against LibreOffice: line spacing, paragraph spacing, and left margin all convert correctly through LibreOffice's own pptx/odp export. The one exception, documented in the README, is the first-line/hanging indent — LibreOffice's own .ppt import does not recover it correctly, while this package's reader does; the byte layout was independently confirmed against the specification, so the discrepancy sits in LibreOffice's own import path rather than in the bytes written here.

TextPFException carries lineSpacing, spaceBefore, spaceAfter, leftMargin, and indent alongside
the alignment field this package already handled; every optional field now reads and writes in
the spec's declared order (masks, then textAlignment, lineSpacing, spaceBefore, spaceAfter,
leftMargin, indent).

ParaSpacing has two mutually exclusive forms: a non-negative percentage-of-line-height value, or
a negative absolute master-units value. document-schema.js's lineSpacing (a line-height
multiplier) can only express the percentage form; spacingBeforePt/spacingAfterPt (plain points)
can only express the absolute form. A paragraph stating the other form of either field reports no
value for it rather than a wrong one.

MarginOrIndent has no such ambiguity: leftMargin and indent are always absolute master-unit
offsets, converting cleanly to indentLeftPt/indentFirstLinePt in both directions, including a
negative (hanging) first-line indent.
…h-property fixtures

Adds coverage for both ParaSpacing forms (percentage-of-line-height and absolute master-units)
on lineSpacing/spaceBefore/spaceAfter, for MarginOrIndent conversion including a hanging indent,
and a whole-file writePptContent/readPptContent round trip carrying all five new fields together.

Widening ParagraphProperties left every hand-built paragraph-run fixture across content.test.ts
and text/style-write.test.ts missing the five new fields; extracted a shared pfProps() helper in
each file rather than repeating the same five undefined fields at every call site.
…ritten

Moves lineSpacing/spaceBefore/spaceAfter/leftMargin/indent from the read/write gap lists into
the reader/writer's own formatting rows, notes which ParaSpacing form each schema field can and
cannot express, and records LibreOffice verification for line spacing, paragraph spacing, and
left margin.

LibreOffice's own .ppt import does not recover indentFirstLinePt: this package's independent,
specification-only reader recovers the written value exactly, and the field's byte order was
separately confirmed against the MS-PPT TextPFException specification, so the discrepancy is
noted as LibreOffice's own import behaviour rather than left unstated.
@Mearman
Mearman marked this pull request as ready for review September 4, 2026 13:27
@Mearman
Mearman merged commit f1fe832 into main Sep 4, 2026
17 checks passed
@Mearman
Mearman deleted the feat/ppt-paragraph-spacing-margins branch September 4, 2026 13:27
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 4, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
🔒 Security Review Completed 2026-09-04T13:31:07.915074Z 9983730 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 1.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant