Skip to content

feat: parse .epub files by reading the XHTML inside (closes #21) - #27

Merged
francescobianco merged 2 commits into
openapi:mainfrom
qiaobochi040726-source:20261013-epub-parser
Oct 13, 2026
Merged

francescobianco merged 2 commits into
openapi:mainfrom
qiaobochi040726-source:20261013-epub-parser

Conversation

@qiaobochi040726-source

Copy link
Copy Markdown
Contributor

Closes #21.

An .epub is just a zip of XHTML, so parsers.parse now pulls the html/xhtml entries out with zipfile and reuses the existing tag stripping, instead of falling through to the binary best-effort read. Also let the importer accept .epub, otherwise import_folder skips it. A broken or non-zip file returns "" like the PDF path does.

Tried it: tests/test_core.py builds a tiny epub in tmp_path and runs it through import + ingest, checking the text lands in the source page. Didn't bother with spine/OPF ordering — sorted filenames are good enough for a flat read of the chapters.

Drafted with an AI coding assistant and gone over before sending, as CONTRIBUTING asks.

@francescobianco

Copy link
Copy Markdown
Member

Thank you @qiaobochi040726-source for this contribution! 🎉

It's a clean, focused change: stdlib zipfile, reusing the existing tag stripping, failing gracefully like the PDF path, and an end-to-end test from import through ingest. We also appreciate the honest note on AI assistance and the trade-off on spine ordering. Sorted filenames are a reasonable first step, and OPF ordering can come later if anyone needs it.

You're warmly invited to become an official Openapi contributor: https://github.com/openapi/contributors 🙌

@francescobianco
francescobianco merged commit 02b4c70 into openapi:main Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add an EPUB parser

2 participants