Skip to content

Add EPUB 3 nav.xhtml TOC support#197

Merged
daveallie merged 1 commit intocrosspoint-reader:masterfrom
bigbag:feature/epub3-support
Jan 3, 2026
Merged

Add EPUB 3 nav.xhtml TOC support#197
daveallie merged 1 commit intocrosspoint-reader:masterfrom
bigbag:feature/epub3-support

Conversation

@bigbag
Copy link
Contributor

@bigbag bigbag commented Dec 31, 2025

Summary

  • What is the goal of this PR? Add EPUB 3 support by implementing native navigation document (nav.xhtml) parsing with NCX fallback, addressing issue Fixes: EPUB 3 support missing #143.

  • What changes are included?

    • New TocNavParser for parsing EPUB 3 HTML5 navigation documents (<nav epub:type="toc">)
    • Detection of nav documents via properties="nav" attribute in OPF manifest
    • Fallback logic: try EPUB 3 nav first, fall back to NCX (EPUB 2) if unavailable
    • Graceful degradation: books without any TOC now load with a warning instead of failing

Additional Context

Copy link
Member

@daveallie daveallie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, a small simplification can be made

@bigbag bigbag force-pushed the feature/epub3-support branch from c3f3ae6 to 271b1b9 Compare January 2, 2026 14:13
  - Add TocNavParser for HTML5 navigation documents
  - Detect nav document via properties=nav in OPF manifest
  - Try nav.xhtml first, fall back to NCX for compatibility
  - Books without TOC now load with warning instead of failing
@bigbag bigbag force-pushed the feature/epub3-support branch from 271b1b9 to 17215dd Compare January 2, 2026 14:20
@bigbag bigbag requested a review from daveallie January 2, 2026 19:31
Copy link
Member

@daveallie daveallie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks for the modification!

@daveallie daveallie merged commit 0332e11 into crosspoint-reader:master Jan 3, 2026
1 check passed
@bigbag bigbag deleted the feature/epub3-support branch January 14, 2026 05:44
yingirene pushed a commit to yingirene/crosspoint-reader that referenced this pull request Jan 16, 2026
## Summary

* **What is the goal of this PR?** Add EPUB 3 support by implementing
native navigation document (nav.xhtml) parsing with NCX fallback,
addressing issue Fixes: crosspoint-reader#143.

  * **What changes are included?**
- New `TocNavParser` for parsing EPUB 3 HTML5 navigation documents
(`<nav epub:type="toc">`)
- Detection of nav documents via `properties="nav"` attribute in OPF
manifest
- Fallback logic: try EPUB 3 nav first, fall back to NCX (EPUB 2) if
unavailable
- Graceful degradation: books without any TOC now load with a warning
instead of failing

  ## Additional Context

* The implementation follows the existing streaming XML parser pattern
using Expat to minimize RAM usage on the ESP32-C3
* EPUB 3 books that include both nav.xhtml and toc.ncx will prefer the
nav document (per EPUB 3 spec recommendation)
* No breaking changes - existing EPUB 2 books continue to work as before
* Tested on examples from
https://idpf.github.io/epub3-samples/30/samples.html
Unintendedsideeffects pushed a commit to Unintendedsideeffects/crosspoint-reader that referenced this pull request Feb 17, 2026
## Summary

* **What is the goal of this PR?** Add EPUB 3 support by implementing
native navigation document (nav.xhtml) parsing with NCX fallback,
addressing issue Fixes: crosspoint-reader#143.

  * **What changes are included?**
- New `TocNavParser` for parsing EPUB 3 HTML5 navigation documents
(`<nav epub:type="toc">`)
- Detection of nav documents via `properties="nav"` attribute in OPF
manifest
- Fallback logic: try EPUB 3 nav first, fall back to NCX (EPUB 2) if
unavailable
- Graceful degradation: books without any TOC now load with a warning
instead of failing

  ## Additional Context

* The implementation follows the existing streaming XML parser pattern
using Expat to minimize RAM usage on the ESP32-C3
* EPUB 3 books that include both nav.xhtml and toc.ncx will prefer the
nav document (per EPUB 3 spec recommendation)
* No breaking changes - existing EPUB 2 books continue to work as before
* Tested on examples from
https://idpf.github.io/epub3-samples/30/samples.html
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.

EPUB 3 support missing

2 participants