feat(ppt-codec): read and write a paragraph's spacing and margins - #914
Merged
Conversation
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.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Contributor
|
🎉 This PR is included in version 1.1.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #817.
Adds line spacing, spacing before/after, left margin, and first-line indent to ppt-codec's
TextPFExceptionread/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/spacingAfterPtfields 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
.pptimport 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.