Skip to content

Add "Split EPUB every N chapters" feature#2524

Open
AdolDev40 wants to merge 2 commits intodteviot:ExperimentalTabModefrom
AdolDev40:ExperimentalTabMode
Open

Add "Split EPUB every N chapters" feature#2524
AdolDev40 wants to merge 2 commits intodteviot:ExperimentalTabModefrom
AdolDev40:ExperimentalTabMode

Conversation

@AdolDev40
Copy link

Summary

Adds the ability to split a novel into multiple EPUB files based on a user-defined chapter count. Useful for very long novels where a single EPUB becomes too large.

Changes

New feature: Split EPUB by N chapters

  • New option "Split EPUB every N chapters" in the UI (popup.html)
  • Set to 0 (disabled) by default — existing behavior is unchanged
  • When enabled (e.g. N=20), generates multiple EPUBs with padded filenames:
    • NovelName 01 - 20.epub
    • NovelName 21 - 40.epub
    • NovelName 41 - 50.epub
  • Each split EPUB contains its own metadata, TOC, and images

Filename sanitization

  • makeNovelBaseName() removes characters invalid on Windows/Linux/macOS (<>:"/\|?*~) and control characters (0x00–0x1F)

Files modified

File Change
plugin/js/main.js Core split logic: saveSplitEpubs(), makeSplitFileName(), makeNovelBaseName(), getSplitChapterCount()
plugin/js/UserPreferences.js Added splitChaptersPerEpub preference (default: "0")
plugin/popup.html Added number input for split chapter count
plugin/_locales/en/messages.json Added label string for the new option
package.json Added contributor
readme.md Added contributor to Credits

Checklist

  • All existing unit tests pass
  • No ESLint warnings or errors
  • Feature can be turned off (set to 0)
  • Feature is off by default
  • Contributors updated in package.json
  • Credits updated in readme.md
  • Committing to ExperimentalTabMode branch

Anexo

{175ABA75-DAA5-4F09-85F2-5EB0372E5AEA} {72AA9EF1-9722-4306-B497-E7CB18278C68}

- Added 'Split EPUB every N chapters' option (disabled by default with N=0).
- Generates multiple EPUB files for long novels.
- Cleaned filenames to remove invalid characters for Windows/Linux/macOS.
- Ensured metadata and TOC are regenerated for each split block.
@gamebeaker
Copy link
Collaborator

Useful for very long novels where a single EPUB becomes too large.

What do you mean too large? We made sure that it can get bigger than 1gb.

@AdolDev40
Copy link
Author

Useful for very long novels where a single EPUB becomes too large.

What do you mean too large? We made sure that it can get bigger than 1gb.

I was mainly referring to my experience with e-reader hardware. When a file has 2,000+ pages, it takes a long time to load, and I have some books with 5,000 or even 10,000 pages.

@dteviot
Copy link
Owner

dteviot commented Mar 8, 2026

@AdolDev40

A couple of questions for you.

  1. Have you considered using the EpubSplit plugin for Calibre? https://github.com/JimmXinu/EpubSplit
  2. How does this interact with WebToEpub's library functionality?

Note, In general the policy of WebToEpub is to keep it as simple as possible. Additional epub processing is usually deferred to other tools.
I'm not going to reject this out of hand, but will defer to @gamebeaker if he thinks this is sufficiently valuable to include.

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.

3 participants