Convert Microsoft Word documents into structured JSON content suitable for web applications, content management systems, or RAG (Retrieval-Augmented Generation) pipelines.
- Multi-language support - Process books in multiple languages from a single repo
- Automatic TOC extraction - Identifies chapters and sections from Table of Contents
- NavTree v2 output - Structured JSON with per-node metadata (index.toml)
- Image extraction - Extracts all images including WMF to PNG conversion
- Table processing - Preserves complex table structures
- Markdown export - Optional parallel Markdown output
This is a template repository. It contains the build tools but no content.
To use it with your own documents, fork it to a private repository and add your content there. The .gitignore is structured so you can easily enable content tracking in your fork.
Use the included sample document to verify the toolchain works:
make install-deps
make build- Fork this repo to your own (private) GitHub account
- Edit
.gitignoreβ remove the first section labeled "Content files β TEMPLATE ONLY" - Add your content to
lang-store/<lang>/(see below) - Commit your content files β they are now tracked in your private fork
The .gitignore has three clearly marked sections:
| Section | Template repo | Your fork |
|---|---|---|
| Content files β TEMPLATE ONLY | Ignored | Remove this section to track content |
| Generated output | Ignored | Keep ignored |
| Standard ignores | Ignored | Keep ignored |
All source content lives under lang-store/, organized by language:
lang-store/
βββ eng/
β βββ book_config.toml # Book metadata and settings
β βββ original-book.docx # Source Word document
β βββ exceptions.eng.conf # TOC numbering fixes (optional)
βββ fra/
β βββ book_config.toml
β βββ source-document.docx
β βββ cover.png
βββ rus/
βββ book_config.toml
βββ source-document.docx
βββ exceptions.rus.conf
The build system auto-discovers files in each language directory.
Each language needs a book_config.toml. Copy from book_config.toml.example:
canonical_id = "my-book-title"
language = "eng"
title = "My Book Title"
is_original = true
pictures_location = "root"If title is left empty, it will be extracted from the DOCX metadata or first paragraph.
# Build a specific language (default: eng)
make build L=eng
make build L=fra
# Build with images
make all L=eng
# See available languages
make helpGenerated output goes to export/ (JSON) and export_md/ (Markdown) β both are gitignored.
The folder hierarchy IS the navigation tree. Each section gets its own folder
with index.toml (metadata) and content.json (content blocks).
export/
βββ {lang}/
β βββ {book_id}/
β βββ config.toml # Global settings
β βββ search-positions.json # content_id β tree positions
β βββ 01/ # Chapter 1
β β βββ index.toml # Chapter metadata
β β βββ content.json # Chapter intro content
β β βββ 01/ # Section 1.1
β β β βββ index.toml
β β β βββ content.json
β β β βββ 01/ # Subsection 1.1.1
β β β βββ index.toml
β β β βββ content.json
β β βββ 02/ # Section 1.2
β β βββ index.toml
β β βββ content.json
β βββ 02/ # Chapter 2
βββ pictures/
βββ {lang}/
βββ {book_id}/
βββ 01/
βββ 01/
βββ 001.png
export_md/ # Parallel Markdown export
βββ {lang}/
βββ README.md
βββ style.css
βββ 01/
βββ intro.md
βββ 01.md
See docs/navtree-v2-format.md for the full format specification.
make build # Build JSON/Markdown for one language
make all # Build JSON/Markdown + extract images
make rebuild-all # Clean and rebuild from scratch
make clean # Remove generated files
make check-deps # Verify dependencies installed
make verify # Check image integrity
make status # Show project status
make stats # Display content statisticsUse L=<lang> to select language: make build L=fra
- Python 3.8+ with python-docx
- ImageMagick 7+ - Image processing
- Ghostscript - PDF to PNG conversion
- LibreOffice - WMF to PDF conversion (optional, for Windows Metafile images)
macOS:
brew install imagemagick ghostscript
brew install --cask libreoffice
make install-depsLinux (Ubuntu/Debian):
sudo apt-get install imagemagick ghostscript libreoffice python3-pip
make install-depsImportant: Convert automatic numbering to fixed text before processing.
Word/LibreOffice automatic numbering stores section numbers invisibly, causing missing sections in the output.
Quick Fix:
- LibreOffice: Select All β Format β Lists β No List β Save
- Word: Use the VBA macro in DOCUMENT_PREPARATION_GUIDE.md
If your document has known numbering inconsistencies, create an exceptions file in your language directory (e.g., lang-store/eng/exceptions.eng.conf):
# Format: wrong_number = correct_number
10.7.7 = 10.7.5
21.4.3 = 21.2.3
- docs/navtree-v2-format.md - Output format specification
- DOCUMENT_PREPARATION_GUIDE.md - Preparing Word documents
- WMF_CONVERSION_GUIDE.md - WMF image conversion
- MARKDOWN_GENERATION.md - Markdown output details
- CONTRIBUTING.md - Contributing to the template
GNU General Public License v3.0 (GPL-3.0) - See LICENSE file.