A book stamped <html data-webbook-contract="0"> guarantees everything listed here. A UI release
(the CSS and JS under template/src/, or a remote release on the v0/ channel) may rely on
these and nothing else. Anything not listed must be feature-detected.
Compatible UI changes ship within the v0 channel. A new incompatible contract requires
reconverting from the original EPUB; there is no webbook-upgrader. Keep the source EPUB.
Optional reader features must feature-detect their supporting files in older books.
src/template-contract.ts checks the converter’s side: the hooks it fills in, and that the
template declares contract 0.
New v0 conversions contain plain content and standalone navigation pages. Reader controls are
built by JS from the release’s shell before feature initialization. Compatible control/styling
changes therefore do not require rewriting content. Earlier v0 books may contain embedded
chrome; release code feature-detects that shape and keeps it working. The detailed chrome hooks
below describe that legacy shape and the current reader’s internal DOM, not requirements on
newly generated content pages. The authoring template still has converter hooks, validated by
template-contract.ts; those are separate from the delivered-content contract.
webbook-style-* classes
and boxes as webbook-box; these add no semantics. Hidden/invisible/visible classes apply
in both looks. Other reader classes and boxes apply only in the reader look.data-webbook-has-published on <html> identifies publisher CSS availability. The reader
adds an “Appearance option” section before Colors: My settings (default) or As published, remembered
for each book under webbook-appearance:<book-id> (settings|published, read in appearance.js;
not in a settings file, cleared by Reset).
With As published, the reader sets data-webbook-appearance="published"; without JS it is absent.
--no-publisher-styles omits CSS and the availability attribute. There is no old-name compatibility.link[rel="stylesheet"][data-webbook-publisher-style] loads styles/publisher-<content-hash>.css.
Identical sheets share a file. CSS is conditional on the appearance attribute, scoped to source
publication elements and layered under publisher (source, inline, source-important,
inline-important). Reader elements (data-webbook-reader, .webbook and its descendants)
are excluded. Native SVG/MathML styles remain. Page navigation loads the next sheet while
retaining the audio element. Root frame properties are omitted and renamed ids resolved.webbook-publisher-r* and webbook-publisher-s* freeze source selectors whose
source target sets change, retaining specificity and dynamic states. Newly inserted reader
elements never cause freezing. Temporary data-webbook-publisher-source identifies source
elements during transformation and is removed before output. Converter wrappers are marked
data-webbook-reader on the wrapper itself, allowing its publication descendants to be styled.webbook-publisher-only marks styled empty paragraphs hidden only in My settings; they add no
narration/search text. data-webbook-inline-style identifies extracted inline declarations.switch-appearance action defaults to Alt+Shift+D; its label is “Switch between As published
and My settings”, and it announces the chosen look. The Appearance group has search keywords
for the hidden preferences; hidden rows do not count as found.webbook-appearance-hidden. Saved values return in My settings. One
explanation in Appearance replaces the controls. Highlight, captions and other settings remain.
There are no paused notes or descriptions. Reader settings are not translated from old look keys.CSS fonts/images are copied and URLs rewritten relative to the stylesheet. IDPF and Adobe font obfuscation is removed using the original package identifier; other encryption is skipped and reported. Reports count retained, frozen and unapplied selectors and copied assets.
<html lang="…" data-webbook-contract="0"><html> (plan 28), from the book’s own CSS and package:
data-webbook-writing-mode: vertical-rl |
vertical-lr, when the page’s text is vertical |
data-webbook-line-break: strict |
loose |
anywhere; data-webbook-word-break: |
keep-all |
break-all (a language’s line-breaking rules, for the whole page) |
data-webbook-page-progression="rtl" when the spine’s page-progression-direction is rtl<head>:
<title><meta name="webbook-book-id" content="…"> (the book identifier; resume position is keyed on it)<link rel="stylesheet" href="src/css/style.css"><script type="module" src="src/js/main.js"> at the end of <body>src/css/ and src/js/ relative to each page. In a converted book, src/css/style.css
holds all the UI’s CSS: the converter inlines the template’s @imported component files into it,
in order, and leaves those files out. Pages are flat files in one
directory (index.html is the entry page). The UI does not rely on any other asset path.sw.js at the book root, reserved for offline reading. Its content is fixed:
importScripts('src/js/offline-worker.js'); (plus a comment). Offline controls register it on
first use, with explicit book-root scope and updateViaCache: 'none'. It is at
the root because a service worker only controls pages at or below its own folder;
src/js/offline-worker.js is UI and free to change.search-data.json at the book root contains versioned book search data. If it’s
missing, the reader reports that search is unavailable rather than failing.conversion-report.md describes converter changes, warnings and requested optional checks. It is
a conversion record rather than a reader dependency, for people to read; its wording isn’t a
format. There is no machine-readable report.src/ui-files.json is generated after combining CSS: { version: 1, contract: 0, revision,
files: [{ href, bytes, sha256 }] }. Files are every shipped file under src/, sorted in path
order, excluding the inventory itself. URLs are relative to the book root, SHA-256 is lowercase
hex, and revision hashes the UTF-8 JSON.stringify(files). This includes lazy/vendor files.
An older book can read normally without this file, but cannot claim a complete offline save.
A complete local reader-package update supplies it without changing book HTML or root sw.js.src/js/offline-worker.js is a classic loader; the local implementation is
src/js/offline-worker-core.js, with offline-range.js and offline-network.js. Long downloads
run in the page-owned offline-download-worker.js, sharing the core through foreground mode,
so they are not a single long-lived service-worker event. The fixed root stub is not rewritten.
The compatibility bridge (not selected by the current reader, which requires local workers)
allows worker script update URLs to carry validated webbook-channel/webbook-worker query values
for an immutable channel release, while scope stays the same. An imported remote bundle must
export self.WebbookOfflineWorker = { protocol: 1, version, start } without attaching handlers
until start(). It can bundle WebbookOfflineRange; failed loads use the full local core,
incompatible factories fail installation, and active readers are not forced through skipWaiting.{ webbookOffline: 1, protocol: 1, command, ... }.
Commands are status, saved-ui, begin-save, end-save, notify, cancel, remove, activate;
the SDK routes save through the foreground downloader (which accepts save and cancel); replies are { result }, { error }
or intermediate { progress: { phase, done, total, bytes } }. Calling clients must be content
pages in this book’s exact root, or a same-origin src/offline-books.html management page. No arbitrary worker URL is accepted in a message.status includes protocol/workerVersion/scope, saved, complete, pending, pendingIncomplete, busy, recovering.
A snapshot contains cache name, files/validators/sizes, bytes, savedAt and ui descriptor.
save receives a discovered file list (optional reusable Blob bodies) and ui:
{ contract: 0, localRevision, protocol: 1, remote?, localOnly? }. A foreground lease records
its owner client and staging cache, renews every 30 seconds and expires after 120 seconds or
loss of the owner. Cancellation and commit check the lease transactionally. The page must stay
open. Compatible remote factories accept start({ scope, foreground }) as well as normal
service-worker startup; localOnly selects the local download core. Every required UI hash and inventory
entry is verified. Optional remote records a selected channel/version and the complete
SHA-256 file inventory under its immutable <version>/ directory, alongside local fallback.
The remote bootstrap asks for the saved UI descriptor before selecting current.json.webbook-offline-1 stores books,
snapshots, pins. Cache prefix webbook-offline-1-<SHA256(root URL)>- isolates copies even
with identical EPUB identifiers. Pins keep an open client on its generation across worker
restarts. An explicit webbook-offline-recover=1 navigation selects a whole online recovery
copy if required cached files are missing. Its query marker is removed after startup; a client
pin keeps all subsequent resources online until a re-save is explicitly activated. Storage
denial on an unsaved book falls through to ordinary network reading. Save/Update stages beside the working copy; activate requires other book tabs to
close and is followed by an explicit reader reload. Unknown schemas are not cleared silently.X-Webbook-Offline-Network: 1 requests, including foreground GET/HEAD, to bypass the pinned content. No automatic
reading cache, background download guarantee or required converter book manifest exists.
Legacy update checks compare discovery and available HTTP validators; unreliable checks are
labeled as such and allow an explicit full refresh. Generation integrity without publisher
revision metadata has the limits described in the approved design note.section#webbook-offline in About, its heading/status/storage text, labeled
native progress/count, save/size/cancel/check/update/use/remove controls, inline Remove
confirmation, and button#webbook-offline-indicator in the top toolbar while offline.
Actions are registered with no default shortcut. New sections remain optional for old pages.search-data.json (optional)Version 1 is { version: 1, lang, pages, passages }. pages contains { href, title } in spine
order. Each passage contains { page, heading, text, lang? }; page indexes pages, and lang
is present only when it differs from the book language. A narrated passage has its cue’s Web
Annotation selector (or an id when the cue target keeps one). A non-narrated passage instead has
selector: { type: "TextQuoteSelector", exact, prefix?, suffix? }. The browser builds its own
index from this data on first search and resolves selectors against <main>.
audio-map.json (optional)Version 1 is { version: 1, duration, pages, chapters }. duration and all times are seconds.
pages contains every spine page as { href, title, start, duration, audio }; unnarrated pages have a
zero duration and no audio (the page’s narration file, relative to the book root). chapters contains ascending top-level TOC positions as { title, href, time }. toc contains
every TOC entry, at every level and in TOC order, whose heading has narration, as { href, time, end }:
the book time span that speaks the heading at that entry’s target (the target, or the first heading
in it; without narration in a heading, the first phrase at or after the target). Its href matches
the TOC link’s. Reserved for a talking TOC; nothing uses it yet.
When present, the UI enhances the per-page narration slider into a full-book timeline; without it
(no narration, or the map can’t be fetched) the slider stays per page.
This runs before first paint and is baked into every page, so no release can change it. It reads:
| Key | Values | Effect |
|---|---|---|
webbook-appearance |
auto | dark | light |
webbook-dark or webbook-light class on <html> |
webbook-font-size |
integer, clamped to 50–200 | --webbook-main-font-size: N% on <html> |
webbook-font-family |
system-ui | sans-serif | serif |
--webbook-main-font-family on <html>: the value itself, except serif, which is Charter, "Bitstream Charter", serif, and sans-serif, which is "Avenir Next", Verdana, sans-serif |
webbook-caption-mode |
'true' |
webbook-caption-mode class on <html> |
webbook-writing-mode |
'horizontal' |
with data-webbook-writing-mode set and this key not horizontal: webbook-vertical class on <html> (and webbook-vertical-lr for vertical-lr) |
Releases must keep writing these keys with these meanings and value ranges, and CSS must honor these classes and custom properties.
Caption mode is global. Both this script and the UI read the shared webbook-caption-mode key.
The former per-book caption and color keys are ignored; there is no migration of their values.
<main>)<main> holds the page’s book content. It is the boundary for structure lookups. It has
id="webbook-main", the skip link’s target.xml:lang is removed. Its value is copied to HTML lang only when most letters use the
declared script; text with no letters and suspect values inherit their surrounding language.
A tag whose expected script cannot be determined is copied.-content added, and internal links, navigation and narration selectors use the renamed target.epubtype_<type> (: becomes _). The UI relies on:
epubtype_pagebreak (with aria-label holding the page label)epubtype_footnote, epubtype_endnote, epubtype_note, epubtype_sidebarepubtype_table, epubtype_list, epubtype_figuretable, ol, ul, figure elements are also treated as escapable structures, and so
is MathML math (an equation narration reads on its own).div.webbook-table-scroll[role=region][tabindex="0"]. The wrapper is named by its caption’s id,
or by aria-label="Table N" when it has no caption. It has no id of its own. Reader JS removes
role, tabindex and the ARIA name whenever the table fits, retaining the name in
data-webbook-label or data-webbook-labelledby; it restores them when horizontal scrolling
is needed. Without JS the labeled scroll region remains keyboard-operable.span and div wrappers with only class/style/title attributes are removed too. Narration selectors are
generated after this final cleanup; narrated target elements themselves are preserved.webbook-equation, containing one MathML expression
(possibly inside neutral wrappers) and a short number marked webbook-equation-number.
The expression branch is wrapped in span.webbook-equation-scroll[role=region][tabindex="0"],
named with aria-label="Equation (1.1)" using its actual number. DOM order and MathML are kept.
CSS centers the expression and puts the number at the logical line end, below at narrow widths.
Reader JS uses data-webbook-equation-stacked when an expression needs the full line and keeps
the named region/tab stop only while it scrolls (the name is retained in
data-webbook-equation-label). The wrapper still scrolls without JS.data-webbook-math-wide (which gives it overflow-x: auto) and adds a temporary Tab stop,
preserving native math semantics and restoring the original focus hook from
data-webbook-math-tabindex when it fits. Other inline MathML doesn’t scroll, so glyphs taller
than the line add no Tab stop. Without JS, wide inline MathML overflows its line. Display
equations use their outer scroll wrapper.h* > a.webbook[rel=bookmark][href="#<heading id>"].dir from the source <html> or <body> is on <main> (the book’s text; the reader’s own
controls keep theirs).-epub-, -webkit- and standard spellings), only where an element’s value differs
from what it inherits; a page-wide one is on <main>. The UI styles them in standard CSS:
webbook-style-combine and -combine-none (text-combine-upright);
webbook-style-glyphs-upright, -sideways, -mixed (text-orientation);
webbook-style-horizontal, -vertical-rl, -vertical-lr (writing-mode);
webbook-style-emphasis-<shape>[-open] for dot, circle, double-circle, triangle,
sesame, and -filled, -open, -none (text-emphasis-style, in the text color);
webbook-style-emphasis-over, -under, -left, -under-left (text-emphasis-position);
webbook-style-fullwidth (text-transform: full-width); webbook-speak-spell-out, -digits,
-literal-punctuation, -no-punctuation (speak-as, hints only).section.webbook-title-page with img.webbook-title-cover, .webbook-title-kicker.<audio> in #webbook-toolbar with src
or source[src]. On a page without narration the converter removes <audio>,
#webbook-narration-position and #webbook-audio-controls.--no-small-audio it
keeps the source’s format instead, with the highest channel count, sample rate and bitrate among
that page’s sources (MP3 sources produce MP3 without an intermediate lossy encode).--no-audio-cleanup is used, clips have short fades at joins and each joined page is
low-cut filtered (rumble), de-plosived and normalized with a two-pass loudness measurement. The enhancement
filters (all five by default; --audio-enhance chooses) do not change the page or cue duration.<track> child: WebVTT metadata. Each cue’s text is JSON containing a Web Annotation
selector. It is a FragmentSelector when the phrase itself has a retained id; otherwise it is a
structure’s FragmentSelector with a scoped CssSelector in refinedBy, or a main-relative
CssSelector when no anchoring structure exists. The UI resolves and caches every cue element as soon as the track loads, before any
feature changes the publication DOM.All IDs below are present on every page unless marked optional.
The chrome is in the order it appears on screen, so Tab follows it: the skip link, the top toolbar,
<main>, spine navigation, then the bottom toolbar.
a#webbook-skip-link.webbook (optional)<body>, href="#webbook-main", text “Skip to text”. The UI handles it: focus goes to
the reading position (the phrase being read aloud, else the phrase or structure at the reading
line). #webbook-main doesn’t go into the URL or move the narration.nav#webbook-spine-nava#webbook-previous-document: has href when a previous page exists. On the entry page it is
removed (converter output) or has no href (hand-authored template). The UI treats “no
#webbook-previous-document[href]” as “this is the entry page.”a#webbook-next-document[rel=next]: has href when a next page exists; removed otherwise.#webbook-spine-nav a[rel=next|prev][href].nav#webbook-basic-navFor reading without JavaScript, the first element in <body>: a button[popovertarget="webbook-toc-nav"]
(“Contents”), and a#webbook-basic-previous[rel=prev] and a#webbook-basic-next[rel=next] with
the page titles as text (removed when there’s no such page). The TOC has a
button.webbook-basic-close[popovertarget="webbook-toc-nav"][popovertargetaction=hide]. The
toolbar’s <audio> has controls. CSS hides all of these, and shows the toolbars, when <html>
has webbook-dark, webbook-light or webbook-js, i.e. when the reader’s script runs; without
it, CSS hides the toolbars except the <audio>, which shows the browser’s player.
nav#webbook-toc-nav[popover].webbookh2#webbook-toc-nav-hd; optional a#webbook-cover-link points to the cover document identified
by EPUB landmarks or the EPUB 2 guide (it is omitted when the EPUB identifies only a cover image).
The UI moves this link to the About panel.ol > li > a. The link for the current page has aria-current="page", but only when a
link points at the page itself: when every link to a page has a #fragment, none is marked. The
UI marks the entry for the reader’s section itself when the TOC or About panel opens.data-webbook-narrated and ends with span.webbook-narrated-mark (an
aria-hidden icon and .sr-only text “, narrated”). A p#webbook-toc-narration-key[aria-hidden]
before the list explains the icon. A fully narrated or unnarrated book has none of these.section#webbook-top-toolbar.webbookbutton[popovertarget="webbook-search"], button[popovertarget="webbook-menu"]div#webbook-escape-containerdiv#webbook-escape-status[role=status]: empty at load, always in the DOM (live region)button#webbook-escape-btn[hidden][disabled] containing span#webbook-escape-labeldiv#webbook-resume-banner[role=status][hidden]section#webbook-toolbar.webbookIn this order:
div#webbook-narration-position[role=group] (optional, see Narration) containing
span#webbook-time and input[type=range]#webbook-seekbutton[popovertarget="webbook-toc-nav"]div#webbook-audio-controls[role=group] (optional, see Narration) containing
button#webbook-previous-phrase, button#webbook-audio-playpause, button#webbook-next-phrasebutton[popovertarget="webbook-info"], button[popovertarget="webbook-settings"]The two groups are present together or not at all.
main[data-webbook-print-page-before] optionally carries the last print-page label from an
earlier web page. The value is the publication’s label, which may be roman or otherwise
non-numeric. It is omitted before the publication’s first pagebreak.
section#webbook-menu[popover].webbookinput#goto-page[list=pages], button#webbook-goto-page-godatalist#pages of option[value][data-href] (label may differ from value)section#webbook-search[popover].webbookh2#webbook-search-hd, form#webbook-search-form[role=search], input#webbook-search-input,
ol#webbook-search-results[aria-live=polite]section#webbook-info[popover].webbookimg#webbook-cover, .webbook-info-body, h2#webbook-info-hd, dl of metadatasection#webbook-accessibility at the end of .webbook-info-body: h3#webbook-accessibility-hd,
a p.webbook-accessibility-source, then an h4 and ul per section of the source EPUB’s
accessibility information, in the W3C Accessibility Metadata Display Guide 2.0’s order and
descriptive wording (Ways of reading and Conformance always; the others when there’s metadata)section#webbook-progress containing p#webbook-current-page-label,
progress#webbook-reading-progress[max=100], p#webbook-progress-counta#webbook-cover-link here and styles it as .webbook-cover-page-link.section#webbook-settings[popover].webbook| Control | Type |
|---|---|
#webbook-highlight-auto-toggle |
checkbox |
#webbook-color-picker |
color |
#webbook-font-size-range (50–200, step 5), #webbook-font-size-value, #webbook-reset-font-size |
range, text, button |
#webbook-font-family-options (system-ui, sans-serif, serif) |
select |
#webbook-appearance-options (auto, dark, light) |
select |
#webbook-dialog-blur-toggle |
checkbox |
#webbook-caption-mode-toggle |
checkbox |
#webbook-rate-range (50–200, step 5), #webbook-rate-value, #webbook-reset-rate |
range, text, button |
#webbook-skip-pagebreak-toggle, #webbook-skip-footnote-toggle (“Skip notes”: footnotes, endnotes and generic notes), #webbook-skip-sidebar-toggle |
checkbox |
#webbook-resume-toggle |
checkbox |
The panel retains h2#webbook-settings-hd. Section headings and containers are created by the UI;
there is no fieldset around the whole panel.
The JS creates these, so a release may change them freely:
.webbook-popover-close buttons in each popoversection#webbook-caption-view with #webbook-caption-text; caption text preserves note-reference
numbers as <sup> without adding brackets or copying links, ids or publication styles#webbook-keyboard-shortcuts-toggle and its row), added to the
Keyboard section if the page doesn’t already have itsection#webbook-keyboard-shortcuts[popover], a separate panel with grouped action lists,
current keys, Change/Remove controls, an individual Restore default control for changed bindings,
visible and announced two-step conflict warnings for reassignment and restoration, and Reset to
defaults.
#webbook-shortcut-status[role=status] inside it announces capture instructions, results and
refusals.#webbook-action-status[role=status].sr-only, a polite live region outside the popovers for
narration speed, text size, caption mode and requested time-left announcementscopy-position-link reader action, with no default shortcut, copies the page’s URL,
which always points at the reading position, and announces the result through #webbook-action-status.button#webbook-where-am-i in #webbook-top-toolbar, before the Search button, and the
where-am-i reader action (no default shortcut; it also runs in an open panel on a key with
Alt, Ctrl or Cmd). It announces through #webbook-action-status and adds nothing to the
publication content..webbook-settings-filter[role=search] at the top of Settings, before Jump to: input#webbook-settings-filter
(Find a setting) and p#webbook-settings-filter-status[role=status]. Filtering hides rows and
sections with the class webbook-settings-filtered (never hidden, which the panel uses for its
own reasons) and puts webbook-settings-filtering on the panel.#webbook-writing-mode-row with select#webbook-writing-mode (Writing direction) in the Text
settings section, hidden unless the page has data-webbook-writing-mode; html.webbook-vertical
while vertical text is shown, and html[data-webbook-line-length] with the Line length step.button#webbook-continue-playing, shown when the browser refuses to start narration on a page
the reader arrived at while listeningp#webbook-search-status[role=status] above the results list; the UI removes aria-live from the
list itself so only the concise result count is announcedwebbook-js on <html> (set by toolbar.js), marking that the reader’s script runs.visible (toolbars), .open (popover buttons), webbook-dark,
webbook-light, webbook-caption-mode, webbook-dialog-backdrop-blur on <body>::highlight(narration), colored by --webbook-highlight-bg, --webbook-highlight-fg and
--webbook-highlight-line on <body> (worked out against the background behind the narrated
phrase), and data-webbook-highlight-style (underline | both; absent for a background) on
<html>div#webbook-highlight-style with
select#webbook-highlight-style-options), after #webbook-colorfieldset#webbook-text-spacing with a legend and
select#webbook-line-height-options, #webbook-letter-spacing-options,
#webbook-word-spacing-options and #webbook-line-length-options, after #webbook-font-family.
A chosen step sets --webbook-line-height, --webbook-letter-spacing, --webbook-word-spacing
or --webbook-line-length on <html>, and the first three also a data-webbook-line-height,
data-webbook-letter-spacing or data-webbook-word-spacing attribute therediv#webbook-colors with select#webbook-colors-options (Automatic, Light,
Dark, reviewed color pairs and Custom), then
div#webbook-colors-custom (hidden unless Custom) with input#webbook-colors-background-picker,
input#webbook-colors-text-auto-toggle, input#webbook-colors-text-picker and
p#webbook-colors-contrast, in the static Appearance row’s place. Chosen colors set data-webbook-colors and --webbook-page-fg,
--webbook-page-bg, --webbook-page-focus, --webbook-page-muted, --webbook-page-search-bg,
--webbook-page-search-fg and --webbook-page-scheme on <html>; they apply one palette to the
publication, page, toolbars, panels, dialogs, controls, caption mode and navigation, over the
book’s own colorsdiv#webbook-toolbar-auto-hide with input#webbook-toolbar-auto-hide-toggle
(“Hide toolbars automatically”), after #webbook-dialog-blur-toggle’s row. Off, the toolbars and
page arrows stay .visible::highlight(search), used for matched words after following a resulttabindex="-1" on each narrated element in <main> that isn’t already focusable, so a screen
reader’s cursor brings keyboard focus with it (used by Play from here)--webbook-font-scale on <html>, the font size setting as a unitless factortabindex, aria-expanded, hidden nested groups,
.webbook-toc-chevron pointer controls, and #webbook-toc-depth-control with
select#webbook-toc-depth, div#webbook-toc-find (a labeled input#webbook-toc-find-input and
p#webbook-toc-find-status[role=status])div#webbook-book-timeline around the narration slider, containing #webbook-timeline-label
(the chapter and time under the pointer, or of the slider’s value on focus and while dragging)button#webbook-time-mode around #webbook-time, cycling the visible timeline value between
elapsed time, chapter time left and book time left. Its accessible name is its visible text; what
it does is in aria-description and title.span#webbook-current-print-page in the top toolbar’s Go to page button. When a current print
page is known it replaces the button’s icon with a visible Page <label> and updates the
button’s accessible name.p#webbook-about-print-page in About’s reading-progress section, showing the same current print
page without live-region behaviorbutton#webbook-note-phrase-btn and #webbook-note-status[role=status] in the escape container;
#webbook-note-menu[popover][role=menu] for phrases with several references; and the floating
button#webbook-back-to-text in the same wrapping escape container, so floating controls never
overlap each other at narrow widths. A reference visit shows Back to text alone for leaving
that note; the escape action remains keyboard-accessible through the same return point.
Nested tables/lists retain their own Leave control because they have a different destination.
Note-return data is stored in the note history entry rather than
publication markup. Three settings rows in the Notes section: select#webbook-note-references-options (“At a phrase with notes”),
#webbook-note-wait-sound-toggle (“Play ticking sound while paused”), and
#webbook-note-auto-return-toggle (“Go back to the text after a note”).
After a phrase’s note wait or automatic note visit, narration resumes at the next playable cue,
respecting the reader’s skip settings.
The ticking checkbox stays visible but disabled unless Pause briefly is selected, preserving
its saved value. Waiting ticks are off by default. When enabled, the brief pause plays quiet ticks every half second;
these stop when the option is turned off, narration resumes, the
reader goes to a note or seeks, the wait is canceled, or the page changes. This uses the
reader’s Web Audio context and does not depend on the optional structure-sound toggles.#webbook-escape-btn is labeled “Leave …”;
it leaves the nearest escapable structure. Browsing endnotes offers Leave notes for the whole
section; nested tables/lists retain their own escape.
With no following cue or page, Leave stops at the end of narration, clears the highlight/caption
and announces the end of the book. The existing skip-past action id and webbook:skippast
event remain for compatibility. Exclusion preferences keep their existing webbook-skip-*
storage keys and control ids, under the visible legend “Exclude from narration”; these
preferences do not create escape buttons. Manual Back to text exits an entire queued note
visit; automatic note completion alone continues the remaining notes.#webbook-sound-headings-toggle,
#webbook-sound-notes-toggle, #webbook-sound-lists-tables-toggle.div.webbook-agent-tools-row in Settings with
input#webbook-agent-tools-toggle[type=checkbox], labeled “Let AI assistants in this browser
control the reader”, created only when the browser exposes WebMCP.The reader also creates equation/code Copy controls (not publication contract ids):
span.webbook-copy-unit around display MathML, or div.webbook-copy-unit.webbook-copy-code
around a pre, with a button after the source, never inside a code listing. MathML includes
math[display=block], .webbook-equation math, .disp-formula math, and an expression that is the only content of its
block. Wrapping and focus hooks are added only after narration cue elements are resolved.
Inline math has no Copy button; tabindex=-1 permits screen reader focus, with a temporary
Tab stop when the expression needs keyboard scrolling.
An overflowing display equation or code listing gets a temporary Tab stop for keyboard scrolling;
it is removed when the source fits again. Copy controls add no text to a narrated phrase’s
textContent.
Copy equation, Copy selection and Copy code are reader actions registered without default keys
(no menu: selecting text and the browser’s own Copy covers inline math). Controls are hidden without a secure context and Clipboard API. The Text section creates
select#webbook-copy-math-options; webbook-copy-math-format stores mathml (default) or latex
and participates in settings export/import/reset.
Equation clipboard payloads include MathML in text/html, with reader attributes removed, and
LaTeX or MathML in text/plain. LaTeX uses a non-empty annotation[encoding=application/x-tex],
then non-empty alttext, then lazy reader-side conversion; failure preserves complete MathML.
Text selections containing math keep complete expressions in HTML and use $…$ around LaTeX.
Code is plain text from pre.textContent, without buttons. Conversion preserves MathML fallback
images by copying/rewriting math[altimg] through the image registry. alttext stays as the book
has it, empty or not; no alternatives or TeX are added to publication content.
The vendored converter is mathml-to-latex 1.8.0 (MIT), 169,560 bytes with its license and native DOMParser adaptation, 36,975 bytes gzipped. It loads on the first copy that needs conversion.
Other tools may use this versioned format. Export downloads webbook-settings.json:
{
"format": "webbook-settings",
"version": 1,
"exported": "2026-11-10T12:00:00.000Z",
"settings": { "webbook-colors": "sepia", "webbook-font-size": null }
}
settings maps the preference keys in settings-file.js to localStorage strings or null (unset,
use the default). Export includes every registered key; shortcut mappings retain their JSON string
representation. Reading positions, one-shot navigation flags and tab state are excluded. Import
validates the complete file before writing: wrong formats, unsupported versions and invalid known
values are rejected; unknown keys are ignored, missing keys retain their current values, and null
removes a preference. Import and reset reload the current page while keeping its position and
narration time. Reset removes only registered preference keys. The UI’s sections, jump links,
transfer buttons and two-press reset confirmation are not publication contract ids. The three
transfer actions (export-settings, import-settings, reset-settings) have no default shortcuts
and can be assigned in the shortcut editor.
When enabled and the browser implements WebMCP, the UI registers these stable imperative tools on
document.modelContext (with the older navigator.modelContext as a fallback): reader_status,
list_contents, go_to, narration, set_reading_option, search_book, and read_text.
Registration is progressive enhancement and failures do not affect reading. Turning the global
setting off aborts all registrations. Search results and returned publication text carry WebMCP’s
untrusted-content annotation; no tool exposes state from another book or arbitrary storage.
localStorage)Books from different releases, and different books on the same origin, share these keys, so a release must keep reading values written by earlier v0 releases.
| Key | Values |
|---|---|
webbook-appearance |
auto | dark | light, read by the inline script to choose the light or dark base before the first paint. Written by the Colors setting to match its choice (auto for Automatic, otherwise by the chosen background), so pages load without a flash. A light or dark value from before the Colors setting becomes its choice once |
webbook-appearance-migrated |
'true' once that has happened |
webbook-font-size |
integer string, 50–200 in steps of 5 |
webbook-font-family |
system-ui | sans-serif | serif |
webbook-copy-math-format |
mathml (default) | latex: plain-text form for equations; HTML always contains MathML |
webbook-caption-mode |
'true' | 'false' (default false): global caption mode, also read by the inline appearance script |
webbook-caption-entry |
'first' | 'last' (one-shot, cross-page): the phrase to start at after stepping across a page boundary, in or out of caption mode |
webbook-highlight-auto |
'true' | 'false' (default true) |
webbook-highlight-color |
CSS hex color |
webbook-highlight-style |
background | underline | both (default background) |
webbook-line-height |
1.8 | 2; unset is 1.6, the reader’s own |
webbook-letter-spacing, webbook-word-spacing |
wider | widest; unset is no extra spacing |
webbook-line-length |
narrow | medium | wide; unset is medium. Horizontal text: 50 and 65 characters, within half and three quarters of the text’s width, and all of it; vertical text: columns of 20 and 30 characters, and the whole height |
webbook-writing-mode |
horizontal: a book with vertical text is shown horizontally; unset follows the book (global) |
webbook-colors |
unset (Automatic) | light | dark | cream | sepia | gray | blue | custom, globally. Legacy auto, white and black read as Automatic, Light and Dark. |
webbook-colors-text, webbook-colors-background |
CSS hex colors for the shared custom choice |
webbook-colors-text-auto |
'true' | 'false' (default true): automatic custom text color, globally |
webbook-dialog-backdrop-blur |
'true' | 'false' (default true) |
webbook-toolbar-auto-hide |
'false' while the toolbars stay shown; unset hides them automatically (global) |
webbook-rate |
integer string, 50–200 in steps of 5 |
webbook-time-display |
elapsed | chapter | book (default elapsed) |
webbook-skip-pagebreak, webbook-skip-footnote, webbook-skip-sidebar |
'true' means skip, 'false' means play; when unset, notes (webbook-skip-footnote: footnotes, endnotes, a book’s endnotes section, and generic notes) are skipped and the others played |
webbook-resume-enabled |
'true' | 'false' (default true) |
webbook-keyboard-shortcuts |
'true' | 'false' (default true) |
webbook-note-references |
What narration does at the end of a phrase with note references: 'button' (default; carry on, with the note button), 'pause' (pause for 2 seconds), 'follow' (go to each note, then back) |
webbook-note-auto-return |
'true' | 'false' (default true): after reading a note it went to, narration goes back to the text, or stops at the end of the note |
webbook-note-wait-sound |
'true' | 'false' (default false): play quiet ticks during the brief pause at a phrase with notes |
webbook-sound-headings, webbook-sound-notes, webbook-sound-lists-tables |
'true' | 'false' (default false): a tone at headings, a bell at footnotes and endnotes, knocks entering and leaving lists and tables |
webbook-agent-tools |
'true' | 'false' (default true), shared across books |
webbook-keyboard-shortcut-map |
JSON { "version": 1, "bindings": { "<action id>": [keySpec, …] } }; only custom bindings, with [] disabling an action. Missing actions use their defaults. Shared across books; malformed data and unknown actions/fields are ignored. |
webbook-toc-depth |
1 | 2 | 3 | all (default all), shared across books |
webbook-appearance:<book-id> |
'settings' | 'published' (default settings): this book’s Appearance; only for books with publisher styles |
webbook-resume:<book-id> |
JSON { page, anchorId?, audioTime?, ts }; older elementId values remain readable |
webbook-resume-banner-pending |
'true' (one-shot) |
webbook-autoplay, webbook-autoplay-target |
'true', absolute URL without hash (one-shot) |
Each shortcut keySpec stores a physical KeyboardEvent.code and exact boolean modifiers, e.g.
{ "code": "KeyF", "shift": true, "alt": false, "ctrl": false, "meta": false }.
sessionStorage: webbook-resume-checked; webbook-search-highlight is a one-shot search target
used to preserve matched-word highlighting across a full page load when in-place navigation is
unavailable.
#<id> in the page URL names the nearest retained structure at or above the reading position.
In a narrated book, ?t=<seconds>#<id> refines that structure to an exact cue; opening it seeks
and scrolls to that phrase. Without script the hash still reaches the structure. During narration, after paused scrolling, and when focus moves in
the text, the UI updates the URL with history.replaceState, retaining history.state and never
creating a history entry. An explicit hash or t takes precedence over a saved resume position.<main>, <title>, lang, spine links, TOC aria-current and narration,
and sets the page’s URL with history.pushState. It does this only for a page in the same
directory with the same contract, book ID and stylesheets, and loads anything else normally. So
every page must still work as a complete page on its own, and the URL in the address bar is
always a real page.t and other
query parameters; Back and Forward continue to use their saved exact scroll and audio state.The saved-books management page is src/offline-books.html, linked from About. It reads the
same-origin offline database and sends per-book operations to each existing registered worker.
Refresh uses that book’s foreground lease and stages an update; activation remains explicit and
requires other book tabs to close. Removal keeps preferences. A webbook-offline-library- cache
retains the hosting reader’s src/ files so the management page can reopen after all books are
removed; it contains no publication text/audio/images. The root worker serves this shell only
for the management page and its subresources when the hosting book has no active snapshot.
data-webbook-shell="1", <main>, a skip link, real links in
#webbook-basic-nav, previous/next links, native narration in #webbook-toolbar, and permanent
#webbook-escape-status / #webbook-resume-banner live regions. Reader controls are absent.toc.html and about.html are standalone, script-free navigation documents; pages.html
exists only with print-page links. These filenames are reserved; conflicting source chapters
are renamed and mapped like any other output filename. The content page’s Contents fragment
identifies its entry. data-webbook-navigation identifies navigation pages.webbook-page-file, webbook-page-number, webbook-page-count, webbook-page-label metadata
supply current-page identity/progress. webbook-source is JSON with original source filename,
EPUB identifier (independent of a reader-ID override), and converter package version. About
attributes original EPUB claims to their source and retains its complete metadata XML/roles.data-webbook-local-style. Remote styles carry data-webbook-ui-style and
are excluded from content-page stylesheet comparisons. UI resources never resolve against
import.meta.url; content/navigation paths resolve against the book. The bundled
local reader and a release’s main.js both build in the reader shell; only a book given the
unbundled modules carries src/reader-shell.html.webbook-ui-channel metadata contains the HTTPS channel directory (localhost HTTP is
allowed for tests). The default beta channel is the stable URL
https://webbook.daisy.org/ui/releases/v0/, which redirects to where the files are published. Conversions default to the channel with a prominent notice;
--no-remote-ui selects a fixed bundled copy and omits the metadata. Channel-enabled pages set no-referrer and preconnect to the channel origin.src/js/bootstrap.js for
CSPs blocking inline scripts. Both share a startup guard. main.js exports async init();
it must not mutate reader state at import time. Pure policy in bootstrap-policy.js is unit-tested
and compiled with bootstrap-source.js by build-bootstrap.mjs; conversions copy that reviewed
bundle without importing a Node bundler (the browser converter shares this path). webbook-js identifies enhanced mode; the
baseline remains readable without it, including file URLs and clean reloads after failure.current.json: {contract:0,version,minBootstrap:1,script,stylesheet,worker?,inventory,protocol:1}.
Relative resource paths must stay inside that version’s <version>/ directory, directly in the channel directory.
Every remote selection requires script/style hashes from its immutable inventory, or stored
verified inventory for a saved selection. Missing hashes select local UI. Optional manifest
integrity:{script,stylesheet} fields must agree with that inventory. CSS always uses SRI; JS
bytes are always verified before importing a module Blob URL. Restrictive CSPs select local UI.
{contract:0,useLocal:true} is the kill switch. Invalid, timed-out, CORS-blocked or incompatible
releases select both local CSS/JS. CSS remains inactive until the matching module downloads.saved-ui returns {ui,recovering} without
scanning content caches; older workers are queried for status. Unknown saved state selects
local fallback. Default channel state cannot replace a saved release; testing overrides can
select an uncached release online without rewriting the snapshot.?webbook-ui=local|remote|release:<version>|auto persists valid choices then removes the
parameter. Local override is in localStorage, testing overrides in sessionStorage. Keys use
webbook-ui:<book-root>:override; manifests, bad-version flags and reload guards use the same
book-root prefix. Auto clears overrides and baseline/retry guards. Source documents never
contain a reader’s override. window.webbookUI exposes the selected validated descriptor to
the current reader’s offline controller. About shows any stored override and offers Return to
automatic updates, preserving reading position; this also clears internal URL crash guards.localOnly:true even with a remote page UI), because classic
importScripts cannot verify integrity before execution. The remote worker bundle is retained
and checked as an asset but not executed by this reader. The optional old bridge is compatibility
tooling only. No forced skipWaiting or schema-clearing occurs. Root sw.js is byte-for-byte unchanged.See REMOTE_UI.md for release tooling, retained artifacts, verification receipts, rollback, the selected repository, publication and outstanding device checks.