11# Python-Redlines Quickstart
22
33` python-redlines ` wraps a C# comparison engine to produce tracked-change redline ` .docx `
4- files. This guide uses the ` XmlPowerToolsEngine ` (Open-XML-PowerTools); ` DocxodusEngine `
5- works the same way.
4+ files. This guide uses ` DocxodusEngine ` — the default and recommended engine.
5+ ` XmlPowerToolsEngine ` (legacy) shares the same call signature; the only behavioural
6+ difference is that it silently ignores the keyword arguments shown in Step 4.
67
78### Step 0: Install
89
910Install the core package plus the engine you want as an extra. No .NET SDK is needed —
1011the engine binary is prebuilt and embedded in the wheel.
1112
1213``` commandline
13- pip install python-redlines[ooxmlpowertools ]
14+ pip install python-redlines[docxodus ]
1415```
1516
17+ Use ` python-redlines[ooxmlpowertools] ` for the legacy engine, or ` python-redlines[all] `
18+ for both.
19+
1620### Step 1: Import and Initialize the Wrapper
1721
1822In your Python script or interactive session, import and initialize the wrapper:
1923
2024``` python
21- from python_redlines.engines import XmlPowerToolsEngine
25+ from python_redlines import DocxodusEngine
2226
23- wrapper = XmlPowerToolsEngine ()
27+ wrapper = DocxodusEngine ()
2428```
2529
2630### Step 2: Run Redlines
2731
28- Use the ` run_redline ` method to compare documents. You can pass the paths of the ` .docx ` files or their byte content:
32+ Use the ` run_redline ` method to compare documents. You can pass the paths of the ` .docx ` files (as ` str ` or ` pathlib.Path ` ) or their byte content:
2933
3034``` python
3135# Example with file paths
@@ -37,12 +41,11 @@ with open('/path/to/original.docx', 'rb') as f:
3741with open (' /path/to/modified.docx' , ' rb' ) as f:
3842 modified_bytes = f.read()
3943
40- # This is a tuple, bytes @ element 0
44+ # Returns (redline_bytes, stdout, stderr)
4145output = wrapper.run_redline(' AuthorTag' , original_bytes, modified_bytes)
4246```
4347
44- In both cases, ` output ` will contain the byte content of the resulting redline - a .docx with changes in tracked
45- changes.
48+ In both cases, ` output[0] ` will contain the byte content of the resulting redline — a .docx with changes as Word tracked changes.
4649
4750### Step 3: Handle the Output
4851
@@ -52,3 +55,20 @@ Process or save the output as needed. For example, to save the redline output to
5255with open (' /path/to/redline_output.docx' , ' wb' ) as f:
5356 f.write(output[0 ])
5457```
58+
59+ ### Step 4: Tune the Comparison (optional, DocxodusEngine only)
60+
61+ ` DocxodusEngine ` accepts keyword arguments to control move detection, granularity, and
62+ more. See the [ main README] ( ../README.md#comparison-settings-docxodusengine-only ) for
63+ the full table.
64+
65+ ``` python
66+ output = wrapper.run_redline(
67+ ' AuthorTag' , original_bytes, modified_bytes,
68+ detect_moves = True ,
69+ simplify_move_markup = True , # required with detect_moves for Word compatibility
70+ detail_threshold = 0.3 ,
71+ )
72+ ```
73+
74+ ` XmlPowerToolsEngine ` silently ignores these kwargs — switch engines if you need them.
0 commit comments