Classbook — notes in, interactive classbook out
A classbook is a static website (plain HTML/CSS/JS, no server, no build tools beyond Python's
standard library). Each unit is a folder; each lesson in it is a <section> the reader steps
through with a stepper, a story panel on the right, and — only where the topic needs them — widgets,
animations, formulas with hoverable symbols, code in any language, exercises and quick checks.
Practice, Code Lab and Cheatsheet views are assembled automatically, and their tabs disappear when a
unit has nothing for them.
Everything is in this skill folder:
| path | what it is |
|---|---|
engine/ | the site engine copied into every classbook: assets/ (style, app, plotting/animation helpers, KaTeX, font) and build.py |
templates/ | classbook.json, home.html, and a unit template (unit/content.html, unit/widgets.js) showing every block |
scripts/new_classbook.py | create a classbook folder (engine + config + home + first unit) and build it |
scripts/add_unit.py | add a lesson unit, lab or project; registers it in classbook.json |
scripts/check.py | build + catch broken symbols, widgets, exercises, links, JS errors before publishing |
references/authoring.md | every content macro, with examples — read before writing content |
references/widgets.md | the Plot / UI / M API, UI.player animations, widget recipes — read before writing widgets |
references/pedagogy.md | how to turn notes into a learning journey — read when planning units |
references/publishing.md | GitHub Pages, custom colours, updating the engine |
Workflow
- Read the notes fully (PDF → text, slides, markdown, photos of handwriting). List the topics, the formulas, the worked examples, the code and the exercises they contain. Note the audience level.
- Plan (see
references/pedagogy.md): units → lessons (4–10 per unit, 15–35 min each). For each lesson decide its one key idea and which blocks it actually needs (table below). Show the plan to the person if they are present and the course is large; otherwise state your plan and proceed. - Create the classbook:
Usepython scripts/new_classbook.py <target> --title "…" --subject "…" --languages py:Python[,f90:Fortran|m:MATLAB|r:R|cpp:C++|js:JavaScript|jl:Julia] --no-unit python scripts/add_unit.py <target> --id 01 --name "…" --lessons "Title 1|Title 2|…" [--kind lab|project --label "Lab 1 ·"]--languages ""for a course with no code (history, languages, biology…). - Write each unit's
content.htmlwith the macros inreferences/authoring.md, faithful to the notes (same notation, same examples, same order unless pedagogy demands otherwise). Fill the right-panel story, key idea and "you'll learn" list of every lesson. Remove every TODO. - Write
widgets.jsonly for lessons where something can be explored (slider → plot) or watched (an animation of a process). Define theSYMBOLSused by\h{key}{…}. Test numbers you quote: run any code you include (it must print what the text says). - Edit
home.html(description, suggested order table, credits to the notes' authors). - Check:
python scripts/check.py <target>until 0 errors; then open the pages in a browser (Playwright screenshots if available) — look at every widget once, on desktop and at phone width. - Deliver: the folder is the website. For GitHub, follow
references/publishing.md.
Use only what the topic needs
Nothing is mandatory except a section's title, its prose and its right-panel story. Choose per lesson:
| the notes contain… | use |
|---|---|
| a definition, law or equation | <x-f> formula with \h{key}{…} hover symbols (+ code if the course has code) |
| a parameter whose effect matters ("what if σ doubles?") | a slider widget (recipe 1) |
| a process in time: motion, growth, a wave, a cycle, a historical sequence | an animation with UI.player (recipe 2) |
| an algorithm or a procedure | a stepped animation (UI.player({steps}), recipe 3) or <x-steps> |
| a derivation or a proof | <x-steps> (each line revealed with its justification) |
| numeric worked examples | <x-ex> checked exercises with hint and full solution |
| concepts, vocabulary, cause–effect (non-numeric subjects) | <x-mcq> quick checks with a "why" |
| open-ended understanding | <x-think> reflection prompts |
| program code / lab scripts | <x-code> (inline or from code/ files), a lab unit (--kind lab) |
| a long running example across the course | a project unit + <x-link kind="project"> from each lesson |
| figures, photos, diagrams from the notes | <figure class="fig"><img src="figures/…"><figcaption>… |
Do not add a widget, an animation, an exercise or a code block just to fill a section. One strong widget beats three decorative ones. A pure-concept course can have no code and no formulas at all — the Code Lab and Cheatsheet tabs then vanish by themselves.
Quality bar
- Start every lesson from intuition and a concrete case; then the precise statement; then limits
and common mistakes (BASIC → CORE → ADVANCED labels,
references/pedagogy.md). - Every number in the text is computed or quoted from the notes, never invented. Exercise answers are verified (compute them). Code blocks run.
- Credit the original authors of the notes on the home page; do not copy copyrighted textbook text verbatim beyond short quotes — rewrite in your own words.
- Keep the visual language: warm paper, ink borders, monospace, one accent colour per unit.
- Widgets must redraw on resize/theme (
root._redraw = draw) and work at phone width. - Animations start paused for readers who prefer reduced motion (
UI.playerdoes this) and pause themselves when hidden.