Skip to content

Missing ability to clear explicit paragraph/run formatting #274

Description

@lightinmirror

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

  1. Build document structure with batch (explicit formatting on every paragraph)
  2. Establish design specs (styles, type scale, spacing)
  3. Update style definitions
  4. 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)

  1. Clear size on a paragraph with explicit sizing → get output no longer shows size=11pt; effective size comes from the style
  2. Clear a key that has no explicit value → no-op, not an error
  3. Works on runs directly (/body/p[1]/r[1])
  4. batch with clear commands → atomic semantics
  5. Round-trip: clear then set the same key → explicit value restored

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions