Repository navigation
Conversation
Accept embedded numbered chapter titles while preserving their original case and zero padding. Filename-derived names retain priority, titles identified as the book title remain excluded, and other generic titles still use fallback numbering. Regression coverage checks ordering, title preservation after an introduction, and the chapter metadata passed into merging; the documentation describes the behavior. Fixes kikootwo#509
Owner
|
@mvanhorn thanks for this, the diagnosis is right. I'm bringing it in on a branch of mine with you as co-author, with one change: the embedded "Chapter N" titles are kept only when they stay distinct across the whole book, so multi-disc sets that restart at "Chapter 1" on each disc keep today's numbering instead of getting duplicate names. I'll close this one when it lands. |
kikootwo
added a commit
that referenced
this pull request
Nov 2, 2026
…a merged book (#531) A merged book whose files are tagged "Intro", "Chapter 1", "Chapter 2" and whose file names hold no titles keeps those chapter names; before, every "Chapter N" tag was replaced by the file's position, so the intro shifted each chapter by one. The numbered tags are kept only when every title in the set is distinct (case and spacing folded, "Chapter 01" = "Chapter 1"), fallback names of untagged files included. Per-disc tags that restart at "Chapter 1", or an untagged intro beside "Chapter 1..N", keep position numbering as before. One log line says which way the set went. Closes #509 Based on #525 by @mvanhorn, with a check across the whole book so per-disc sets keep their numbering. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: mvanhorn <455140+mvanhorn@users.noreply.github.com>
Owner
Owner
|
@mvanhorn this is out in v1.2.13, landed in #531: https://github.com/kikootwo/ReadMeABook/releases/tag/v1.2.13 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Linked issue
Fixes #509
What changed
Accept embedded numbered chapter titles while preserving their original case and zero padding. Filename-derived names retain priority, titles identified as the book title remain excluded, and other generic titles still use fallback numbering. Regression coverage checks ordering, title preservation after an introduction, and the chapter metadata passed into merging; the documentation describes the behavior.
Why
Merging an audiobook with an introduction shifts subsequent embedded chapter numbers: “Chapter 1” becomes “Chapter 2” even though the audio remains in the correct order. getChapterTitle() treated embedded “Chapter N” titles as generic and replaced them with numbering based on file position. An introduction occupies the first position, so the fallback numbers no longer match the embedded chapter labels.
How it was tested
npx --no-install vitest run tests/utils/chapter-merger.test.tspassed all 25 tests.Ran
npm testin a Linux container (localhost/osc-linux-node:22) for the ReadMeABook getChapterTitle change; 6482 tests passed.The tests in
tests/utils/chapter-merger.test.tsfail without the fix in the ReadMeABook getChapterTitle change (checked by reverting the source changes).Checklist
npm testpassesdocumentation/updated in the compact format (bullets, tables, short code blocks), plusdocumentation/TABLEOFCONTENTS.mdif a doc was addedAI was used for assistance.