Skip to content

feat: section columns and column break - #12

Open
serpentblade wants to merge 2 commits into
dskripchenko:mainfrom
serpentblade:feat/section-columns
Open

serpentblade wants to merge 2 commits into
dskripchenko:mainfrom
serpentblade:feat/section-columns

Conversation

@serpentblade

Copy link
Copy Markdown
Contributor

Summary

Adds text columns to sections and a column break element, both written to and read back from OOXML.

Commits

  1. feat: section columns
    • New Style\Columns value: count, spaceTwips (default 720), separator, and for unequal columns widthsTwips (one per column) and spacesTwips (one per gap). The constructor validates counts and signs.
    • Section::$columns (?Columns, null is a single column), written by Word2007Writer as <w:cols> after <w:pgMar> and before <w:titlePg> (ECMA-376 order). Equal: <w:cols w:num w:space [w:sep="1"]/>. Unequal: <w:cols w:num w:equalWidth="0" [w:sep="1"]> with one <w:col w:w w:space/> per column, the last without w:space.
    • SectionReader::columns() reads it back per section.
    • DocumentBuilder::columns() sets the current section's columns; newSection() takes a columns argument (a new section is single-column unless given them).
    • A bare <w:cols w:space="720"/> (what Word writes in ordinary documents) reads as no columns (null), not a one-column Columns. w:space is always written, also for unequal columns.
    • Conformance reference document: its landscape section now has two unequal columns with a separator.
    • README (Sections) and the ru/de/zh translations, CHANGELOG (new Unreleased section).
  2. feat: column break
    • New Element\ColumnBreak block, written as <w:p><w:r><w:br w:type="column"/></w:r></w:p>.
    • BodyReader reads <w:br w:type="column"/> and splits the paragraph around it, as it does for a page break (also dropped from list items, like a page break).
    • Builder columnBreak().
    • PHPStan baseline: two new entries and one reworded, mirroring the existing PageBreak entries in BodyReader (the inline/block mismatch).
    • Conformance reference document: a column break between the two columns.
    • README, ru/de/zh translations, CHANGELOG.

The HTML serializer has no column concept and renders ColumnBreak as nothing.

Tests

New tests/Writer/SectionColumnsTest.php (writer output for equal, unequal and separator cases, element order, per-section columns, round trips through DocxReader, argument validation, column break round trip), plus cases in SectionsBuilderTest, BodyXmlBuilderTest and BodyReaderTest. Full suite: 512 tests passing. composer stan: no errors. The conformance reference document validates against the ECMA-376 XSDs (xsd-check.sh, all six parts) and passes the LibreOffice and python-docx consumer smoke.

🤖 Generated with Claude Code

serpentblade and others added 2 commits November 1, 2026 21:55
Section::$columns (Columns: count, space, separator, and per-column widths
and per-gap spaces for unequal columns) is written as <w:cols> after
<w:pgMar> in the section's <w:sectPr> and read back by SectionReader.
DocumentBuilder::columns() sets the current section's columns, and
newSection() takes them too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ColumnBreak is written as <w:p><w:r><w:br w:type="column"/></w:r></w:p>
and read back by BodyReader, which splits a paragraph around it as it
does for a page break. The builder gets columnBreak(). The PHPStan
baseline gains the same inline/block mismatch entries PageBreak already
has in BodyReader.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant