Expand description
§jubarte
Lossless DOCX redline engine: compare two Word documents and produce a
tracked-changes (redline) .docx — the original document with every
difference against the modified one expressed as Word revisions
(insertions, deletions, moves, and format changes) — that opens cleanly
in Microsoft Word. Also lists, accepts, and rejects tracked revisions.
§Example
let original = std::fs::read("original.docx").unwrap();
let modified = std::fs::read("modified.docx").unwrap();
let redline =
jubarte::document_comparer::compare_documents(&original, &modified, "Reviewer")
.expect("compare");
std::fs::write("original_v_modified.docx", &redline).unwrap();For author/date/detail-threshold control, build a
comparer::WmlComparerSettings and call
document_comparer::compare_documents_with_settings. To inspect a
redline, use document_comparer::get_revisions; to flatten one, use
document_comparer::accept_revisions / document_comparer::reject_revisions.
Convert a document to PDF with convert::docx_to_pdf.
§Provenance
The comparer is a Rust port of the WmlComparer/DocumentComparer engine
from Docxodus (MIT), itself a fork of
Microsoft’s Open-Xml-PowerTools
(MIT). The repository itself is AGPL-3.0-only; LICENSES/ preserves those
upstream attribution texts without changing the repository license.
Re-exports§
pub use wml_document::WmlDocument;
Modules§
- comparer
- Core WmlComparer engine (atomize → LCS → produce → finalize).
WmlComparer core (M4). Port of
WmlComparer.ts. - comparison_
log - Structured comparison log (info / warning / error entries).
Port of
ComparisonLog.ts— diagnostic log emitted during comparison. - convert
- Independent DOCX → PDF conversion (not LibreOffice). Independent DOCX → PDF conversion (not LibreOffice / soffice).
- document_
comparer - Byte-level package API: compare, list, accept, and reject revisions.
DocumentComparer façade (M5). Port of
DocumentComparer.ts(compare path). - markup_
simplifier - Markup simplification (PowerTools
MarkupSimplifierport). Port ofMarkupSimplifier.ts(the comparison subset the comparer uses) — M2. - namespaces
- WordprocessingML and related namespace /
XNameconstants. Namespace + name constants ported fromPtOpenXmlUtil.ts(the subset the comparer references) — M1.7. - opc
- Open Packaging Conventions adapter (
PartFs). OPC (Open Packaging Conventions) layer — M1.5. - perf
- P0-LAB-01 stage counters/timers — no-ops unless
perf-profileis enabled. P0-LAB-01 — feature-gated stage counters and coarse timers. - revision_
processor - Accept / reject tracked revisions across a package.
Port of
RevisionProcessor.ts— accept-revisions pipeline (M3). - strict_
translation - ISO Strict → Transitional package normalization. ISO/IEC 29500 Strict → Transitional namespace normalization (M8).
- unid
- Unique id helpers for revision markup.
Port of
UnidHelper(UnidHelper.ts) — M1.7. - util
- Shared small utilities.
Utilities ported from
PtUtil.ts— M1.6. - wml_
document WmlDocument— document bytes + lazily parsed main part. Port ofWmlDocument/PtMainDocumentPart(WmlDocument.ts) — M1.7.- xmllinq
- Arena DOM (
xmllinq) used by the comparer. Port oflib/xml-linq.ts— a LINQ-to-XML-style mutable XML tree.