Skip to content

EPUB: split large XHTML flows and add MOBI page-break option - #32

Open
M-Kepler wants to merge 1 commit into
zacharydenton:masterfrom
M-Kepler:feature/huangjinjie/epub-flow-size-pagebreaks
Open

M-Kepler wants to merge 1 commit into
zacharydenton:masterfrom
M-Kepler:feature/huangjinjie/epub-flow-size-pagebreaks

Conversation

@M-Kepler

@M-Kepler M-Kepler commented Oct 13, 2026 •

Copy link
Copy Markdown

Closes #31.

Summary

  • Split oversized EPUB XHTML at safe element boundaries, including <br> boundaries inside a single large paragraph, while relocating links and TOC targets.
  • Match Calibre's CLI default --flow-size of 260 KiB for EPUB output. --flow-size N changes the limit, and --flow-size 0 disables size-based splitting.
  • Add --dont-split-on-page-breaks for MOBI input. It suppresses source page-break and NCX-position splits while leaving size-based splitting active. Without the flag, existing source page-break handling remains enabled.

The size limit is best effort where content cannot be split safely.

Validation

  • cargo test --locked
  • cargo clippy --locked --all-targets -- -D warnings
  • cargo fmt --check and git diff --check
  • Converted a 29.6 MB MOBI with one large paragraph and 114,991 line breaks. Both default conversion and --dont-split-on-page-breaks produced 53 XHTML files, largest 266,239 bytes (below 260 KiB). --flow-size 0 produced one XHTML file. All three outputs had identical body text hashes and line-break counts; ZIP, XML, and internal references checked clean.

This branch has not been deployed

No deployments
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.

Split oversized EPUB XHTML by size by default

1 participant