Repository navigation
fix: writer honours lineSpacingRule, allCaps and smallCaps - #4
Merged
dskripchenko merged 2 commits intoOct 20, 2026
Merged
dskripchenko merged 2 commits into
dskripchenko merged 2 commits into
Conversation
The writer wrote w:lineRule="exact" for every line spacing and never read lineSpacingRule. The reader sets the rule (auto when the attribute is missing, per the schema default), so read -> write turned Word's 1.15 spacing (line=276 auto) into a fixed 13.8pt line height. auto, exact and atLeast are now written as given. An unset or unknown rule stays exact, so callers that set only lineSpacingTwips (the builder's spacing(line:), the HTML converter) get the same output as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RunStyle::$allCaps and $smallCaps were parsed by the reader and serialized to HTML (text-transform / font-variant), but the writer never emitted them, so a read -> write round-trip lost the formatting. Both are written in their CT_RPr position, after i/iCs and before strike. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 20, 2026
Merged
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.
Summary
Two commits, each separable (each passes the full suite on its own):
fix: emit w:lineRule from ParagraphStyle::$lineSpacingRule: the writer wrotew:lineRule="exact"for every line spacing. It now writesauto,exactoratLeastas the style says. An unset or unknown rule still writesexact.fix: emit w:caps and w:smallCaps for RunStyle:RunStyle::$allCapsand$smallCapswere never written to DOCX.No API changes. Both are model fields that already existed and that the reader already fills in; only the writer ignored them.
Motivation
Both show up on a plain read → write round-trip through the library itself:
OoxmlPropertyParserstores the rule next tow:line(autowhen the attribute is missing, the schema default), and the HTML serializer already treats a missing rule asauto. The writer was the one place that ignored it. Word's default 1.15 spacing (<w:spacing w:line="276" w:lineRule="auto"/>) came back asw:line="276" w:lineRule="exact", a fixed 13.8 pt line height, so any text larger than about 11 pt was clipped at the top.<w:caps/>/<w:smallCaps/>and the serializer writestext-transform: uppercase/font-variant: small-caps, but a heading set in small caps came back from read → write in plain lowercase.Notes
lineSpacingRule = nullwritesexact, as before.DocumentBuilder'sspacing(line: ...)and the HTML converter'sline-height(both set onlylineSpacingTwips) produce the same bytes as today.<w:caps/>and<w:smallCaps/>go afteri/iCsand beforestrike, their position inEG_RPrBase.w:rProrder: the existing order (ubeforestrike,vertAlignbeforecolor) does not match the orderEG_RPrBaselists its elements in, but the Transitional schema inscripts/conformancedeclaresEG_RPrBaseas an unboundedxsd:choice, so any order validates. I left it alone. Happy to send a reorder separately if you'd like it to match the Strict ordering.scripts/conformance/xsd-check.sh.styles.xml) line spacing and caps.StylesXmlBuilderwrites neither yet; that is a separate change. The HTML converter also does not parsetext-transform/font-variantback intoRunStyle.Tests
composer install && vendor/bin/phpunit: OK (408 tests, 1027 assertions); before: OK (398 tests, 1009 assertions). After each commit: 405, 408, all OK.composer stan: no errors.tests/Writer/LineSpacingRuleTest.php: each rule is written as given, unset/unknown writeexact, and a DOCX withline="276" lineRule="auto"(and with nolineRule) comes back from read → write asauto. The round-trip cases fail onmain.tests/Writer/CapsTest.php: emission, position afteriCsand beforestrike, and write → read.🤖 Generated with Claude Code