Eval iteration 1: the callout 'edge' variant picked up the diagram connector styles, and all three skill runs hand-wrote a template filler. fill_template.py takes values.json with @fragment files, escapes </ in the quiz; suite 21 checks.
550 lines
15 KiB
HTML
550 lines
15 KiB
HTML
<!doctype html>
|
|
<html lang="{{LANG}}">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<meta name="color-scheme" content="light dark">
|
|
<title>{{TITLE}}</title>
|
|
<style>
|
|
:root {
|
|
--bg: #faf9f6;
|
|
--surface: #f1eee7;
|
|
--ink: #1f1d1a;
|
|
--muted: #5a554c;
|
|
--line: #d8d3c8;
|
|
--accent: #245a8f;
|
|
--accent-wash: #e4ecf4;
|
|
--add-bg: #e3f0e1;
|
|
--add-ink: #1f5427;
|
|
--del-bg: #f6e2de;
|
|
--del-ink: #8a2a1f;
|
|
--edge-ink: #7a5408;
|
|
--select: #cddff0;
|
|
--serif: Charter, "Bitstream Charter", "Iowan Old Style", "Sitka Text",
|
|
Cambria, "Noto Serif", Georgia, serif;
|
|
--sans: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans",
|
|
sans-serif;
|
|
--mono: ui-monospace, "SF Mono", "Cascadia Mono", "DejaVu Sans Mono",
|
|
Menlo, Consolas, monospace;
|
|
--measure: 68ch;
|
|
}
|
|
@media (prefers-color-scheme: dark) {
|
|
:root {
|
|
--bg: #171614;
|
|
--surface: #22201c;
|
|
--ink: #ebe7df;
|
|
--muted: #aaa498;
|
|
--line: #3b3832;
|
|
--accent: #8fb8e2;
|
|
--accent-wash: #1d2935;
|
|
--add-bg: #1c2e1e;
|
|
--add-ink: #a3d6a6;
|
|
--del-bg: #361f1b;
|
|
--del-ink: #f2a89d;
|
|
--edge-ink: #e3b65f;
|
|
--select: #2d4560;
|
|
}
|
|
}
|
|
*, *::before, *::after { box-sizing: border-box; }
|
|
[hidden] { display: none !important; }
|
|
html {
|
|
-webkit-text-size-adjust: 100%;
|
|
scroll-behavior: smooth;
|
|
scrollbar-color: var(--line) var(--bg);
|
|
}
|
|
@media (prefers-reduced-motion: reduce) {
|
|
html { scroll-behavior: auto; }
|
|
}
|
|
body {
|
|
margin: 0;
|
|
background: var(--bg);
|
|
color: var(--ink);
|
|
font: 1.0625rem/1.65 var(--serif);
|
|
caret-color: var(--accent);
|
|
}
|
|
::selection { background: var(--select); color: var(--ink); }
|
|
a {
|
|
color: var(--accent);
|
|
text-decoration-thickness: 1px;
|
|
text-underline-offset: 0.18em;
|
|
}
|
|
a:hover { text-decoration-thickness: 2px; }
|
|
:focus-visible {
|
|
outline: 2px solid var(--accent);
|
|
outline-offset: 2px;
|
|
border-radius: 3px;
|
|
}
|
|
.page { max-width: 62rem; margin: 0 auto; padding: 3rem 1rem 6rem; }
|
|
.masthead, .toc, .q, .colophon,
|
|
main > section > :is(p, ul, ol, h2, h3, h4, blockquote, details, .callout) {
|
|
max-width: var(--measure);
|
|
}
|
|
h1, h2, h3, h4 {
|
|
font-family: var(--sans);
|
|
line-height: 1.2;
|
|
letter-spacing: -0.01em;
|
|
text-wrap: balance;
|
|
}
|
|
h1 {
|
|
margin: 0 0 0.75rem;
|
|
font-size: clamp(1.9rem, 1.4rem + 2.2vw, 2.7rem);
|
|
font-weight: 700;
|
|
letter-spacing: -0.02em;
|
|
}
|
|
h2 {
|
|
margin: 4.5rem 0 1rem;
|
|
padding-top: 1.5rem;
|
|
border-top: 1px solid var(--line);
|
|
font-size: 1.6rem;
|
|
font-weight: 650;
|
|
}
|
|
h3 { margin: 2.5rem 0 0.6rem; font-size: 1.15rem; font-weight: 650; }
|
|
h4 { margin: 1.75rem 0 0.4rem; font-size: 1rem; font-weight: 650; }
|
|
p, ul, ol { margin: 0 0 1.1rem; }
|
|
li + li { margin-top: 0.3rem; }
|
|
.meta {
|
|
margin: 0 0 1.5rem;
|
|
font: 0.9rem/1.5 var(--sans);
|
|
color: var(--muted);
|
|
font-variant-numeric: tabular-nums;
|
|
}
|
|
.lead { font-size: 1.2rem; line-height: 1.55; }
|
|
|
|
/* Table of contents */
|
|
.toc {
|
|
margin: 2.5rem 0 1rem;
|
|
padding: 1rem 1.25rem;
|
|
border: 1px solid var(--line);
|
|
border-radius: 8px;
|
|
background: var(--surface);
|
|
font-family: var(--sans);
|
|
}
|
|
.toc-title { margin: 0 0 0.4rem; font-size: 0.95rem; font-weight: 650; }
|
|
.toc ol { margin: 0; padding-left: 1.25rem; }
|
|
.toc a { text-decoration: none; }
|
|
.toc a:hover { text-decoration: underline; }
|
|
|
|
/* Code */
|
|
code {
|
|
padding: 0.05em 0.3em;
|
|
border: 1px solid var(--line);
|
|
border-radius: 4px;
|
|
background: var(--surface);
|
|
font-family: var(--mono);
|
|
font-size: 0.88em;
|
|
}
|
|
pre {
|
|
margin: 0 0 1.5rem;
|
|
padding: 0.9rem 1rem;
|
|
overflow-x: auto;
|
|
border: 1px solid var(--line);
|
|
border-radius: 8px;
|
|
background: var(--surface);
|
|
font: 0.85rem/1.6 var(--mono);
|
|
white-space: pre;
|
|
tab-size: 2;
|
|
}
|
|
pre code { padding: 0; border: 0; background: none; font-size: inherit; }
|
|
pre.diff { padding: 0.9rem 0; }
|
|
pre.diff .lines { display: inline-block; min-width: 100%; }
|
|
pre.diff .ln { display: block; padding: 0 1rem; }
|
|
pre.diff .add { background: var(--add-bg); color: var(--add-ink); }
|
|
pre.diff .del { background: var(--del-bg); color: var(--del-ink); }
|
|
pre.diff .hunk { color: var(--muted); }
|
|
figure { margin: 2rem 0; }
|
|
figure pre { margin: 0; }
|
|
figcaption {
|
|
max-width: var(--measure);
|
|
margin-top: 0.6rem;
|
|
font: 0.85rem/1.5 var(--sans);
|
|
color: var(--muted);
|
|
}
|
|
.path {
|
|
display: block;
|
|
margin: 0 0 0.35rem;
|
|
font: 0.8rem/1.4 var(--mono);
|
|
color: var(--muted);
|
|
}
|
|
|
|
/* Callouts and the skippable deep background */
|
|
.callout {
|
|
margin: 1.75rem 0;
|
|
padding: 0.9rem 1.1rem;
|
|
border: 1px solid var(--line);
|
|
border-radius: 8px;
|
|
background: var(--surface);
|
|
}
|
|
.callout.concept { border-color: var(--accent-wash); background: var(--accent-wash); }
|
|
.callout > :last-child { margin-bottom: 0; }
|
|
.callout-title {
|
|
margin: 0 0 0.35rem;
|
|
font: 650 0.95rem/1.35 var(--sans);
|
|
color: var(--accent);
|
|
}
|
|
.callout.edge .callout-title { color: var(--edge-ink); }
|
|
.callout.risk .callout-title { color: var(--del-ink); }
|
|
details.deep {
|
|
margin: 1.5rem 0 2rem;
|
|
padding: 0 1.1rem;
|
|
border: 1px solid var(--line);
|
|
border-radius: 8px;
|
|
}
|
|
details.deep > summary {
|
|
padding: 0.8rem 0;
|
|
cursor: pointer;
|
|
font: 600 0.95rem/1.4 var(--sans);
|
|
}
|
|
details.deep > summary .hint { font-weight: 400; color: var(--muted); }
|
|
details.deep[open] > summary {
|
|
margin-bottom: 1rem;
|
|
border-bottom: 1px solid var(--line);
|
|
}
|
|
|
|
/* Diagrams: flow and states (.arrow links two nodes) */
|
|
.flow { display: flex; align-items: stretch; }
|
|
.node {
|
|
flex: 1 1 0;
|
|
min-width: 0;
|
|
padding: 0.7rem 0.8rem;
|
|
border: 1px solid var(--line);
|
|
border-radius: 8px;
|
|
background: var(--surface);
|
|
font: 0.9rem/1.4 var(--sans);
|
|
}
|
|
.node.hl { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
|
|
.node.state { border-radius: 999px; text-align: center; }
|
|
.node-title { display: block; font-weight: 650; }
|
|
.node-sub { display: block; font-size: 0.82rem; color: var(--muted); }
|
|
.arrow {
|
|
position: relative;
|
|
flex: 0 0 9rem;
|
|
align-self: center;
|
|
padding: 0 0.6rem 0.7rem;
|
|
font: 0.75rem/1.3 var(--mono);
|
|
color: var(--muted);
|
|
text-align: center;
|
|
overflow-wrap: break-word;
|
|
}
|
|
.arrow::before {
|
|
content: "";
|
|
position: absolute;
|
|
left: 0.3rem;
|
|
right: 0.5rem;
|
|
bottom: 0.3rem;
|
|
border-top: 1.5px solid var(--muted);
|
|
}
|
|
.arrow::after {
|
|
content: "";
|
|
position: absolute;
|
|
right: 0.3rem;
|
|
bottom: calc(0.3rem - 4.25px);
|
|
border: 5px solid transparent;
|
|
border-right: 0;
|
|
border-left: 7px solid var(--muted);
|
|
}
|
|
|
|
/* Diagrams: before and after, UI mock */
|
|
.compare {
|
|
display: grid;
|
|
grid-template-columns: 1fr 1fr;
|
|
gap: 1rem;
|
|
margin: 1.75rem 0;
|
|
}
|
|
.pane {
|
|
padding: 0.9rem 1rem;
|
|
border: 1px solid var(--line);
|
|
border-radius: 8px;
|
|
}
|
|
.pane > :last-child { margin-bottom: 0; }
|
|
.pane-label { margin: 0 0 0.5rem; font: 650 0.9rem/1.3 var(--sans); }
|
|
.pane.before .pane-label { color: var(--del-ink); }
|
|
.pane.after .pane-label { color: var(--add-ink); }
|
|
.mock {
|
|
max-width: 26rem;
|
|
overflow: hidden;
|
|
border: 1px solid var(--line);
|
|
border-radius: 10px;
|
|
background: var(--bg);
|
|
font: 0.9rem/1.4 var(--sans);
|
|
}
|
|
.mock-bar {
|
|
padding: 0.45rem 0.75rem;
|
|
border-bottom: 1px solid var(--line);
|
|
background: var(--surface);
|
|
font-size: 0.78rem;
|
|
color: var(--muted);
|
|
}
|
|
.mock-body { display: grid; gap: 0.6rem; padding: 0.9rem; }
|
|
.mock-body > * { margin: 0; }
|
|
.mock-button {
|
|
justify-self: start;
|
|
padding: 0.3rem 0.75rem;
|
|
border: 1px solid var(--accent);
|
|
border-radius: 6px;
|
|
color: var(--accent);
|
|
font-weight: 600;
|
|
}
|
|
.mock-field {
|
|
padding: 0.35rem 0.6rem;
|
|
border: 1px solid var(--line);
|
|
border-radius: 6px;
|
|
color: var(--muted);
|
|
}
|
|
.mock-alert {
|
|
padding: 0.45rem 0.7rem;
|
|
border-radius: 6px;
|
|
background: var(--del-bg);
|
|
color: var(--del-ink);
|
|
}
|
|
.mock-alert.ok { background: var(--add-bg); color: var(--add-ink); }
|
|
.mark { outline: 2px dashed var(--edge-ink); outline-offset: 3px; }
|
|
|
|
/* Toy data */
|
|
.table-wrap { margin: 1.5rem 0; overflow-x: auto; }
|
|
table.data {
|
|
width: 100%;
|
|
border-collapse: collapse;
|
|
font: 0.9rem/1.45 var(--sans);
|
|
font-variant-numeric: tabular-nums;
|
|
}
|
|
table.data th, table.data td {
|
|
padding: 0.45rem 0.65rem;
|
|
border-bottom: 1px solid var(--line);
|
|
text-align: left;
|
|
vertical-align: top;
|
|
}
|
|
table.data th { font-weight: 650; color: var(--muted); }
|
|
|
|
/* Quiz */
|
|
.q {
|
|
margin: 1.5rem 0;
|
|
padding: 1.1rem 1.2rem 1rem;
|
|
border: 1px solid var(--line);
|
|
border-radius: 10px;
|
|
}
|
|
.q-text { margin: 0 0 0.8rem; font-weight: 600; }
|
|
.opt {
|
|
display: block;
|
|
width: 100%;
|
|
margin: 0.45rem 0;
|
|
padding: 0.65rem 0.85rem;
|
|
border: 1px solid var(--line);
|
|
border-radius: 8px;
|
|
background: var(--bg);
|
|
color: var(--ink);
|
|
font: 0.95rem/1.45 var(--sans);
|
|
text-align: left;
|
|
cursor: pointer;
|
|
transition: border-color 0.15s ease-out, background-color 0.15s ease-out;
|
|
}
|
|
.opt:hover:not(:disabled) { border-color: var(--accent); }
|
|
.opt:disabled { cursor: default; }
|
|
.opt.right { border-color: var(--add-ink); background: var(--add-bg); }
|
|
.opt.wrong { border-color: var(--del-ink); background: var(--del-bg); }
|
|
.opt .why { display: block; margin-top: 0.35rem; font-size: 0.88rem; color: var(--muted); }
|
|
.opt.right .why { color: var(--add-ink); }
|
|
.opt.wrong .why { color: var(--del-ink); }
|
|
.verdict { min-height: 1.4em; margin: 0.6rem 0 0; font: 600 0.95rem/1.4 var(--sans); }
|
|
.score { font: 650 1rem/1.4 var(--sans); }
|
|
.colophon {
|
|
margin-top: 5rem;
|
|
padding-top: 1rem;
|
|
border-top: 1px solid var(--line);
|
|
font: 0.8rem/1.5 var(--sans);
|
|
color: var(--muted);
|
|
}
|
|
|
|
@media (max-width: 40rem) {
|
|
body { font-size: 1rem; }
|
|
.page { padding-top: 2rem; }
|
|
h2 { margin-top: 3.5rem; }
|
|
.compare { grid-template-columns: 1fr; }
|
|
.flow { flex-direction: column; }
|
|
.arrow {
|
|
flex-basis: auto;
|
|
align-self: flex-start;
|
|
padding: 0.55rem 0 0.75rem 1.5rem;
|
|
text-align: left;
|
|
}
|
|
.arrow::before {
|
|
top: 0;
|
|
bottom: 0.2rem;
|
|
left: 0.65rem;
|
|
right: auto;
|
|
border-top: 0;
|
|
border-left: 1.5px solid var(--muted);
|
|
}
|
|
.arrow::after {
|
|
right: auto;
|
|
bottom: 0;
|
|
left: calc(0.65rem - 4.25px);
|
|
border: 5px solid transparent;
|
|
border-bottom: 0;
|
|
border-top: 7px solid var(--muted);
|
|
}
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="page">
|
|
|
|
<header class="masthead">
|
|
<h1>{{TITLE}}</h1>
|
|
<p class="meta">{{PROJECT}} · {{RANGE}} · {{DATE}} · {{STATS}}</p>
|
|
<p class="lead">{{LEAD}}</p>
|
|
</header>
|
|
|
|
<nav class="toc" aria-labelledby="toc-title">
|
|
<p class="toc-title" id="toc-title">{{TOC_TITLE}}</p>
|
|
<ol>
|
|
<li><a href="#background">{{BACKGROUND_TITLE}}</a></li>
|
|
<li><a href="#intuition">{{INTUITION_TITLE}}</a></li>
|
|
<li><a href="#code">{{CODE_TITLE}}</a></li>
|
|
<li><a href="#quiz">{{QUIZ_TITLE}}</a></li>
|
|
</ol>
|
|
</nav>
|
|
|
|
<main>
|
|
<section id="background" aria-labelledby="h-background">
|
|
<h2 id="h-background">{{BACKGROUND_TITLE}}</h2>
|
|
{{BACKGROUND_BODY}}
|
|
</section>
|
|
|
|
<section id="intuition" aria-labelledby="h-intuition">
|
|
<h2 id="h-intuition">{{INTUITION_TITLE}}</h2>
|
|
{{INTUITION_BODY}}
|
|
</section>
|
|
|
|
<section id="code" aria-labelledby="h-code">
|
|
<h2 id="h-code">{{CODE_TITLE}}</h2>
|
|
{{CODE_BODY}}
|
|
</section>
|
|
|
|
<section id="quiz" aria-labelledby="h-quiz">
|
|
<h2 id="h-quiz">{{QUIZ_TITLE}}</h2>
|
|
{{QUIZ_INTRO}}
|
|
<div id="quiz-root" data-right="{{QUIZ_RIGHT}}"
|
|
data-wrong="{{QUIZ_WRONG}}" data-score="{{QUIZ_SCORE}}"></div>
|
|
<p class="score" id="quiz-score" aria-live="polite"></p>
|
|
</section>
|
|
</main>
|
|
|
|
<footer class="colophon">{{COLOPHON}}</footer>
|
|
</div>
|
|
|
|
<script type="application/json" id="quiz-data">
|
|
{{QUIZ_JSON}}
|
|
</script>
|
|
<script>
|
|
(function () {
|
|
"use strict";
|
|
|
|
// Backtick spans become <code>; all text goes through textContent.
|
|
function withInlineCode(text, el) {
|
|
String(text).split("`").forEach(function (part, i) {
|
|
if (i % 2 === 1) {
|
|
var code = document.createElement("code");
|
|
code.textContent = part;
|
|
el.appendChild(code);
|
|
} else if (part) {
|
|
el.appendChild(document.createTextNode(part));
|
|
}
|
|
});
|
|
return el;
|
|
}
|
|
|
|
function lineKind(line) {
|
|
if (line.indexOf("@@") === 0) return " hunk";
|
|
if (line.charAt(0) === "+") return " add";
|
|
if (line.charAt(0) === "-") return " del";
|
|
return "";
|
|
}
|
|
|
|
function renderDiff(pre) {
|
|
var lines = pre.textContent.replace(/^\n+|\s+$/g, "").split("\n");
|
|
var wrap = document.createElement("span");
|
|
wrap.className = "lines";
|
|
lines.forEach(function (line) {
|
|
var span = document.createElement("span");
|
|
span.className = "ln" + lineKind(line);
|
|
span.textContent = line || " ";
|
|
wrap.appendChild(span);
|
|
});
|
|
pre.textContent = "";
|
|
pre.appendChild(wrap);
|
|
}
|
|
|
|
function reveal(chosen, options, verdict, ctx) {
|
|
options.forEach(function (o) {
|
|
o.button.disabled = true;
|
|
o.why.hidden = false;
|
|
if (o.data.correct) o.button.classList.add("right");
|
|
});
|
|
if (!chosen.data.correct) chosen.button.classList.add("wrong");
|
|
chosen.button.setAttribute("aria-pressed", "true");
|
|
verdict.textContent =
|
|
chosen.data.correct ? ctx.labels.right : ctx.labels.wrong;
|
|
ctx.answered += 1;
|
|
if (chosen.data.correct) ctx.right += 1;
|
|
if (ctx.answered === ctx.total) {
|
|
ctx.score.textContent = ctx.labels.score
|
|
.replace("{n}", ctx.right).replace("{total}", ctx.total);
|
|
}
|
|
}
|
|
|
|
function renderOption(data, box) {
|
|
var button = document.createElement("button");
|
|
button.type = "button";
|
|
button.className = "opt";
|
|
withInlineCode(data.text, button);
|
|
var why = withInlineCode(data.why, document.createElement("span"));
|
|
why.className = "why";
|
|
why.hidden = true;
|
|
button.appendChild(why);
|
|
box.appendChild(button);
|
|
return { data: data, button: button, why: why };
|
|
}
|
|
|
|
function renderQuestion(item, index, ctx) {
|
|
var box = document.createElement("div");
|
|
box.className = "q";
|
|
var text = document.createElement("p");
|
|
text.className = "q-text";
|
|
text.appendChild(document.createTextNode(index + 1 + ". "));
|
|
box.appendChild(withInlineCode(item.q, text));
|
|
var options = item.options.map(function (d) {
|
|
return renderOption(d, box);
|
|
});
|
|
var verdict = document.createElement("p");
|
|
verdict.className = "verdict";
|
|
verdict.setAttribute("aria-live", "polite");
|
|
box.appendChild(verdict);
|
|
options.forEach(function (o) {
|
|
o.button.addEventListener("click", function () {
|
|
reveal(o, options, verdict, ctx);
|
|
});
|
|
});
|
|
return box;
|
|
}
|
|
|
|
function renderQuiz() {
|
|
var root = document.getElementById("quiz-root");
|
|
var data = document.getElementById("quiz-data");
|
|
if (!root || !data) return;
|
|
var quiz = JSON.parse(data.textContent);
|
|
var ctx = {
|
|
labels: root.dataset, answered: 0, right: 0, total: quiz.length,
|
|
score: document.getElementById("quiz-score")
|
|
};
|
|
quiz.forEach(function (item, i) {
|
|
root.appendChild(renderQuestion(item, i, ctx));
|
|
});
|
|
}
|
|
|
|
document.querySelectorAll("pre.diff").forEach(renderDiff);
|
|
renderQuiz();
|
|
})();
|
|
</script>
|
|
</body>
|
|
</html>
|