You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
build_html.py currently treats all non-picture pages as stitchable content and renders them as <p> paragraphs. This is wrong for:
Epigraph / front-matter pages (short isolated quote, e.g. page 8 "Law stops at atmosphere") — should be <section epub:type="epigraph"> or <blockquote>, NOT stitched to neighbours
Chapter openers — should trigger a new EPUB chapter, NOT stitch with the preceding page (this mostly works via the heading label already, but needs to be made explicit)
Brainstorm: docs/brainstorm.md § "Page-level classification for HTML assembly (design 2026-06-29)".
Page classes
Class
Detection
HTML output
Stitching
content
default
<p>
yes
chapter_opener
first token block label = title/heading
<h1>/<h2> + <p>
no (starts new chapter)
special_page
total_tokens < 40 AND no title/heading AND not picture
<blockquote> / <section epub:type="epigraph">
no
picture
picture_page=True
<figure><img src="images/page_NNN.jpg"/></figure>
no
Plan
Add classify_page(page_result) -> str function in build_html.py — pure heuristic, no model needed, operates on voted_tokens + picture_page flag already in consensus output.
Update build_book_html() to call it per page and route to the appropriate renderer.
Background
build_html.pycurrently treats all non-picture pages as stitchable content and renders them as<p>paragraphs. This is wrong for:<section epub:type="epigraph">or<blockquote>, NOT stitched to neighbours<figure><img>(see Image extraction from PDF: extract_images.py for picture-page embedding #34)Brainstorm: docs/brainstorm.md § "Page-level classification for HTML assembly (design 2026-06-29)".
Page classes
content<p>chapter_openertitle/heading<h1>/<h2>+<p>special_pagetotal_tokens < 40AND no title/heading AND not picture<blockquote>/<section epub:type="epigraph">picturepicture_page=True<figure><img src="images/page_NNN.jpg"/></figure>Plan
classify_page(page_result) -> strfunction inbuild_html.py— pure heuristic, no model needed, operates onvoted_tokens+picture_pageflag already in consensus output.build_book_html()to call it per page and route to the appropriate renderer.<figure><img>(requires images to be extracted, see Image extraction from PDF: extract_images.py for picture-page embedding #34).<blockquote>with no stitching on either boundary.Depends on
Acceptance criteria
classify_page()function with tests covering all four classes<blockquote>in book.html<figure><img>pointing to extracted images