Back to feed
Dev.to
Dev.to
6/24/2026
How We Built a Robust EPUB Parsing and Rebuilding Pipeline in Python

How We Built a Robust EPUB Parsing and Rebuilding Pipeline in Python

Short summary

LectuLibre built a Python pipeline to translate entire EPUB books while preserving visual structure, fonts, and metadata. The hybrid approach uses ebooklib for EPUB structure and lxml for namespace-aware XHTML parsing to handle broken markup and sentence-aware text extraction. The solution processes 90%+ of real-world books without manual intervention, validated through epubcheck.

  • Hybrid architecture: ebooklib for metadata/structure, lxml for fine-grained XHTML parsing
  • Solves namespace handling, performance (6s→faster), and broken-markup challenges in real-world EPUBs
  • Processes books through LLM translation pipeline while preserving layout, fonts, and embedded assets

Generated with AI, which can make mistakes.

Is this a good recommendation for you?

Comments

Failed to load comments. Please try again.

Explore more