This tutorial walks you through the complete pipeline for this example project — from OCR'ing the sample scans to producing a clean, AI-reviewed Word document.
By the end you will have:
- A raw Markdown file assembled from the scans
- A cleaned-up version with OCR artefacts removed
- An AI-corrected version with context-dependent OCR errors fixed
- An HTML copy-edit review produced by Claude
- A Word document ready to share or import into Vellum
Fork this repository on GitHub (click Fork at the top right), then clone your fork:
git clone https://github.com/<your-username>/scatterpub-toolchain-example.git
cd scatterpub-toolchain-exampleThe scripts and skills live in a submodule. Initialise it:
git submodule update --initThese are installed once via Homebrew. If you do not have Homebrew, install it first by following the instructions at https://brew.sh.
brew install poppler # extracts text from PDFs
brew install pandoc # converts between document formats
brew install tesseract # OCR engine (fallback; the default engine is installed via Poetry below)The toolchain uses Poetry to manage its Python libraries. Install Poetry if you do not have it:
curl -sSL https://install.python-poetry.org | python3 -Then install the toolchain's dependencies:
cd toolchain && poetry install && cd ..This creates a self-contained virtual environment inside toolchain/.
source toolchain/.venv/bin/activateYou will need to run this once each time you open a new terminal window. Your prompt will change to show (.venv) when it is active. All the python3 commands in the rest of this tutorial assume the virtual environment is active.
Parts 4 and 5 of this tutorial use Claude Code. Open this project folder in Claude Code — the skills are already wired up via symlinks in .claude/skills/, so no additional workspace setup is needed.
The sample scans are in publishing/tell-me-bella/ocr/scans/clean/. Run the OCR script to extract their text and assemble it into a single Markdown file:
python3 toolchain/scripts/ocr-to-markdown.py \
"publishing/tell-me-bella/ocr/scans/clean"This will take a minute or two — the default OCR engine (marker) uses a machine-learning model and processes each page in turn. You will see progress as each file is processed.
When it finishes, you will find the result at:
publishing/tell-me-bella/ocr/tell-me-bella-raw.md
Open it and have a look. You will notice some issues typical of OCR output:
- Running headers (page number + title repeated at the top of each page)
- Occasional invisible characters
- Words split across lines with a hyphen
As a note on OCR, please do make an effort to ensure that when you scan a book, you get the pages as flat as possible. Professional book scanning equipment for archives presses a sheet of glass down on the page to help with this. I then open the raw PDF scans in Adobe Acrobat where I crop them and align them so there is a clean rectangular block of text without any text visible from an opposite page. You can see what I mean if you look at the example scans in this project.
An additional pro-tip is to put a sheet of black paper behind the page being scanned. This ensures that the text on the other side of the page does not come through in the scan. That can be picked up by OCR, causing all sorts of extra letters to appear in the resulting text output.
The clean-up script removes the most common OCR artefacts automatically:
python3 toolchain/scripts/clean-ocr.py \
"publishing/tell-me-bella/ocr/tell-me-bella-raw.md" \
--join-hyphens --reflow--join-hyphens joins words that were split across lines by the typesetter (e.g. news-\npaper becomes news-paper). The hyphen is kept so you can review each join and decide whether to remove it.
--reflow joins the remaining soft line-breaks within each paragraph into a single long line. OCR preserves the typeset line breaks from the printed page; --reflow removes these so each paragraph becomes one continuous line of text.
The cleaned file is written to:
publishing/tell-me-bella/ocr/tell-me-bella-clean.md
Compare it with the raw version — running headers will be gone, invisible characters removed, line-break hyphens joined, and each paragraph on a single line.
The Python script catches mechanical artefacts, but some OCR errors require reading in context. The script cannot reliably detect:
- Fused words — two words joined without a space:
ofMezre,onthe,OldRomanRoad - Dropped characters — a character missed by the scanner, producing a plausible-looking but wrong word:
bomforborn,WestemforWestern - Character substitutions — a
dmisread asclin certain typefaces:SadcllerforSaddler - Garbled proper nouns — stray characters inserted into names:
Tow:vandaforTourvanda - Exclamation marks misread —
!rendered aslorIinside quoted speech:lad lforlad!
With Claude Code open (step 1.6), load the copy-editor skill:
/manuscript-copyeditor
Then ask Claude to perform an OCR artefact correction pass and write a corrected Markdown file:
Please apply an OCR artefact correction pass to
publishing/tell-me-bella/ocr/tell-me-bella-clean.md
and write the corrected version to
publishing/tell-me-bella/ocr/tell-me-bella-ai-clean.md
Claude will read the file, identify and fix OCR errors in context, and write the result to:
publishing/tell-me-bella/ocr/tell-me-bella-ai-clean.md
Review the output — Claude will catch most OCR errors, but corrections to proper nouns and place names are worth checking against the original scans before proceeding.
Up until this point, everything can be re-created by re-running the steps above. However, now it is over to you to start manually updating the copy, ready for publication. Take a copy of the automatically generated tell-me-bella-ai-clean.md file and put it in the draft folder as plain tell-me-bella.md
cp publishing/tell-me-bella/ocr/tell-me-bella-ai-clean.md \
publishing/tell-me-bella/draft/tell-me-bella.mdWith the same workspace open, load the copy-editor skill:
/manuscript-copyeditor
Then ask Claude to produce a full style review:
Please produce a full copy-edit review of
publishing/tell-me-bella/draft/tell-me-bella.md
Claude will read the file, work through it chapter by chapter, and write a self-contained HTML review to:
publishing/tell-me-bella/review/tell-me-bella-review.html
Open that file in any web browser. Each issue is shown as a colour-coded card:
| Colour | Category | Used for |
|---|---|---|
| Red | TYPO | Spelling errors, wrong or missing words |
| Orange | PUNCT | Quotation marks, dashes, ellipsis |
| Yellow | STYLE | British English, capitalisation, numbers |
| Blue | CONSISTENCY | The same word formatted differently in different places |
| Purple | QUERY | Ambiguous phrasing — flagged for a human to decide |
Work through the review and make any edits you agree with directly in tell-me-bella.md.
Once you are happy with the cleaned Markdown, convert it to a Word document:
python3 toolchain/scripts/md-to-docx.py \
"publishing/tell-me-bella/draft/tell-me-bella.md"The result is written to:
publishing/tell-me-bella/draft/tell-me-bella.docx
This Word document is ready to:
- Share with a human editor — they can read and annotate it in Word or Google Docs
- Import into Vellum — open Vellum, choose Import Word Document, and select the file; each chapter heading will be detected as a chapter break
This example covers five pages. For a full book project:
- Prepare clean per-page PDFs for all pages and add them to
ocr/scans/clean/ - Re-run the OCR and clean-up scripts
- Run the copy-editor on the full text
- Generate the final Word document
See the scatterpub-toolchain README for instructions on setting up a new book project from scratch, and for documentation on all the available scripts.