Repository navigation
Conversation
Refs #13 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Refs #13 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Refs #13 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Refs #13 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Refs #13 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Themes declare the strings under html-refs:, merged through extends like page:. Refs #13 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pillow becomes a direct dependency: the book needs it without the pdf extra. Refs #13 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
No inline TOC, and page-floated notes end their chapter instead. Refs #13 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
render_book writes a static directory: the theme CSS filtered for a browser, font sizes as shares of the reader's size, images as WebP, and a reader that pages with CSS columns, swipes, keeps rectos in a spread, follows in-book links and remembers the place by block. examples/html-book builds it next to two PDFs. Refs #13 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # docs/superpowers/plans/2026-10-20-html-book.html # scriptorium/cli.py # scriptorium/render.py
Each chapter is its own file and its own column strip. index.html carries the TOC, which chapter holds each id and each chapter's length; the reader loads the chapter it needs, counts the others' pages out of sight in idle time (cached per geometry, font size and edition), and estimates until then. Each section restarts the theme's CSS counters where the previous chapters left them. On an 861-page book at a phone size: ready in 0.44 s (0.70 s at CPU x4), a font change re-lays out in 28 ms (66 ms), crossing into a chapter takes 8-21 ms (35-110 ms), and all pages are counted 2.7 s (7.7 s) after opening. Refs #13 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Part 2 of 3 for #13, stacked on #14. Plan tasks 4-7.
What changed
scriptorium/book.py:browser_css()drops what only paged media runs (@pagerules including@page:left, page and slide boxes,string-set,target-counter()/target-text()/counter(page)declarations) and turns page breaks into column breaks.resolve_refs()writes cross-reference text into the emptya.ref-*anchors, counting chapters, sections and figures as the themes' CSS does. The strings live in each theme'stheme.ymlunderhtml-refs:, merged throughextends:.collect_images()writes local images as WebP (capped atimage-max-width, named by content) with intrinsicwidth/height.collect_css_assets()copies theme fonts.relative_sizes()turnsfont-size: Nptinto a share of the reader's size, so A−/A+ scales headings with the text.render_book()/emit_book()write the directory. It holds a cover, a title page and onesection.chapter.rectoper chapter, and a full page right before a chapter heading opens that chapter.themes/base/reader/:index.html,reader.css,reader.js. CSS multi-column layout makes the pages and the script never measures text. Each chapter is its own file (chapters/NNN.html) and its own column strip: the reader loads the chapter it needs, counts the other chapters' pages out of sight in idle time (cached per geometry, font size and edition) and estimates until then. Each section restarts the theme's CSS counters where the chapters before it left them. It provides swipe, tap zones, keys and wheel; rectos in a spread (a blank page goes in before a chapter heading that would land on the left); in-book links turn to their target; the place is stored by block, so it survives resizes and font changes. There are three reading modes, English and Spanish chrome,window.scriptoriumReader, andreader:ready/reader:page/reader:layoutevents. A project'sjs:files load after it.prepare(for_screen=True)skips the inline TOC and ends page-floated notes with their chapter.htmloutput builds the book;--format htmlbuilds one from a single file.examples/html-book/: three short chapters (langes) with outputsprint,pocket(A5) andweb.Measured
Unit tests:
test_book_css(7),test_book_refs(5),test_book_assets(6),test_book_html(10).Browser tests (
-m browser, Chromium found or skipped): 14 pass at 390×844 touch and 1440×900. They cover the TOC jump, turn and resume; arrow keys walking every page across all chapters in order and back; a swipe that starts on an image; rectos all on right pages; nothing spilling out of its page in any chapter (a 300-character word, a wide table, a long code line); a link to another chapter loading it; a reference in the same chapter; a font change keeping the first block; a#hashopening at its chapter; and no console errors.Layout cost on a 129,000-word book (861 pages at 390×844), one strip for the whole book against one strip per chapter:
The per-chapter count gives the same 861 pages as the single strip. Before the split, parsing the 1 MB index alone took 1.2 s, and the theme's styles plus the columns took 2.8 s more.
🤖 Generated with Claude Code