Track changes (revisions) support for python-docx: read, write and manipulate <w:ins> and <w:del> elements
Project description
Python Tracked Changes Library - docx-revisions
Read and write track changes in Word documents (.docx) with Python. docx-revisions extends python-docx to support document revision tracking, change tracking, and OOXML revision markup (insertions <w:ins> and deletions <w:del>) so you can programmatically accept text, list revisions with author and date, and apply insertions, deletions, or replacements with full revision metadata.
Use it for Microsoft Word-compatible revision tracking: parse DOCX files with track changes on, get accepted (clean) text, enumerate revisions per paragraph, or write new revisions (insert/delete/replace) that show up as track changes in Word.
Installation
pip install docx-revisions
Quick Start
Check out our examples!
Navigate to the examples directory to see code samples.
Read tracked changes
from docx_revisions import RevisionDocument
rdoc = RevisionDocument("tracked_changes.docx")
for para in rdoc.paragraphs:
if para.has_track_changes:
for change in para.track_changes:
print(f"{type(change).__name__}: '{change.text}' by {change.author}")
print(f"Accepted: {para.accepted_text}")
print(f"Original: {para.original_text}")
Accept or reject all changes
from docx_revisions import RevisionDocument
rdoc = RevisionDocument("tracked_changes.docx")
rdoc.accept_all() # or rdoc.reject_all()
rdoc.save("clean.docx")
Find and replace with tracking
from docx_revisions import RevisionDocument
rdoc = RevisionDocument("contract.docx")
count = rdoc.find_and_replace_tracked("Acme Corp", "NewCo Inc", author="Legal")
print(f"Replaced {count} occurrences")
rdoc.save("contract_revised.docx")
Add tracked insertions and deletions
from docx_revisions import RevisionParagraph
rp = RevisionParagraph.from_paragraph(paragraph)
rp.add_tracked_insertion("new text", author="Editor")
rp.add_tracked_deletion(start=5, end=10, author="Editor")
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file docx_revisions-0.1.5.tar.gz.
File metadata
- Download URL: docx_revisions-0.1.5.tar.gz
- Upload date:
- Size: 324.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b567eb521d8bc51eb87fe5b94227cf5a8f28fdbf97b18d3e58d393652fdac793
|
|
| MD5 |
2749b864482be379ae15e5716c95e641
|
|
| BLAKE2b-256 |
bafd4ef9a41a2ed36399a81598cb4a534bb73c782410615871cbcc03ee2e2cc2
|
Provenance
The following attestation bundles were made for docx_revisions-0.1.5.tar.gz:
Publisher:
release.yml on balalofernandez/docx-revisions
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
docx_revisions-0.1.5.tar.gz -
Subject digest:
b567eb521d8bc51eb87fe5b94227cf5a8f28fdbf97b18d3e58d393652fdac793 - Sigstore transparency entry: 1297353107
- Sigstore integration time:
-
Permalink:
balalofernandez/docx-revisions@8bda70c9b68f2533802e637443a65ab7f4f88470 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/balalofernandez
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@8bda70c9b68f2533802e637443a65ab7f4f88470 -
Trigger Event:
push
-
Statement type:
File details
Details for the file docx_revisions-0.1.5-py3-none-any.whl.
File metadata
- Download URL: docx_revisions-0.1.5-py3-none-any.whl
- Upload date:
- Size: 18.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1f369c5eabbaea450c8214c6ad9de66514e65ff517c6d74db6a15da7c1c8b790
|
|
| MD5 |
07a598671fee3b9bf2603ed8993ecfbf
|
|
| BLAKE2b-256 |
49f8d425260cade4d519f32bb3822dbcc01c9e7dc94b22dbeb742f4f5578a468
|
Provenance
The following attestation bundles were made for docx_revisions-0.1.5-py3-none-any.whl:
Publisher:
release.yml on balalofernandez/docx-revisions
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
docx_revisions-0.1.5-py3-none-any.whl -
Subject digest:
1f369c5eabbaea450c8214c6ad9de66514e65ff517c6d74db6a15da7c1c8b790 - Sigstore transparency entry: 1297353195
- Sigstore integration time:
-
Permalink:
balalofernandez/docx-revisions@8bda70c9b68f2533802e637443a65ab7f4f88470 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/balalofernandez
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@8bda70c9b68f2533802e637443a65ab7f4f88470 -
Trigger Event:
push
-
Statement type: