docx-comments-to-text
Extract reviewer comments from .docx files and insert them inline with the text they reference, creating a plain text output that keeps feedback in context.
Installation
From PyPI (recommended)
pip install docx-comments-to-text
From source
# Clone the repository
git clone https://github.com/platelminto/docx-comments-to-text
cd docx-comments-to-text
# Install in development mode
uv sync --dev
# or: pip install -e .
Usage
Command Line Interface
# Basic usage - output to stdout
docx-comments-to-text document.docx
# Save to file
docx-comments-to-text document.docx -o output.txt
# Control author display
docx-comments-to-text document.docx --authors never # Hide authors
docx-comments-to-text document.docx --authors always # Always show authors
docx-comments-to-text document.docx --authors auto # Show authors when multiple exist (default)
# Control comment placement
docx-comments-to-text document.docx --placement inline # Inline with text (default)
docx-comments-to-text document.docx --placement end-paragraph # At end of each paragraph
docx-comments-to-text document.docx --placement comments-only # Comments only with context
Development Usage
If working from source:
# Run with uv
uv run docx-comments-to-text document.docx
# Or use module syntax
uv run python -m docx_comments_to_text.cli document.docx
Example Output
Inline placement (default)
Original text with [reviewer feedback] [COMMENT: "This needs clarification"] continues here.
More content [needs examples] [COMMENT John: "Consider adding examples"] and final text.
End-paragraph placement
Original text with reviewer feedback[1] continues here.
More content needs examples[2] and final text.
Comments:
1. This needs clarification
2. John: Consider adding examples
Comments-only placement
"reviewer feedback": This needs clarification
"needs examples": John: Consider adding examples
Features
- Accurate comment positioning and text preservation
- Handles overlapping comments and multiple comment types
- Configurable author display
- Multiple comment placement styles (inline, end-of-paragraph, comments-only)
Technical Details
DOCX Structure
- DOCX files are ZIP archives containing XML files
word/document.xml- main document contentword/comments.xml- comment definitions- Comment ranges marked with
<w:commentRangeStart>and<w:commentRangeEnd>
Comment Insertion Strategy
- Parse document XML to extract text and track character positions
- Map comment ranges to their start/end positions in the text
- Sort comments by position for safe insertion (reverse order)
- Wrap commented text in brackets:
[commented text] - Insert comment content after bracketed text:
[COMMENT: "feedback"]
Dependencies
python-docx- DOCX file handlinglxml- XML parsingclick- Command line interface
Metadata
Release files for docx-comments-to-text 0.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| docx_comments_to_text-0.2.2.tar.gz | 15.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| docx_comments_to_text-0.2.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 24.6 kB
Release files / docx_comments_to_text-0.2.2.tar.gz
| Download URL | docx_comments_to_text-0.2.2.tar.gz |
|---|---|
| Size | 15.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bed74040e67a1824072ad6878dd7e5121cb75311895b11632b6c1c9bd253526b
|
|
BLAKE2b-256 checksum How to use checksums |
499825124c274ab947eb3f7cf0f5c0c3af7a3a73df30224bdbf9298ef5b16291
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.15
|
Release files / docx_comments_to_text-0.2.2-py3-none-any.whl
| Download URL | docx_comments_to_text-0.2.2-py3-none-any.whl |
|---|---|
| Size | 9.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fcf9ba5e1c74a4e8917f5565f826dcfa5664e3b540a661ba3759eaa1739f31e5
|
|
BLAKE2b-256 checksum How to use checksums |
eae3edb9254c5b567e437c5a96c0faf69a6f5bbd54e7aeb71974e0dad8c47a9c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.15
|