Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ['3.9', '3.11', '3.12']
python-version: ['3.11', '3.12', '3.13', '3.14']

steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Python-Redlines generates `.docx` redline/tracked-changes documents by comparing
Two comparison engines are available:
- **XmlPowerToolsEngine** — wraps Open-XML-PowerTools WmlComparer (original engine).
Deprecated as of 1.0.0: instantiating it emits a `DeprecationWarning`. Still published.
- **DocxodusEngine** — wraps Docxodus v14.1.0, a modernized .NET 10.0 fork with better move detection.
- **DocxodusEngine** — wraps Docxodus v17.0.0, a modernized .NET 10.0 fork with better move detection.
Runs `DocxDiff`, its only algorithm — Docxodus v11.0.0 deleted `WmlComparer`.

## Monorepo structure — three published packages
Expand Down
66 changes: 62 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ with open("redline.docx", "wb") as f:
That's the whole thing. The rest of this README covers the other engines, comparison
settings, and how the packages are built and distributed.

Version 2.0.0 bundles Docxodus v14.1.0. Its comparison output can differ from
1.0.0; see [Upgrading to 2.0.0](#upgrading-to-200) before updating an existing deployment.
Version 3.0.0 bundles Docxodus v17.0.0. Its comparison output can differ from
2.0.0; see [Upgrading to 3.0.0](#upgrading-to-300) before updating an existing deployment.

### ⚠️ Breaking in 1.0.0: `WmlComparer` is gone; DocxDiff is the only algorithm

Expand Down Expand Up @@ -167,7 +167,7 @@ argument raises `ValueError`.
### 1. `DocxodusEngine` — the default

**[Docxodus](https://github.com/JSv4/Docxodus)** is an actively-maintained .NET 10.0 document
toolchain. Python-Redlines 2.0.0 bundles Docxodus v14.1.0. Its `DocxDiff` algorithm
toolchain. Python-Redlines 3.0.0 bundles Docxodus v17.0.0. Its `DocxDiff` algorithm
models the document as an intermediate representation rather than a stream of runs,
which lets it attribute a change to the exact paragraph, cell, row, or section it touched:

Expand Down Expand Up @@ -266,13 +266,31 @@ redline_bytes, stdout, stderr = engine.run_redline(
| `detect_moves` | bool | `False` | Enable move detection |
| `move_similarity_threshold` | float | `0.8` | Jaccard threshold for move matching (0.0–1.0) |
| `move_minimum_word_count` | int | `3` | Minimum words for move detection |
| `minimum_anchor_word_count` | int | `0` | Words a paragraph needs before it is used to line the two documents up; see [Numbered entries](#numbered-entries) |
| `detect_format_changes` | bool | `True` | Detect block-level formatting changes |
| `conflate_spaces` | bool | `True` | Treat breaking/non-breaking spaces the same |
| `date_time` | str | now | Custom ISO 8601 timestamp for revisions |

Anything else raises `ValueError`, including a misspelled setting name. Passing a setting to
`XmlPowerToolsEngine` is still silently ignored — it has never accepted any.

### Numbered entries

Some documents put a short label on its own line before each entry: "P1", then the entry's
text, then "P2", and so on. Adding or removing an entry changes every later label, and the
comparison can then report the entries' unchanged text as moved. Setting
`minimum_anchor_word_count=2` (new in 3.0.0) makes it match the entries by their text
instead, so each label just shows its number changing:

```python
redline_bytes, stdout, stderr = engine.run_redline(
"Reviewer", original, modified,
minimum_anchor_word_count=2,
)
```

Leave it at the default, `0`, for other documents. It must be a non-negative integer.

### Settings removed in 1.0.0

| Setting | Why it is gone |
Expand All @@ -288,6 +306,46 @@ The 0.3.0-era warning that `detect_moves=True` needed `simplify_move_markup=True
"unreadable content" dialog applied to `WmlComparer`'s move markup. It does not apply here —
`DocxDiff` emits move markup natively and has no such mitigation, because it needs none.

## Upgrading to 3.0.0

3.0.0 bundles Docxodus v17.0.0, up from v14.1.0. The major version makes the change in
comparison output an explicit upgrade. Every existing call and setting still works; one
setting is new.

1. **Use Python 3.11 or newer.** Python 3.9 and 3.10 have reached end of life; 2.0.0 was the
last release to support them. CI covers 3.11 to 3.14.
2. **Install the matching wrapper and engine through the extra:**

```bash
pip install --upgrade 'python-redlines[docxodus]==3.0.0'
```

Update lockfiles or separately pinned companions to 3.0.0 as well.
3. **Review representative redlines and refresh output snapshots.** The project's fixture
still reports 10 revisions, but other documents can differ:
- When only a field's displayed text changes, such as a cross-reference going from 16.4 to
21.8, just that text is marked. A field in its short form (`w:fldSimple`) used to mark the
whole paragraph as deleted and re-inserted.
- Formatting changes inside table cells, and on paragraph marks, are now tracked. They were
silently left untracked, so revision counts can rise on documents whose text is unchanged.
`detect_format_changes=False` suppresses the paragraph-mark revisions but not run
formatting in cells, which it has never suppressed in body text either.
- A phrase replaced in a paragraph containing a tab or line break is one deletion and one
insertion rather than a run of one-word edits.
- Docxodus also reports changes to heavily rewritten paragraphs, moves among edited
paragraphs, content controls in tables, headers and footers around section breaks,
comments, notes and text boxes. See its
[changelog](https://github.com/JSv4/Docxodus/blob/v17.0.0/CHANGELOG.md) for 14.2.0–17.0.0.
4. **Expect a refusal for very deeply nested documents.** XML nested more than 128 elements
deep in a story or definition part (the body, headers, notes, styles and so on), or more
than 256 in any other part, now raises `EngineExecutionError` with
`xml_depth_limit_exceeded` in the message. Docxodus says real documents nest a few dozen
levels at most. Packages past its size or compression-ratio limits are refused too.
5. **Consider `minimum_anchor_word_count=2`** if your documents number their entries on
separate lines; see [Numbered entries](#numbered-entries). It needs the 3.0.0 engine.

If upgrading from 1.0.0 or earlier, also review the migration notes below, but use 3.0.0 for their installation commands and companion version pins.

## Upgrading to 2.0.0

2.0.0 bundles Docxodus v14.1.0. The major version makes the change in comparison
Expand Down Expand Up @@ -424,7 +482,7 @@ engine — no Word installation, no TOS risk. See

### Prerequisites

- Python 3.9+
- Python 3.11+
- .NET 10.0 SDK (only for building the engine binaries locally). Install with
`apt install dotnet-sdk-10.0`, or `curl -sSL https://dot.net/v1/dotnet-install.sh | bash -s -- --channel 10.0`.
A .NET 8 SDK can no longer build the Docxodus engine, which targets `net10.0`.
Expand Down
2 changes: 1 addition & 1 deletion docs/developer-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Prerequisites

- Python 3.9 or higher
- Python 3.11 or higher
- .NET 10.0 SDK (to compile the C# engine binaries). The Docxodus engine targets
`net10.0`; the Open-XML-PowerTools engine still targets `net8.0` and the .NET 10 SDK
builds both.
Expand Down
4 changes: 2 additions & 2 deletions docs/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ algorithm they configured — see

### See also

- [Upgrading to 2.0.0](https://github.com/JSv4/Python-Redlines#upgrading-to-200) —
engine output changes, matching companion packages and error reporting
- [Upgrading to 3.0.0](https://github.com/JSv4/Python-Redlines#upgrading-to-300) —
engine output changes, a new comparison setting and refused documents
- [How to compare two Word documents programmatically in Python](tutorials/how-to-compare-word-documents-python.md) —
a step-by-step tutorial covering this same flow in more depth
- [Live demo](https://redlines.opensource.legal) — try a comparison in your browser
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorials/how-to-compare-word-documents-python.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ openable and reviewable in Microsoft Word, LibreOffice, or Google Docs.

## Prerequisites

- Python 3.9+
- Python 3.11+
- Two `.docx` files to compare (any two versions of the same Word document)

No Microsoft Word installation, no COM automation, and no .NET SDK are required — the
Expand Down
2 changes: 1 addition & 1 deletion docxodus
Submodule docxodus updated 962 files
8 changes: 5 additions & 3 deletions packages/core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,12 @@ version as the wrapper. For older releases, pin both packages explicitly (for
example, `python-redlines[docxodus]==0.3.0` and
`python-redlines-docxodus==0.3.0`). Existing published metadata is unchanged.

2.0.0 bundles Docxodus v14.1.0. Python call signatures and supported settings
are unchanged from 1.0.0, but comparison markup and revision granularity can differ.
3.0.0 bundles Docxodus v17.0.0 and adds one setting, `minimum_anchor_word_count`.
Existing call signatures and settings are unchanged from 2.0.0, but comparison markup
and revision counts can differ, and some very deeply nested documents are now refused.
It requires Python 3.11 or newer; 2.0.0 was the last release to support 3.9 and 3.10.
Review representative redlines when upgrading; see the
[2.0.0 migration guide](https://github.com/JSv4/Python-Redlines#upgrading-to-200).
[3.0.0 migration guide](https://github.com/JSv4/Python-Redlines#upgrading-to-300).

An unsuccessful engine exit raises `EngineExecutionError`, a subclass of
`subprocess.CalledProcessError`. Its message includes the captured stderr and
Expand Down
8 changes: 4 additions & 4 deletions packages/core/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ build-backend = "hatchling.build"
[project]
name = "python-redlines"
dynamic = ["version", "optional-dependencies"]
description = "Open-source DOCX comparison tool to generate native Word tracked changes (redlines) in Python without MS Word dependencies."
description = "Open-source DOCX comparison tool, powered by the Docxodus engine, to generate native Word tracked changes (redlines) in Python without MS Word dependencies."
readme = "README.md"
requires-python = ">=3.9"
requires-python = ">=3.11"
license = "MIT"
keywords = [
"docx",
Expand All @@ -30,10 +30,10 @@ classifiers = [
"Development Status :: 5 - Production/Stable",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Programming Language :: Python :: Implementation :: CPython",
]
dependencies = [
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/python_redlines/__about__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2024-present U.N. Owen <void@some.where>
#
# SPDX-License-Identifier: MIT
__version__ = "2.0.0"
__version__ = "3.0.0"
16 changes: 12 additions & 4 deletions packages/core/src/python_redlines/engines.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,11 @@ def run_redline(self, author_tag: str, original: Union[str, bytes, Path], modifi

Additional keyword arguments are passed to _build_command() for engine-specific
options. DocxodusEngine supports: case_insensitive, detect_moves,
move_similarity_threshold, move_minimum_word_count, detect_format_changes,
conflate_spaces, date_time. It raises ValueError for unrecognised settings and
for the WmlComparer-era settings removed in Docxodus v11.0.0 (engine,
detail_threshold, simplify_move_markup). XmlPowerToolsEngine ignores kwargs.
move_similarity_threshold, move_minimum_word_count, minimum_anchor_word_count,
detect_format_changes, conflate_spaces, date_time. It raises ValueError for
unrecognised settings and for the WmlComparer-era settings removed in Docxodus
v11.0.0 (engine, detail_threshold, simplify_move_markup). XmlPowerToolsEngine
ignores kwargs.
"""
scratch_files = []
try:
Expand Down Expand Up @@ -288,6 +289,7 @@ class DocxodusEngine(BaseEngine):
_VALUE_FLAGS = [
('move_similarity_threshold', '--move-similarity-threshold'),
('move_minimum_word_count', '--move-minimum-word-count'),
('minimum_anchor_word_count', '--minimum-anchor-word-count'),
('date_time', '--date-time'),
]

Expand Down Expand Up @@ -322,6 +324,12 @@ def _validate_kwargs(cls, kwargs):
if not isinstance(val, int) or val < 1:
raise ValueError(f"move_minimum_word_count must be a positive integer, got {val!r}")

if 'minimum_anchor_word_count' in kwargs:
val = kwargs['minimum_anchor_word_count']
# bool is an int subclass, but would reach the CLI as "True".
if isinstance(val, bool) or not isinstance(val, int) or val < 0:
raise ValueError(f"minimum_anchor_word_count must be a non-negative integer, got {val!r}")

def _build_command(self, author_tag, original_path, modified_path, target_path, **kwargs):
self._validate_kwargs(kwargs)

Expand Down
2 changes: 1 addition & 1 deletion packages/docxodus/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Compiled Docxodus redline engine binary for
[`python-redlines`](https://pypi.org/project/python-redlines/).

Version 2.0.0 bundles the engine built from Docxodus v14.1.0.
Version 3.0.0 bundles the engine built from Docxodus v17.0.0.

This package only contains the platform-specific engine binary. Install it via
the `python-redlines` extra rather than directly:
Expand Down
2 changes: 1 addition & 1 deletion packages/docxodus/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name = "python-redlines-docxodus"
dynamic = ["version"]
description = "Docxodus redline engine binary for python-redlines."
readme = "README.md"
requires-python = ">=3.9"
requires-python = ">=3.11"
license = "MIT"
authors = [
{ name = "John Scrudato IV" },
Expand Down
4 changes: 2 additions & 2 deletions packages/ooxmlpowertools/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ build-backend = "hatchling.build"
[project]
name = "python-redlines-ooxmlpowertools"
dynamic = ["version"]
description = "Open-XML-PowerTools redline engine binary for python-redlines."
description = "Deprecated Open-XML-PowerTools redline engine binary for python-redlines. Use python-redlines-docxodus, the current engine, instead."
readme = "README.md"
requires-python = ">=3.9"
requires-python = ">=3.11"
license = "MIT"
authors = [
{ name = "John Scrudato IV" },
Expand Down
Loading
Loading