1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
// SPDX-FileCopyrightText: 2026 Jandira Technologies, LLC
//
// SPDX-License-Identifier: Apache-2.0
//! # jubarte
//!
//! Word-faithful `.docx` toolkit. It compares two Word documents into a
//! tracked-changes redline that opens cleanly in Microsoft Word, and it also
//! edits, inspects, checks, cleans, merges and renders them: every function
//! takes the complete package as `&[u8]` and returns a new one, with no temp
//! files and no Word or LibreOffice process.
//!
//! ## What you can do
//!
//! | Task | Start here |
//! |---|---|
//! | Compare two documents into a redline | [`document_comparer::compare_documents`]; [`comparer::WmlComparerSettings`] with [`document_comparer::compare_documents_with_settings`] for author, date, moves and detail |
//! | List, accept or reject tracked changes, all or some | [`document_comparer::get_revisions`], [`document_comparer::accept_revisions`], [`document_comparer::reject_revisions`]; one at a time with [`changes::list_changes`], [`changes::accept_changes`], [`changes::reject_changes`] |
//! | Edit a document as tracked changes | [`edit::apply_plan`] / [`edit::apply_plan_json`] with an [`edit::EditPlan`]: rewrite, insert, tables, lists, run formatting, footnotes, images, page setup, content controls, watermark, redact, settings |
//! | Read a document the way an edit addresses it | [`inspect::paragraphs`], [`inspect::summary`], [`inspect::stories`], [`inspect::controls`], [`inspect::inspect_json`], [`inspect::markdown`] |
//! | Render to PDF or PNG | [`convert::docx_to_pdf`], [`convert::docx_to_pdf_with`] and [`convert::PdfOptions`] (revision marks: [`convert::RevisionStyle`]), [`convert::docx_to_png`]; page-by-page differences with [`convert::diff_render`] |
//! | Convert a Word 97-2003 `.doc` | [`legacy_doc::doc_to_docx`], [`legacy_doc::doc_to_markdown`]: text, headings and tables |
//! | Markdown in and out | [`markdown::markdown_to_docx`] (CriticMarkup becomes tracked changes and comments), [`markdown::docx_to_markdown`], [`markdown::diff_markdown`], [`markdown::redline`] |
//! | Check that Word will open it, and repair it | [`validate::validate`], [`validate::repair`], [`validate::audit_tracked`]; triage with [`debug::report`] |
//! | Accessibility, style and structure findings | [`audit::audit_report`] |
//! | Remove authors and metadata before sending | [`scrub::scrub`] with [`scrub::ScrubOptions`]; find leftover text with [`scrub::leaks`] |
//! | Append one document after another | [`append::append_documents`] with [`append::AppendOptions`] |
//! | List comment threads | [`comments::list_comments`] |
//! | Refresh a table of contents and other fields | [`fields::update_fields`] |
//! | Bound untrusted input before it is opened | [`admission::admit`] with [`admission::InputLimits`] (every entry point above admits its input too) |
//! | Ask what this build supports | [`capabilities::capabilities_json`] |
//!
//! The [Rust guide](https://github.com/jandira-tech/jubarte/blob/main/docs/rust.md)
//! walks through each one; the same operations are in Python (`jubarte-redlines`
//! on PyPI), JavaScript (`jubarte-wasm` on npm) and the `jubarte` CLI.
//!
//! ## Example
//!
//! ```no_run
//! fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let original = std::fs::read("original.docx")?;
//! let modified = std::fs::read("modified.docx")?;
//! let redline =
//! jubarte::document_comparer::compare_documents(&original, &modified, "Reviewer")?;
//! std::fs::write("original_v_modified.docx", &redline)?;
//! std::fs::write("original_v_modified.pdf", jubarte::convert::docx_to_pdf(&redline)?)?;
//! Ok(())
//! }
//! ```
//!
//! An edit plan is JSON, so an agent can write one. Each operation names its
//! paragraph (an id from [`inspect::paragraphs`]) and text that must occur
//! there exactly once; the result holds the edited document and its redline:
//!
//! ```no_run
//! fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let contract = std::fs::read("contract.docx")?;
//! let plan = r#"{"schema_version": 1, "author": "Reviewer", "operations": [
//! {"kind": "replace", "paragraph": "p4",
//! "find": "thirty (30) days", "replacement": "sixty (60) days"}
//! ]}"#;
//! let edited = jubarte::edit::apply_plan_json(&contract, plan)?;
//! std::fs::write("contract_clean.docx", &edited.clean)?;
//! std::fs::write("contract_redline.docx", &edited.redline)?;
//! Ok(())
//! }
//! ```
//!
//! ## Comparison fidelity
//!
//! The redline is Word-valid, and differences in text and formatting are
//! revisions, but the engine also normalizes some markup so the output opens
//! cleanly and matches what Word's own Compare writes. This list is the main
//! cases, not every one. Both inputs lose non-standard `w:`-namespace children
//! of `w:sdtPr` and have `mc:AlternateContent` resolved to a single branch.
//! In the default (Word-visual) mode, the original's own tracked changes are
//! flattened and compared like text, internal anchor `w:hyperlink` wrappers
//! (no `r:id`) become runs styled as hyperlinks, content controls in any
//! paragraph that carries a revision are unwrapped, some redundant default
//! spacing is stripped, and a breaking and a non-breaking space compare equal
//! ([`comparer::WmlComparerSettings::conflate_breaking_and_nonbreaking_spaces`]).
//! [`comparer::WmlComparerSettings::powertools_faithful`] skips the
//! mode-specific passes.
//!
//! ## Provenance
//!
//! The comparer is a Rust port of the `WmlComparer`/`DocumentComparer` engine
//! from [Docxodus](https://github.com/JSv4/Docxodus) (MIT), itself a fork of
//! Microsoft's [Open-Xml-PowerTools](https://github.com/OfficeDev/Open-Xml-PowerTools)
//! (MIT). The repository itself is Apache-2.0; `NOTICE` and `LICENSES/` preserve
//! those upstream attribution texts.
pub use cli;
pub use append;
pub use audit;
/// Tracked changes one at a time: list, accept or reject a selection.
pub use changes;
pub use comments;
/// `jubarte debug`: short Word-validity triage of a package, or two compared.
pub use debug;
/// Table, cell and paragraph border views shared by render, markdown and debug.
/// Word's built-in style names.
/// Machine-readable manifest of what this build can do.
pub use capabilities;
pub use admission;
/// Custom XML and built-in data stores shared by the OPC layer.
/// Core WmlComparer engine (atomize → LCS → produce → finalize).
pub use comparer;
/// Structured comparison log (info / warning / error entries).
pub use comparison_log;
/// Independent DOCX → PDF conversion (not LibreOffice).
pub use convert;
/// Byte-level package API: compare, list, accept, and reject revisions.
/// One-call document comparison and revision accept/reject. Composed
/// per A6: the compare crate's module, plus the comment-keeping
/// accept/reject the doc layer owns.
/// Tracked-change editing: the jubarte-edit crate's module plus the
/// inline CLI actions (behind `cli`).
pub use update;
pub use fields;
/// Read-only paragraph/package views and the Markdown projection for agents.
pub use inspect;
pub use scrub;
pub use validate;
pub use ids;
/// WordprocessingML and related namespace / `XName` constants.
pub use namespaces;
/// P0-LAB-01 stage counters/timers — no-ops unless `perf-profile` is enabled.
pub use perf;
pub use unid;
/// Shared small utilities.
pub use util;
/// Arena DOM (`xmllinq`) used by the comparer.
pub use xmllinq;
/// V2-13 (issue #845): the checker core for `--expect` evaluations.
pub use expect;
/// The composed markdown module (A6): the markdown crate's module plus
/// the edit crate's patch, redline and unified modules.
pub use markdown;
pub use result;
pub use text_diff;
pub use legacy_doc;
/// Markup simplification (PowerTools `MarkupSimplifier` port).
pub use markup_simplifier;
/// Open Packaging Conventions adapter (`PartFs`).
pub use opc;
pub use settings;
/// ISO Strict → Transitional package normalization.
pub use strict_translation;
/// Accept / reject tracked revisions across a package.
pub use revision_processor;
/// Pure DOM structural predicates shared by validate and the comparers.
/// Word's default theme part, for originals without one.
/// `WmlDocument` — document bytes + lazily parsed main part.
pub use wml_document;
/// [`WmlDocument`] re-export for the common library entry point.
pub use WmlDocument;
/// Capability-confined, staged filesystem publication for host applications.
pub use publication;