paper-docxAPI referenceblocks
docx.blocks
paper-docx 0.2.0 API reference
Anchor-relative block operations and clause-level redlines (paper-docx).
Operations here compose whole paragraphs: insert a section after an anchor, tracked-delete a paragraph range, tracked-replace a range. The load-bearing safety rule (kept from the battle-tested reference): every selected paragraph must share one parent element — selections that would span story regions, table boundaries, or content-control boundaries are refused loudly.
Improvements over the reference helpers:
- Tracked deletion moves the paragraph's own runs into
w:del, retaggingw:t->w:delTextin place, so every run keeps itsrPrand a later reject restores the original exactly (the reference collapsed formatting into one run). - Tracked insert/delete also stamp the paragraph MARK (
w:pPr/w:rPr/w:insor/w:del), so accepting a deletion removes the paragraph instead of leaving an empty husk, and rejecting an insertion removes the inserted paragraph entirely.
BlockTarget
attributeBlockTarget= Union[str, Block, Span]