Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tri Differ — Multi-Document Word Comparison

English | Simplified Chinese

Tri Differ is a browser-based .docx comparison tool. It loads multiple Word documents, renders Word-like pages, compares text and embedded images, and builds a navigable similarity index. All document processing happens locally in the browser.

Highlights

  • Load any number of .docx files in one session.
  • Organize comparisons as independent tasks, each with its own A/B document windows.
  • Select an A/B window and double-click a file in the document library to open it in that window.
  • Collapse either sidebar to give more space to the document panes.
  • Render only the active task's two full Word-like document views instead of rendering every loaded file.
  • Preserve page size, margins, paragraph alignment, indentation, line spacing, basic text formatting, tables, and inline image placement as closely as practical in a browser.
  • Generate text similarity matches sorted by score.
  • Detect identical and visually similar embedded images using file digests and 64-bit dHash fingerprints.
  • Reduce comparison work with text candidate indexing and image hash buckets instead of comparing every possible pair.
  • Filter the match index to the active A/B document pair.
  • Jump to and highlight both matching locations by selecting an index entry.
  • Adjust the text similarity threshold, image hash-distance tolerance, and page zoom.
  • Export the similarity index as JSON.
  • Keep documents private: no upload or server-side conversion is required.

Quick Start

No build step or application installation is required.

Option 1: Open Directly

  1. Clone or download this repository.
  2. Open index.html in a modern desktop browser.

Option 2: Run a Local Web Server

git clone git@github.com:jameswibe79/tri_differ.git
cd tri_differ
python3 -m http.server 8000

Then open:

http://localhost:8000

A local server is useful when a browser applies stricter permissions to pages opened with the file:// protocol.

Usage

  1. Click Add Word and select one or more .docx files.
  2. Wait for automatic analysis, or click Compare.
  3. Select a task and then select its A or B window in the left sidebar.
  4. Double-click a document in the file library to open it in the selected window.
  5. Review the similarity index in the right sidebar. The index follows the active A/B pair.
  6. Select a text or image match to jump to and highlight both corresponding locations.
  7. Adjust the text threshold or image tolerance when needed.
  8. Use Export to save the generated index as JSON.

How It Works

A .docx file is a ZIP archive. Tri Differ uses the bundled vendor/jszip.min.js to read:

  • word/document.xml
  • page and margin settings
  • paragraph and table structures
  • document relationships
  • embedded files under word/media/

The application reconstructs an approximate Word-style page layout directly in the browser. It does not require Microsoft Word, LibreOffice, a backend service, or a document-conversion server.

Text comparison uses indexed candidate generation to avoid an exhaustive comparison of every sentence pair. Image comparison combines exact file digests with 64-bit difference hashes, making it possible to find both identical images and images that remain visually similar after scaling or light recompression.

Privacy

Documents stay in the current browser session. The application does not upload files or document contents to a remote service. Closing or refreshing the page clears the in-memory session unless the browser itself retains page state.

Browser Requirements

Use a current desktop browser with support for:

  • File API and ArrayBuffer
  • DOMParser
  • Web Crypto
  • Canvas
  • modern JavaScript and CSS

Chromium-based browsers are used by the smoke test.

Limitations

  • Only .docx documents are supported.
  • Browser rendering approximates Microsoft Word layout and is not a pixel-perfect replacement for Word's rendering engine.
  • Advanced Word features may not be represented exactly.
  • Rich image formats that a browser cannot draw may still be detected as exact binary matches, but perceptual comparison may be unavailable.
  • Analysis performance depends on document size, sentence count, embedded image count, and the selected thresholds.

Project Structure

tri_differ/
├── index.html
├── README.md
├── README.zh-CN.md
├── src/
│   ├── app.js
│   └── styles.css
├── tests/
│   ├── create-fixtures.py
│   └── smoke.js
└── vendor/
    └── jszip.min.js

Verification

Basic syntax and browser smoke checks:

python3 tests/create-fixtures.py
node --check src/app.js
node --check tests/smoke.js
node tests/smoke.js

The browser smoke test requires Playwright and a Chrome-compatible browser. If Playwright is not already available:

npm install --no-save playwright
npx playwright install chrome

The fixture generator writes temporary test documents under /tmp/tri_differ_smoke.

About

Privacy-first browser-based .docx comparison with Word-like rendering and indexed text and image similarity matching.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages