unset: clear explicit paragraph/run formatting to restore style inheritance
Summary
set --prop key=value writes explicit formatting onto paragraphs and runs — but there is no inverse: no way to clear an explicit property so the element falls back to style or document-default inheritance.
We hit this building a 26-page math-modeling paper with 70+ body paragraphs. Every paragraph was created via batch with size=11pt, indent=24pt, spaceAfter=6pt. Later we redefined Normal style to size=12pt, lineSpacing=23pt, firstLineIndent=480. The style change had no visible effect — every paragraph's explicit formatting masked the style.
The only workaround is per-paragraph set overwrites or raw XML surgery. set --prop size="" throws a validation error. No unset / clear / inherit verb exists.
Environment
- OfficeCLI: MCP-resident (
main), Windows 11, PowerShell 5.1
- Agent: deepseek-v4-pro in opencode
Reproduction
officecli create repro.docx
officecli add repro.docx /body --type paragraph \
--prop text="Should inherit style size" \
--prop size=11pt --prop indent=24pt
officecli set repro.docx /styles/Normal \
--prop size=12pt --prop lineSpacing=23pt --prop firstLineIndent=480
# Paragraph STILL shows size=11pt, indent=24pt
officecli get repro.docx "/body/p[1]" --depth 1
# → paragraph "..." size=11pt indent=24pt
# The style DID change
officecli get repro.docx /styles/Normal
# → style Normal size=12pt lineSpacing=23pt firstLineIndent=24pt
# Attempting to "unset" fails
officecli set repro.docx "/body/p[1]" --prop size=""
# → Error: Invalid font size: ''. Expected a finite number (e.g., '12', '10.5', '14pt').
OOXML root cause
Word's style cascade is docDefaults < style < paragraph-explicit < run-explicit. When add emits w:rPr/w:sz w:val="22" (11pt) on the run, that explicit tier always wins over the style definition.
The corresponding XML nodes that need to be removed for inheritance to take effect:
| Prop |
Node to remove |
size |
w:rPr/w:sz on each child run |
indent |
w:pPr/w:ind |
spaceAfter |
w:pPr/w:spacing (or w:after attr) |
bold / color / etc. |
w:rPr/w:b, w:rPr/w:color, ... |
Today the only way to delete these is raw-set — not practical for batch-built documents.
Real-world timeline
- Build document structure with
batch (explicit formatting on every paragraph)
- Establish design specs (styles, type scale, spacing)
- Update style definitions
- Cannot make existing paragraphs adopt the new styles
Our concrete case: after step 3, every one of 70+ body paragraphs still rendered at 11pt with block indent — the style redefinition was fully invisible. We also had equation paragraphs (oMathPara) inheriting lineSpacing=23pt from Normal, which compressed the equation display. Each equation paragraph had to be individually set to lineSpacing=1x.
Validation proposal (if a fix lands)
- Clear
size on a paragraph with explicit sizing → get output no longer shows size=11pt; effective size comes from the style
- Clear a key that has no explicit value → no-op, not an error
- Works on runs directly (
/body/p[1]/r[1])
batch with clear commands → atomic semantics
- Round-trip: clear then
set the same key → explicit value restored
unset: clear explicit paragraph/run formatting to restore style inheritance
Summary
set --prop key=valuewrites explicit formatting onto paragraphs and runs — but there is no inverse: no way to clear an explicit property so the element falls back to style or document-default inheritance.We hit this building a 26-page math-modeling paper with 70+ body paragraphs. Every paragraph was created via
batchwithsize=11pt, indent=24pt, spaceAfter=6pt. Later we redefinedNormalstyle tosize=12pt, lineSpacing=23pt, firstLineIndent=480. The style change had no visible effect — every paragraph's explicit formatting masked the style.The only workaround is per-paragraph
setoverwrites or raw XML surgery.set --prop size=""throws a validation error. Nounset/clear/inheritverb exists.Environment
main), Windows 11, PowerShell 5.1Reproduction
OOXML root cause
Word's style cascade is
docDefaults < style < paragraph-explicit < run-explicit. Whenaddemitsw:rPr/w:sz w:val="22"(11pt) on the run, that explicit tier always wins over the style definition.The corresponding XML nodes that need to be removed for inheritance to take effect:
sizew:rPr/w:szon each child runindentw:pPr/w:indspaceAfterw:pPr/w:spacing(orw:afterattr)bold/color/ etc.w:rPr/w:b,w:rPr/w:color, ...Today the only way to delete these is
raw-set— not practical for batch-built documents.Real-world timeline
batch(explicit formatting on every paragraph)Our concrete case: after step 3, every one of 70+ body paragraphs still rendered at 11pt with block indent — the style redefinition was fully invisible. We also had equation paragraphs (
oMathPara) inheritinglineSpacing=23ptfrom Normal, which compressed the equation display. Each equation paragraph had to be individuallysettolineSpacing=1x.Validation proposal (if a fix lands)
sizeon a paragraph with explicit sizing →getoutput no longer showssize=11pt; effective size comes from the style/body/p[1]/r[1])batchwith clear commands → atomic semanticssetthe same key → explicit value restored