docx_plus.revisions.accept¶
Resolve revision marks into final text. Accepting keeps the recorded edit;
rejecting restores the pre-edit state. Run-level insertions and deletions
are handled fully (insertion accept = unwrap, deletion accept = remove, and
the inverses on reject, restoring <w:delText> to live <w:t>). Move and
property-change marks get a safe, non-structural transform; the one
structural case — a paragraph-mark deletion implies a paragraph merge —
ships a non-corrupting fallback that drops the mark and leaves the text
intact (true merge/split is deferred).
The *_all forms process revisions innermost-first so nested marks resolve
before their containers, and are idempotent on a clean document.
docx_plus.revisions.accept ¶
Accept or reject tracked changes — resolve revision marks into final text.
Accepting a revision keeps the edit it records; rejecting restores the pre-edit state. The transform differs per element type:
================ ========================== ===========================
Element Accept Reject
================ ========================== ===========================
w:ins unwrap (keep runs) remove (drop element+runs)
w:del remove unwrap + w:delText→w:t
w:moveFrom remove unwrap (+ retag)
w:moveTo unwrap remove
move markers remove remove
w:rPrChange remove marker restore recorded old w:rPr
w:pPrChange remove marker restore recorded old w:pPr
para-mark ins/del remove mark (safe) remove mark (safe)
================ ========================== ===========================
Run-level insertions and deletions are handled fully. Move and property-change marks get the safe, non-structural transform above. The one genuinely structural case — accepting a paragraph-mark deletion should merge two paragraphs — ships a non-corrupting fallback (the mark is removed, the text is left intact) rather than attempting the merge; true merge/split is deferred (ROADMAP v0.3+).
This module imports only from docx_plus.core and the sibling
docx_plus.revisions.mark (SPEC §9.1).
accept_revision ¶
Accept the revision(s) with revision_id, keeping the recorded edit.
Locates every body element carrying @w:id == revision_id and applies
the per-type accept transform. To fully resolve a move (whose wrapper
and range markers carry distinct ids) prefer
:func:accept_all_revisions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
doc
|
Document
|
The python-docx :class: |
required |
revision_id
|
int
|
The |
required |
Raises:
| Type | Description |
|---|---|
RevisionNotFoundError
|
If no revision element carries |
Source code in docx_plus/revisions/accept.py
reject_revision ¶
Reject the revision(s) with revision_id, restoring the prior state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
doc
|
Document
|
The python-docx :class: |
required |
revision_id
|
int
|
The |
required |
Raises:
| Type | Description |
|---|---|
RevisionNotFoundError
|
If no revision element carries |
Source code in docx_plus/revisions/accept.py
accept_all_revisions ¶
Accept every tracked change in doc.
Idempotent: a document with no revisions is left unchanged. Revisions are processed innermost-first so a nested revision is resolved before its container.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
doc
|
Document
|
The python-docx :class: |
required |
Source code in docx_plus/revisions/accept.py
reject_all_revisions ¶
Reject every tracked change in doc, restoring the pre-edit text.
Idempotent. Revisions are processed innermost-first.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
doc
|
Document
|
The python-docx :class: |
required |