Fix the spelling mistakes in a book (EPUB) and flow the corrected text into the publisher's InDesign template, producing a ready-to-open IDML — in the template's house styles, with the layout and front matter intact — plus a clear report of every change. You're a capable agent: this describes the goal and the pitfalls, not step-by-step instructions. Choose your own methods.
- The EPUB (final text).
- The InDesign template as IDML (ask me to export it if I only have .indt — the binary form can't be read).
- A Hunspell dictionary for the book's language (.aff + .dic), or permission to fetch one.
- Optional: a do-not-correct glossary (names, invented/foreign words) and a style note mapping the book's parts to the template's styles. If missing, infer them and state your assumptions.
- Correct confident spelling errors (including context-clear real-word errors) automatically; flag anything ambiguous instead of changing it.
- Preserve everything else: the template's styles, layout, and front matter.
- Deliver a valid IDML that opens cleanly, plus a complete change report (human- and machine-readable) listing every fix, every flag, and what you deliberately left alone.
- Work in whatever language the EPUB declares.
Prefer pure-Python tools — one pip install, identical on every OS:
- lxml (read/write the IDML XML), spylls (Hunspell spell-check straight from .aff/.dic, no native binary), and optionally language-tool-python for a grammar pass (needs Java 17+).
- Native equivalents if you prefer them: hunspell, LanguageTool, pandoc — via winget (Windows), Homebrew (macOS), or apt (Linux). Keep file paths OS-agnostic.
- The template may not contain the book. Publisher templates are often fully laid out with placeholder body text — sometimes a different book entirely — while the front matter is real. Replace only the body; keep the real front matter.
- Most flagged "misspellings" are intentional: character/place names, invented or translated vocabulary, foreign-language lines, and deliberate slang/dialect (often a whole passage). Wrongly "correcting" these is the #1 way this fails. Judge each in context; use the glossary.
- Grammar tools are weak and noisy for many languages — mostly false positives or intentional patterns (repeated words for emphasis/codes, valid compounds). Verify each; apply few.
- Tracked changes may hide in the file and garble naive text extraction — preserve what you keep.
- You probably can't open InDesign, so verify structurally that the IDML is valid and every style the text references exists in the template.