#!/usr/bin/env quilt
This line will be rewritten by a cell further down the page.
HTML is the ground language here, so the page is the program and the cells are its quotes.
Each language's cells share one machine that persists for the whole run — a
Python kernel, a live sqlite3, a long-lived shell, a Node context — and the
page itself is the HTML machine: what a cell prints goes back into it.
A definition in one cell is there for the next. Left, Python; right, SQL; the arrangement is just a CSS grid.
Output that carries an id the page already has redefines that element
wherever it stands. The chart below is drawn by the cell after it — the page held an empty
figure with that id, and the cell's output replaced it. The headline at the top of the page is
rewritten the same way.
Rewritten by a cell: the dearest drink is ↙↑(max(menu, key=menu.get))↘.
↗.coparse()) ↗Machines share nothing with each other; what they share is the page. An unquote that reaches
the page reads it: \↙#total\↘ is the text of the element with that id, spliced into
the cell as a string literal of the cell's language. SQL answers into #total, and
one row of four languages reads it back.
| py↖round(float(↙#total↘) / len(menu), 3)↗ | ts↖const total: number = Number(↙#total↘); total * 100↗ | bash↖total=↙#total↘; echo "cents: ${total/./}"↗ | sql↖SELECT ↙#total↘ - (SELECT MIN(price) FROM menu);↗ |
Output is read as Quilt-in-HTML, so a quote in it is a new cell, run right away and rendered
in place (dashed edge). Python builds each new cell as a Python term — \↑
lifts the name into it as a Python literal — and splices the term into the page markup two
quote levels up, \↙\↙cell\↘\↘. A shell loop writes cells too (${i}
braced, because bash reads the byte after $i as part of the name).
Cells are elements, so anything HTML can do with an element it can do with a cell. A cell in a collapsible section:
And a cell whose language has no machine fails on its own, with the notebook going on:
wgsl↖fn f() -> f32 { return 1.0; }↗The same session, a line at a time: quilt repl html.