Skip to content

Preview a whole chapter, from any build - #272

Merged
mikemaccana merged 1 commit into
mainfrom
claude/preview-chapters
Oct 5, 2026
Merged

mikemaccana merged 1 commit into
mainfrom
claude/preview-chapters

Conversation

@mikemaccana

Copy link
Copy Markdown
Collaborator

npm run preview could only render the single page carrying a phrase, from the digital edition. It now also renders a whole chapter, and can read any build.

npm run preview -- <name> "<phrase>"                 # the page carrying the phrase, as before
npm run preview -- <name> --chapter escrow           # every page of one chapter
npm run preview -- <name> --chapter escrow --pdf "build/…(paperback interior).pdf"
  • Page map. The build now writes <pdf name>.pages.json beside each PDF, giving each chapter's file, title, and first and last page as laid out. A chapter preview therefore shows the book's own pages, broken where that build breaks them, without rebuilding the chapter on its own.
  • Matching. --chapter matches on file name or title, case-insensitively. A query that matches several chapters lists them and exits, unless it is exactly one chapter's file name (intro picks intro.md over introduction.md).
  • Chromium. Preview falls back to Homebrew's Chromium the same way the build does.

Docs brought in line with the code

  • CLAUDE.md
    • Said preview's first argument was a chapter. It is a name prefix for the PNG files.
    • Said the build prints only the output path. It also prints the trim crop line.
  • PRINT-SPECIFICATION.md
    • The cover example used 308 pages. It now uses the current 307 (15.821 x 9.94in, 0.691in spine).
    • Now documents resize-cover --out, the page map, the new preview options, and the full Chromium lookup order.
  • README.md: the Chromium lookup order, and a pointer to npm run preview.

Verified

  • npm run lint, node scripts/check-figure-geometry.mjs and npm run build-pdf-digital pass.
  • The page map lists all 28 sections, and the paperback interior's map is shifted by the 2 cover pages as expected.
  • Chapter previews render the right pages from both the digital and paperback builds. The phrase preview still works. An ambiguous --chapter amm lists the two AMM chapters.

🤖 Generated with Claude Code

https://claude.ai/code/session_01KtTPqhYezQFvpkDqQFUUVT


Generated by Claude Code

npm run preview -- <name> --chapter <file name or title> renders every
page of one chapter, and --pdf <file> reads a build other than the digital
edition. The build writes a page map beside each PDF giving each chapter's
first and last page, so a chapter preview shows the book's own pages,
broken where the build breaks them.

Docs brought in line with the code: CLAUDE.md described preview's first
argument as a chapter and said the build printed only the output path;
the cover example in PRINT-SPECIFICATION.md used an old page count; and
resize-cover's --out and the macOS Chromium fallback were undocumented.
The preview now falls back to Homebrew's Chromium as the build does.

Claude-Session: https://claude.ai/code/session_01KtTPqhYezQFvpkDqQFUUVT
@mikemaccana
mikemaccana merged commit dfec165 into main Oct 5, 2026
1 check passed
@mikemaccana
mikemaccana deleted the claude/preview-chapters branch October 13, 2026 00:23
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.

1 participant