Night-mode styling, French cross-references, and the log through Part VI

- theme.scss and figures draw with the extension's --calc-… tokens; light/dark
  pair plus the high-contrast button; a11y highlight style for html
- figure labels split so none leaves its viewBox in any language
- _quarto-fr.yml: French cross-reference prefixes
- notes extension synced to 2.8.18
- conv/: Parts IV, V and VI logged, pasted terminal output redacted

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
MatsuneMikuroiandClaude Opus 5 committed 2026-10-06 03:36:51 +02:00
1 parent afb816f459
commit f7fa60ba81
62 files changed
+3552 -852

No files matched your search

+16 -9
View File
@@ -1,21 +1,28 @@
5450bea48cd978a098105317ad733839 README.md
c7a6d67f7241268c6ba80e59824b7720 _extension.yml
40495613a91f62b4caa736a8bebeafe0 calc-notes.css
3754c29ead80b6c334397953e0636be4 calc-notes.js
4488fd02675637ec10179a4e96aaa558 calc-notes.lua
9460f3985b27b3107182599992985adf exo.css
e1b695980dee84de5bfa19ff7bfab6c2 README.md
a86fced789dc540cf13974d26391c92d _extension.yml
9037e06faf2c5fde7b3d614039652eed audit-page.js
f9f1c739b8a198b3e9c2c087a5904f85 audit.py
a2f486f6e2dc382624f99801db209b75 calc-notes.css
e9500e2554429fc8da7e9b2a6b51c8f1 calc-notes.js
c06ae335d8506b347298d2a8f0e04ef2 calc-notes.lua
e380e93d24a5968cc483dcbe48d99613 exo.css
1b1c35a5488c4e695a34b1f9efaeab4f exo.js
0bb15846fbb2bc9be2bde88d77698de8 exo.lua
62e03d6d5bd4f62830d71eadb66aa5ed fenced-divs.lua
8f938997710ad5d77e5d378735db451d glossary.css
8bd78a96d4553b922718a381d14a44a3 further.css
1b1237dd91ec14b2c8a9ad20c8ee844f further.lua
2a324dc0362a2a569ac4053b923c17f4 glossary.css
6144abf4ad62088ab51409542e5f28e1 glossary.js
3dd15747646f60632313c8a1cacf7fe9 glossary.lua
3766b7d739c8aebb790b7092af31a57a glossary.lua
2aa159cbe6bfe1ee35e18d4290d67425 handin.sh
93c5c7dddcc07fd7dcedcf06ff32c0d3 high-contrast.css
691f5e66397d855e951c37a953701913 i18n.lua
061f762946d63ea672d4f989f762baf7 latex-tables.css
bab632a49553476bc5275b9c583f457e latex-tables.lua
6242f20acbe379c1da37d4b698de317e quiz.css
b846f2c4afd59aa0c9a328c71633425f narrow.css
f5b63a6c6c5d3f9df63766ade2719ff2 quiz.css
79e94885bf370abe27eeb6df81666946 quiz.js
1695d57dcb6deb45f4fb2303dee6aa09 quiz.lua
2b8ca7ff531d30903bc41240e8b77691 si-mathjax.lua
d32141259df2ce229400779c2ed284d9 sync.sh
838bac386bf1e2b1e0323d91119c3632 theme.css
+147 -1
View File
@@ -8,16 +8,21 @@ documents its syntax in the comment at its top; this page is the overview.
| `calc-notes.lua` | `\begin{calc}` / `calc*` derivations with `\note{}` / `\mnote{}`; label with `$$ … $$ {#eq-x}` |
| `exo.lua` | `::::{.exo}` exercises with `.hint` and `.solution` placed where written; hand-in mode |
| `quiz.lua` | `::::{.quiz}` tick-box self-checks with a **Check** button and per-option `.why` |
| `glossary.lua` | `.gls-def`, `\gls{key}`, `[term]{.gls}`, `::: {.glossary}`; resolves across chapters |
| `glossary.lua` | `.gls-def`, `\gls{key}`, `\gls[variant]{key}` in maths (shows the variant, links to the entry), `[term]{.gls}`, `::: {.glossary}`; resolves across chapters, and links also work inside a definition and in a figure caption (pdf too) |
| `latex-tables.lua` | `tabular` environments rendered as HTML tables |
| `i18n.lua` | one source, several languages: `::: {.de}`, `[…]{.fr}`, `@tr{key}` |
| `si-mathjax.lua` | `\SI`, `\si`, `\num`, `\ang` in HTML (PDF uses siunitx) |
| `further.lua` | `::: {.further}` purple "to go further" notes, for material beside the lecture |
| `fenced-divs.lua` | repairs `:::` divs indented deeper than pandoc accepts (in numbered parts) |
| `theme.css` | the palette every part shares, in light and in night mode |
| `high-contrast.css` | the high-contrast pair, after GitHub's two high-contrast VS Code themes |
| `narrow.css` | keeps the page inside a phone screen: formulas, code and tables scroll in place |
## Options (in `_quarto.yml`)
```yaml
notecolor: "#B45309" # accent colour of notes, exercises, hints
notecolor-dark: "#e0a361" # its night value; by default the same hue, lifted
exo:
pdf-solutions: inline # PDF: solutions in place (default: end of chapter)
@@ -31,11 +36,111 @@ quiz:
check: "Vérifier" # right, wrong, score, true, false, hint, page
siunitx-html: mathjax # leave \SI & co. to a MathJax siunitx extension
furthercolor: "#6B3FA0" # the accent of the "to go further" notes
furthercolor-dark: "#c09ae8"
glossary-page: glossary.html
glossary-back: "→ definition in context" # follows `lang` (en/fr/de) by default
high-contrast: true # stronger palette, both modes (default: off)
```
## Night mode
The extension carries one palette, in `theme.css`, and every colour it draws
with is a token on it. A book gets night mode by offering the two themes:
```yaml
format:
html:
theme:
light: [cosmo]
dark: [darkly]
```
Quarto then shows its light/dark toggle and sets `body.quarto-dark`, which is
what the dark values key off — never `prefers-color-scheme`, so a book
configured light-only stays light for a reader whose system is dark.
A book's own `notecolor` and `furthercolor` are kept in night mode, not
replaced: the print value is too dim on a dark ground, so it is lifted to a
light tone **at the same hue** (`oklch(from … 0.78 c h)`). A book that wants a
particular night colour sets `notecolor-dark:` / `furthercolor-dark:`. The
book's colour itself stays available as `--calc-notecolor-src`.
The tokens, should a book's own css want them: `--calc-ink`, `--calc-muted`,
`--calc-line`, `--calc-grid`, `--calc-accent-a/-b/-c`, `--calc-danger`,
`--calc-surface`, `--calc-faint`, `--calc-shadow`, `--calc-domface`,
`--calc-domtop`, and the two from the metadata, `--calc-notecolor` and
`--calc-furthercolor`.
A pinned `highlight-style` needs no pair: Quarto ships the light and the dark
variant of its bundled themes (`github`, `github-dark`, …) and swaps them with
the toggle as soon as a book offers two themes. theme.css deliberately leaves
code colours alone.
Generated line art (`main img[src$=".svg"]`) is inverted in night mode, hue
rotated so blue stays blue. An svg that is a photograph, or that brings its
own dark palette, opts out with `class="no-invert"`.
A built svg figure writes each colour as a token with its light value as the
fallback, `var(--calc-ink, #1a1a1a)`: inlined in the page it follows the
three modes, while an `<img>` and rsvg-convert (the PDF) draw the fallback.
No `prefers-color-scheme` block in figure CSS: it follows the system, not the
page's toggle.
**Plots from code (matplotlib).** A line plot (curves, points, bars, a few
colours) is an svg: `fig-format: svg` under `format: html` only, a
transparent figure and axes background, black ink and accents that survive
invert + hue-rotate(180°); it then turns with the page like other line art. A
plot whose colours carry data (a colour map, a surface, an image) is a png on
an opaque white ground and is never inverted — inverting would reverse the
scale; in night mode it shows as a white card, like a photograph. A png is
never inverted, so it needs no `no-invert`.
Text drawn in an accent colour needs 4.5:1, a stroke only 3:1: for text, mix
in a fifth of ink, `color-mix(in srgb, var(--calc-accent-a) 80%,
var(--calc-ink))` — same hue, and it passes in all four modes.
## High contrast
`high-contrast.css` is a second pair of themes, taken from GitHub's
**GitHub Light High Contrast** and **GitHub Dark High Contrast** VS Code
themes (the Primer `light_high_contrast` / `dark_high_contrast` scales). It
rides on top of the ordinary pair — the light/dark toggle keeps working — and
restyles the page, not only the extension: canvas, headings, links, the
sidebar and the table of contents, code blocks and their syntax colours,
tables, block quotes and the notes environments.
Following the two themes, it separates by outline rather than by fill: muted
ink goes to full strength, borders take `border.default`, and the tinted
panels of `.exo`, `.further`, `.quiz` and the glossary lose their tint for a
full-strength accent edge.
**The reader switches it** with the half-circle button next to Quarto's
light/dark toggle in the navigation bar. The choice is kept in `localStorage`
(`notes-contrast`) and applied from the `<head>` on the next page, so nothing
flashes. High contrast and night mode are two separate axes: either toggle
works whatever the other one says.
Three ways in, in order of precedence:
1. what the reader last picked with the button;
2. `high-contrast: true` in `_quarto.yml`, for the whole book;
3. the reader's system setting, `prefers-contrast: more`, which is watched, so
changing it takes effect without a reload — until the reader picks for
themselves, after which their choice stands.
Measured on a chapter of Analysis, contrast against the page (WCAG AA is 4.5);
captions re-measured with 2.8.4, which gives them the muted token:
| | body | link | toc | caption | code keyword | comment |
|---|---|---|---|---|---|---|
| ordinary light | 11.5 | 5.4 | 5.4 | 6.4 | — | — |
| high contrast light | 18.9 | 8.0 | 8.0 | 18.9 | 8.1 | 5.0 |
| ordinary dark | 15.9 | 6.5 | 6.5 | 6.3 | — | — |
| high contrast dark | 17.6 | 9.2 | 9.2 | 17.6 | 9.7 | 11.7 |
## Exercises
```markdown
@@ -100,6 +205,30 @@ printed at the end of the chapter with a page reference back to the quiz
Correct answers are part of the built HTML, as solutions are: the quiz is a
self-check, not an assessment.
## To go further
Material that sits beside the course's own statement — a formal construction, a
proof the lecture skipped, a pointer to the wider theory:
```markdown
::: {.further}
Everything in here is optional.
:::
::: {.further title="Cantor pairing"}
…
:::
```
In a multilingual book, wrap the body in `::: {.de}` / `{.fr}` / `{.en}` divs as
usual, and write the title as `title="@tr{key}"` — a literal `title=` is an
attribute and stays in whatever language you typed it.
It renders as a purple box, headed "To go further" (following `lang`: *Vertiefung*,
*Pour aller plus loin*). Override the heading with `further: label: "…"` and the
colour with `furthercolor:` in `_quarto.yml`. Use it whenever the handwritten
pages carry a "to go further" annotation.
## Tools
**Hand in solutions.** Renders only the chosen exercises to `_handin/`, and
@@ -123,3 +252,20 @@ _extensions/notes/sync.sh
A copy that was edited in place (or has a higher `version:`) is skipped with a
diff, so nothing is overwritten silently. Bump `version:` in `_extension.yml`
when you change something.
**Check contrast and phone width.** Loads every page of a build in light,
dark and both high-contrast modes, at 320 and 1280 px, and measures every
visible text node (folds opened, opacity counted) against its ground, and
anything wider than the screen. Point it at `_book/` or at a scratch render;
it works on a temporary copy and never writes to the build:
```bash
quarto render --profile fr --to html --output-dir /tmp/fr-test
_extensions/notes/audit.py /tmp/fr-test # 320 and 1280 px
_extensions/notes/audit.py _book --widths 320 --json out.json
```
It prints the worst ratio per mode, every text under 4.5:1 with its element
and colour, and every page wider than the screen; the exit status is 1 if
anything fails. `audit-page.js` is the part that runs in the page. Needs
Playwright's `chrome-headless-shell` under `~/.cache/ms-playwright/`.
+2 -1
View File
@@ -1,6 +1,6 @@
title: notes
author: Matsune
version: 2.3.0
version: 2.8.18
quarto-required: ">=1.4.0"
contributes:
filters:
@@ -20,6 +20,7 @@ contributes:
- path: quiz.lua
at: pre-ast
- si-mathjax.lua
- further.lua
- latex-tables.lua
# post-quarto: after Quarto's crossref, so {#eq-...} labels on calc blocks
# resolve; glossary last, so \gls{} inside a calc block is linked too
+133
View File
@@ -0,0 +1,133 @@
// audit-page.js -- injected by audit.py into a copy of a built page.
//
// In light, dark, light + high contrast and dark + high contrast it measures
// * the contrast of every visible text node against its composited ground
// (opacity included; a disabled control is exempt, WCAG 1.4.3), and
// * horizontal overflow: text ranges and element boxes past the viewport,
// ignoring content inside a box that scrolls itself.
// Every <details> is opened first, so hints and solutions are measured too.
// The result goes, as JSON, into body[data-audit].
(function () {
var cv = document.createElement('canvas'); cv.width = cv.height = 1;
var cx = cv.getContext('2d', { willReadFrequently: true });
// any css colour (oklch, color-mix ...) -> [r, g, b, a], via a 1x1 canvas
function rgb(c) {
cx.clearRect(0, 0, 1, 1); cx.fillStyle = '#000'; cx.fillStyle = c; cx.fillRect(0, 0, 1, 1);
var d = cx.getImageData(0, 0, 1, 1).data; return [d[0], d[1], d[2], d[3] / 255];
}
function lum(p) {
var a = p.slice(0, 3).map(function (v) { v /= 255; return v <= 0.03928 ? v / 12.92 : Math.pow((v + 0.055) / 1.055, 2.4); });
return 0.2126 * a[0] + 0.7152 * a[1] + 0.0722 * a[2];
}
function blend(fg, bg) { var a = fg[3]; return [fg[0] * a + bg[0] * (1 - a), fg[1] * a + bg[1] * (1 - a), fg[2] * a + bg[2] * (1 - a), 1]; }
// the ground under an element: its translucent layers composited on the page
function bgOf(el) {
var layers = [];
for (var e = el; e; e = e.parentElement) {
var c = rgb(getComputedStyle(e).backgroundColor);
if (c[3] > 0) { layers.push(c); if (c[3] >= 0.99) break; }
}
var base = rgb(getComputedStyle(document.body).backgroundColor);
if (base[3] < 0.99) base = [255, 255, 255, 1];
for (var i = layers.length - 1; i >= 0; i--) base = blend(layers[i], base);
return base;
}
function ratio(f, b) { var L1 = lum(f), L2 = lum(b); return (Math.max(L1, L2) + 0.05) / (Math.min(L1, L2) + 0.05); }
function label(el) {
var s = el.tagName.toLowerCase();
if (el.id) s += '#' + el.id;
var cl = (typeof el.className === 'string' ? el.className : '').trim().split(/\s+/).filter(Boolean).slice(0, 2);
if (cl.length) s += '.' + cl.join('.');
var p = el.parentElement;
if (p) { var pc = (typeof p.className === 'string' ? p.className : '').trim().split(/\s+/).filter(Boolean)[0]; s = (p.tagName.toLowerCase() + (pc ? '.' + pc : '')) + ' > ' + s; }
var box = el.closest('.exo, .exo-hint, .exo-sol, .further, .callout, .quiz, .gls-inline, .calc-note, .cell-output, nav, .sidebar, header, footer');
if (box) s += ' [in ' + box.tagName.toLowerCase() + '.' + String(box.className).trim().split(/\s+/)[0] + ']';
return s;
}
function visible(el) {
if (!el.getClientRects().length) return false;
var cs = getComputedStyle(el);
if (cs.visibility === 'hidden' || +cs.opacity === 0) return false;
for (var e = el; e; e = e.parentElement) if (+getComputedStyle(e).opacity < 0.05) return false;
return true;
}
function scrollsX(el) {
for (var e = el; e && e !== document.body; e = e.parentElement) {
var o = getComputedStyle(e).overflowX;
if (o === 'auto' || o === 'scroll' || o === 'hidden' || o === 'clip') return true;
}
return false;
}
function measure() {
var W = window.innerWidth, worst = [], over = [];
var walker = document.createTreeWalker(document.body, NodeFilter.SHOW_TEXT);
var seen = new Set(), n;
while ((n = walker.nextNode())) {
if (!n.nodeValue.trim()) continue;
var el = n.parentElement;
if (!el || seen.has(el)) continue;
seen.add(el);
if (/^(SCRIPT|STYLE|NOSCRIPT|TEMPLATE)$/.test(el.tagName)) continue;
if (el.closest('mjx-container, .MathJax, svg, [aria-hidden="true"], .visually-hidden, .sr-only')) continue;
if (!visible(el)) continue;
// a disabled control is exempt from the contrast minimum (WCAG 1.4.3)
if (el.closest('[disabled], [aria-disabled="true"], .exo-locked')) continue;
var cs = getComputedStyle(el), f = rgb(cs.color);
// opacity on the element or any ancestor fades the text into its ground
var op = 1;
for (var oe = el; oe; oe = oe.parentElement) op *= +getComputedStyle(oe).opacity;
f = [f[0], f[1], f[2], f[3] * op];
var b = bgOf(el); f = blend(f, b);
var r = ratio(f, b);
worst.push({ r: +r.toFixed(2), el: label(el), text: n.nodeValue.trim().slice(0, 40), fg: cs.color });
if (!scrollsX(el)) {
var rg = document.createRange(); rg.selectNodeContents(n);
var rr = rg.getBoundingClientRect();
if (rr.width && (rr.right > W + 1 || rr.left < -1)) over.push({ el: label(el), right: Math.round(rr.right), text: n.nodeValue.trim().slice(0, 40) });
}
}
document.querySelectorAll('body *').forEach(function (el) {
if (!el.getClientRects().length || scrollsX(el)) return;
var r = el.getBoundingClientRect();
if (r.width && r.right > W + 1 && getComputedStyle(el).position !== 'fixed') over.push({ el: label(el), right: Math.round(r.right) });
});
worst.sort(function (a, b) { return a.r - b.r; });
var fails = worst.filter(function (w) { return w.r < 4.5; });
return { worst: worst.slice(0, 3), fails: fails.length, failList: fails.slice(0, 8), overflow: over.slice(0, 6), overflowCount: over.length, docWidth: document.documentElement.scrollWidth, W: W };
}
function run() {
var st = document.createElement('style'); st.textContent = '*,*::before,*::after{transition:none!important;animation:none!important}'; document.head.appendChild(st);
// measure what a reader can unfold: hints, solutions, notes
document.querySelectorAll('details').forEach(function (d) { d.open = true; });
var hasToggle = typeof window.quartoToggleColorScheme === 'function';
var out = { hasDarkToggle: hasToggle, hasHcButton: !!document.querySelector('.notes-contrast-toggle'), modes: [] };
var M = [[false, false], [true, false], [false, true], [true, true]], i = 0;
// Quarto loads the dark stylesheet only when the toggle asks for it:
// measuring before it arrives reads dark colours on the light ground
function sheetsReady() {
return Array.prototype.every.call(document.querySelectorAll('link[rel~="stylesheet"]'), function (l) {
if (l.disabled) return true;
try { return !!l.sheet && l.sheet.cssRules !== null; } catch (e) { return true; }
});
}
function step() {
if (i === M.length) { document.body.setAttribute('data-audit', JSON.stringify(out)); return; }
var m = M[i];
if (m[0] && !hasToggle) { out.modes.push({ dark: true, hc: m[1], skipped: 'no dark theme' }); i++; return step(); }
if (hasToggle && document.body.classList.contains('quarto-dark') !== m[0]) window.quartoToggleColorScheme();
document.documentElement.classList.toggle('hc', m[1]);
var tries = 0;
(function wait() {
if (!sheetsReady() && tries++ < 40) return setTimeout(wait, 100);
setTimeout(function () {
var r = measure();
r.dark = document.body.classList.contains('quarto-dark'); r.hc = document.documentElement.classList.contains('hc');
r.bodyBg = getComputedStyle(document.body).backgroundColor;
out.modes.push(r); i++; step();
}, 500);
})();
}
step();
}
window.addEventListener('load', function () { setTimeout(run, 400); });
})();
+132
View File
@@ -0,0 +1,132 @@
#!/usr/bin/env python3
"""audit.py -- four-mode check of a built book: contrast and phone width.
_extensions/notes/audit.py <built dir> [--widths 320,1280] [--jobs 4] [--json out.json]
<built dir> is _book/ or a scratch render (quarto render --output-dir ...).
It is copied to a temporary folder -- the build itself is never written to --
and audit-page.js is injected into a copy of every page. The copy is served on
127.0.0.2 (the language switcher is off on localhost) and each page is loaded
in chrome-headless-shell at each width, with overlay scrollbars as on a phone.
For light, dark, light + high contrast and dark + high contrast it prints the
worst text contrast, every text below 4.5:1 (WCAG AA), and any page wider than
the screen. Needs Playwright's headless shell:
~/.cache/ms-playwright/chromium_headless_shell-*/chrome-headless-shell-linux64/
"""
import argparse, concurrent.futures as cf, glob, html, json, os, re, shutil, subprocess, sys, tempfile, threading
from functools import partial
from http.server import ThreadingHTTPServer, SimpleHTTPRequestHandler
HERE = os.path.dirname(os.path.abspath(__file__))
SHELLS = sorted(glob.glob(os.path.expanduser(
"~/.cache/ms-playwright/chromium_headless_shell-*/chrome-headless-shell-linux64/chrome-headless-shell")))
# the switcher redirects a page whose language differs from the remembered one
PIN_LANG = ("<script>document.cookie='notes-lang='+(document.documentElement.lang||'en')"
".slice(0,2)+'; path=/';</script>")
MODES = ["light", "dark", "light+hc", "dark+hc"]
def mirror(src):
dst = os.path.join(tempfile.mkdtemp(prefix="notes-audit-"), "site")
shutil.copytree(src, dst, ignore=shutil.ignore_patterns("*.pdf", "*.ipynb", "*.zip"))
shutil.copy(os.path.join(HERE, "audit-page.js"), os.path.join(dst, "__audit.js"))
pages = []
for p in glob.glob(os.path.join(dst, "**", "*.html"), recursive=True):
rel = os.path.relpath(p, dst)
if "site_libs" in rel or "/figures/" in "/" + rel:
continue
s = open(p, encoding="utf-8").read()
if "quarto" not in s or "<main" not in s:
continue
s = re.sub(r"<head>", "<head>" + PIN_LANG, s, count=1)
s = s.replace("</body>", '<script src="/__audit.js"></script></body>', 1)
out = p[:-5] + ".audit.html"
open(out, "w", encoding="utf-8").write(s)
pages.append(os.path.relpath(out, dst))
return dst, sorted(pages)
def load(shell, url, width):
cmd = [shell, "--headless", "--disable-gpu", "--no-sandbox", "--hide-scrollbars",
f"--window-size={width},900", "--virtual-time-budget=15000", "--dump-dom", url]
try:
dom = subprocess.run(cmd, capture_output=True, text=True, timeout=90).stdout
except subprocess.TimeoutExpired:
return {"error": "timeout"}
m = re.search(r'data-audit="([^"]*)"', dom)
return json.loads(html.unescape(m.group(1))) if m else {"error": "no result"}
def main():
ap = argparse.ArgumentParser(description=__doc__.split("\n")[0])
ap.add_argument("built")
ap.add_argument("--widths", default="320,1280")
ap.add_argument("--port", type=int, default=0, help="0 = any free port")
ap.add_argument("--jobs", type=int, default=4)
ap.add_argument("--json")
a = ap.parse_args()
if not SHELLS:
sys.exit("audit: no chrome-headless-shell under ~/.cache/ms-playwright")
dst, pages = mirror(os.path.abspath(a.built))
class Quiet(SimpleHTTPRequestHandler):
def log_message(self, *x):
pass
srv = ThreadingHTTPServer(("127.0.0.2", a.port), partial(Quiet, directory=dst))
port = srv.server_address[1]
threading.Thread(target=srv.serve_forever, daemon=True).start()
widths = [int(w) for w in a.widths.split(",")]
jobs = [(p, w) for p in pages for w in widths]
results = {}
with cf.ThreadPoolExecutor(a.jobs) as ex:
futs = {ex.submit(load, SHELLS[-1], f"http://127.0.0.2:{port}/{p}", w): (p, w) for p, w in jobs}
for f in cf.as_completed(futs):
results[futs[f]] = f.result()
srv.shutdown()
shutil.rmtree(os.path.dirname(dst), ignore_errors=True)
worst = {n: (99, None) for n in MODES}
fails, overflow, errors, flags_bad, no_toggle = [], [], [], [], set()
for (p, w), r in sorted(results.items()):
if "error" in r:
errors.append(f"{p} @{w}: {r['error']}"); continue
if not r.get("hasDarkToggle") or not r.get("hasHcButton"):
no_toggle.add(p)
for i, m in enumerate(r["modes"]):
n = MODES[i]
if m.get("skipped"):
continue
if m["dark"] != (i in (1, 3)) or m["hc"] != (i in (2, 3)):
flags_bad.append(f"{p} @{w} {n}")
if m["worst"] and m["worst"][0]["r"] < worst[n][0]:
worst[n] = (m["worst"][0]["r"], f"{p} @{w}: {m['worst'][0]['el']} «{m['worst'][0]['text']}»")
for fl in m["failList"]:
fails.append((fl["r"], n, w, p, fl["el"], fl["text"], fl["fg"]))
if m["overflowCount"] or m["docWidth"] > m["W"]:
overflow.append((n, w, p, m["docWidth"], m["W"], m["overflow"][:3]))
print(f"pages: {len(pages)} widths: {widths} runs: {len(jobs)} errors: {len(errors)}")
if no_toggle:
print(f"WITHOUT dark toggle or ◐ button: {len(no_toggle)} page(s), e.g. {sorted(no_toggle)[0]}")
if flags_bad:
print("MODE FLAGS WRONG:", flags_bad[:5])
for n in MODES:
print(f" worst {n:9s} {worst[n][0]:6.2f} {worst[n][1] or '(not measured)'}")
uniq = {}
for f in sorted(fails):
uniq.setdefault((f[1], f[4], f[6]), f)
print(f"text below 4.5: {len(fails)} element-runs, {len(uniq)} distinct (mode, element, colour)")
for f in list(uniq.values())[:25]:
print(f" {f[0]:5.2f} {f[1]:9s} @{f[2]} {f[3]}: {f[4]} «{f[5]}» {f[6]}")
print(f"overflow: {len(overflow)} page-runs")
for o in overflow[:10]:
print(f" {o[0]} @{o[1]} {o[2]}: page {o[3]}px in a {o[4]}px screen {o[5]}")
for e in errors[:10]:
print(" ERROR", e)
if a.json:
json.dump({f"{p}@{w}": r for (p, w), r in results.items()}, open(a.json, "w"), indent=1)
sys.exit(1 if (fails or overflow or errors or flags_bad) else 0)
if __name__ == "__main__":
main()
+17 -2
View File
@@ -43,8 +43,8 @@
cursor: pointer;
list-style: none; /* remove the default triangle ... */
user-select: none;
opacity: 0.7;
font-style: italic;
font-style: italic; /* quiet by style and --calc-muted (theme.css), not by
opacity, which took it under 4.5:1 */
}
.calc-note > summary::-webkit-details-marker { display: none; }
.calc-note > summary::before { content: "▸ "; font-style: normal; }
@@ -98,3 +98,18 @@
.calc-full { grid-column: 1 / 3; }
.calc-tag { grid-column: 1 / -1; }
}
/* --- interactive figures ------------------------------------------------
A figure that is dragged — a rotatable 3d view, a point moved with the
mouse — must not select its own labels while the pointer travels over
them: the browser would paint the axis names and captions as selected
text. The readouts and captions around the drawing stay selectable, so a
value can still be copied. The hooks are the ones every course's figure
scripts build into. */
[data-notes-fig] svg,
[data-notes-plot] svg,
[data-notes-fig] canvas,
[data-notes-plot] canvas {
-webkit-user-select: none;
user-select: none;
}
+55
View File
@@ -13,3 +13,58 @@
});
});
})();
// --- high contrast: a switch of its own, beside Quarto's light/dark one ----
// The class is already set before the first paint by the script calc-notes.lua
// puts in the head; this only builds the control and remembers a choice.
// Precedence: what the reader picked here, then `high-contrast: true` in the
// book, then the reader's system setting.
(function () {
var KEY = "notes-contrast";
var root = document.documentElement;
var LABELS = {
de: { on: "Hoher Kontrast aus", off: "Hoher Kontrast ein" },
fr: { on: "Désactiver le contraste élevé", off: "Activer le contraste élevé" },
en: { on: "Turn high contrast off", off: "Turn high contrast on" }
};
var lang = (root.lang || "en").slice(0, 2).toLowerCase();
var L = LABELS[lang] || LABELS.en;
function store(v) {
try { localStorage.setItem(KEY, v ? "more" : "normal"); } catch (e) {}
}
function paint() {
var on = root.classList.contains("hc");
document.querySelectorAll(".notes-contrast-toggle").forEach(function (b) {
b.setAttribute("aria-pressed", String(on));
b.setAttribute("title", on ? L.on : L.off);
b.setAttribute("aria-label", on ? L.on : L.off);
});
}
function build() {
var anchors = document.querySelectorAll(".quarto-color-scheme-toggle");
if (anchors.length === 0) return; // a page without Quarto's own tools
anchors.forEach(function (a) {
var b = document.createElement("button");
b.type = "button";
b.className = "quarto-navigation-tool px-1 notes-contrast-toggle";
// bootstrap-icons ships with these books; the glyph is the fallback
b.innerHTML = '<i class="bi bi-circle-half" aria-hidden="true"></i>';
b.addEventListener("click", function () {
var on = !root.classList.contains("hc");
root.classList.toggle("hc", on);
store(on);
paint();
});
a.parentNode.insertBefore(b, a.nextSibling);
});
paint();
}
if (document.readyState === "loading") {
document.addEventListener("DOMContentLoaded", build);
} else { build(); }
})();
+41 -3
View File
@@ -385,16 +385,54 @@ function Meta(m)
if m.notecolor then
notecolor = pandoc.utils.stringify(m.notecolor)
end
local notecolor_dark = m["notecolor-dark"] ~= nil
and pandoc.utils.stringify(m["notecolor-dark"]) or nil
if quarto == nil or quarto.doc == nil then return end -- plain pandoc: skip injection
if fmt_is("html") then
quarto.doc.add_html_dependency({
name = "calc-notes",
version = "1.0.0",
stylesheets = { "calc-notes.css" },
stylesheets = { "theme.css", "high-contrast.css", "calc-notes.css", "narrow.css" },
scripts = { "calc-notes.js" },
})
quarto.doc.include_text("in-header",
"<style>:root { --calc-notecolor: " .. notecolor .. "; }</style>")
-- `-src` holds the book's own colour, which theme.css lifts for a dark
-- page rather than replacing; `-dark` is a book's explicit override.
quarto.doc.include_text("in-header", table.concat({
"<style>:root {",
" --calc-notecolor-src: " .. notecolor .. ";",
" --calc-notecolor: var(--calc-notecolor-src);",
notecolor_dark and (" --calc-notecolor-dark: " .. notecolor_dark .. ";") or "",
"}</style>",
}, "\n"))
-- Mark <html> while the head is still parsing, so high-contrast.css is in
-- force before the first paint and the page never flashes the ordinary
-- palette. Three ways in, in this order of precedence: what the reader
-- last picked with the toggle in the navigation bar, `high-contrast: true`
-- in the book, and the reader's own system setting, which is watched so
-- that changing it takes effect without a reload.
local forced = (m["high-contrast"] == true) or
(m["high-contrast"] ~= nil and pandoc.utils.stringify(m["high-contrast"]) == "true")
quarto.doc.include_text("in-header", table.concat({
"<script>(function (e) {",
" var KEY = 'notes-contrast', forced = " .. (forced and "true" or "false") .. ";",
" var picked = null;",
" try { picked = localStorage.getItem(KEY); } catch (err) {}",
" var q = null;",
" try { q = window.matchMedia && window.matchMedia('(prefers-contrast: more)'); } catch (err) {}",
" if (picked === 'more' || (picked !== 'normal' && (forced || (q && q.matches)))) {",
" e.classList.add('hc');",
" }",
" if (q) {",
" var f = function () {",
" var p = null;",
" try { p = localStorage.getItem(KEY); } catch (err) {}",
" if (p === null) e.classList.toggle('hc', forced || q.matches);",
" };",
" if (q.addEventListener) q.addEventListener('change', f);",
" else if (q.addListener) q.addListener(f);",
" }",
"})(document.documentElement);</script>",
}, "\n"))
elseif fmt_is("latex") then
quarto.doc.use_latex_package("mathtools") -- \Aboxed
quarto.doc.use_latex_package("xcolor")
+2
View File
@@ -66,6 +66,8 @@
padding: 0.35rem 0.1rem 0.1rem;
scroll-margin-top: 5rem;
}
/* Quarto greys every summary (#6c757d): 3.4:1 on darkly */
.exo-sol > summary { color: var(--calc-muted, #57606a); }
/* in a numbered part, the fold lines up with the part's text */
.exo li > details { margin-left: 0; }
+34
View File
@@ -0,0 +1,34 @@
/* further — "to go further" notes: optional material, set apart in purple */
.further {
margin: 1.1rem 0;
padding: 0.5rem 0.9rem 0.6rem;
border: 1px solid color-mix(in srgb, var(--calc-furthercolor, #6B3FA0) 30%, transparent);
border-left: 3px solid var(--calc-furthercolor, #6B3FA0);
border-radius: 0.35rem;
background: color-mix(in srgb, var(--calc-furthercolor, #6B3FA0) 4%, transparent);
}
.further-head {
color: var(--calc-furthercolor, #6B3FA0);
font-weight: 600;
font-size: 0.92em;
margin-bottom: 0.35rem;
}
.further-body > p:first-child { margin-top: 0; }
.further-body > p:last-child { margin-bottom: 0; }
/* keep wide content inside the box, as .calc and .exo do */
.further mjx-container[display="true"],
.further .katex-display {
max-width: 100%;
overflow-x: auto;
overflow-y: hidden;
padding-bottom: 0.35em;
display: flex;
justify-content: center;
justify-content: safe center;
}
.further :is(pre, table) { max-width: 100%; overflow-x: auto; }
.further img, .further svg { max-width: 100%; }
+134
View File
@@ -0,0 +1,134 @@
-- further.lua — "to go further" notes, for material beside the lecture's own
--
-- ::: {.further}
-- Everything in here is optional reading.
-- :::
--
-- ::: {.further title="Cantor pairing"}
-- ...
-- :::
--
-- The box is purple, so it reads as an aside and never as the course's own
-- statement. HTML: a box with a heading. PDF: a tcolorbox in the same colour.
--
-- Metadata:
-- furthercolor: "#6B3FA0" # the accent of these notes
-- further:
-- label: "Pour aller plus loin" # defaults to the document `lang`
local LABELS = {
en = "To go further",
fr = "Pour aller plus loin",
de = "Vertiefung",
}
local DEFAULT_COLOR = "#6B3FA0"
local label = LABELS.en
local color = DEFAULT_COLOR
local function fmt_is(name)
if quarto and quarto.doc and quarto.doc.is_format then
return quarto.doc.is_format(name)
end
return FORMAT ~= nil and FORMAT:match(name) ~= nil
end
local function str(v)
if v == nil then return nil end
if type(v) == "boolean" then return tostring(v) end
return pandoc.utils.stringify(v)
end
local function esc_html(s)
return (s:gsub("&", "&amp;"):gsub("<", "&lt;"):gsub(">", "&gt;"):gsub('"', "&quot;"))
end
local function read_meta(meta)
local lang = (str(meta.lang) or "en"):lower():gsub("[_-].*$", "")
label = LABELS[lang] or LABELS.en
if type(meta.further) == "table" and meta.further.label ~= nil then
label = str(meta.further.label)
end
if meta.furthercolor ~= nil then
color = str(meta.furthercolor)
end
local color_dark = meta["furthercolor-dark"] ~= nil
and str(meta["furthercolor-dark"]) or nil
if quarto ~= nil and quarto.doc ~= nil then
if fmt_is("html") then
quarto.doc.add_html_dependency({
name = "calc-further",
version = "1.0.0",
stylesheets = { "further.css" },
})
-- as for notecolor: the book's own colour is kept, and theme.css
-- lifts it for a dark page instead of replacing it
quarto.doc.include_text("in-header", table.concat({
"<style>:root {",
" --calc-furthercolor-src: " .. color .. ";",
" --calc-furthercolor: var(--calc-furthercolor-src);",
color_dark and (" --calc-furthercolor-dark: " .. color_dark .. ";") or "",
"}</style>",
}, "\n"))
elseif fmt_is("latex") then
-- same options as Quarto's callouts, so the two never clash
quarto.doc.use_latex_package("tcolorbox", "skins,breakable")
quarto.doc.use_latex_package("xcolor")
quarto.doc.include_text("in-header",
"\\definecolor{furthercolor}{HTML}{" .. color:gsub("^#", "") .. "}")
end
end
return meta
end
------------------------------------------------------------------ render
-- `sep`: what goes between the label and a title= of its own. LaTeX fonts
-- often lack the U+2002 glyph, so the pdf gets \enspace instead.
local function head_text(el, sep)
local title = el.attributes.title
if title ~= nil and title ~= "" then
return label .. (sep or "\u{2002}—\u{2002}") .. title
end
return label
end
local function html_box(el)
local blocks = pandoc.Blocks({ pandoc.RawBlock("html",
'<div class="further"><div class="further-head">'
.. esc_html(head_text(el)) .. '</div><div class="further-body">') })
blocks:extend(el.content)
blocks:insert(pandoc.RawBlock("html", "</div></div>"))
return blocks
end
local function latex_box(el)
local blocks = pandoc.Blocks({ pandoc.RawBlock("latex",
"\\begin{tcolorbox}[enhanced jigsaw,breakable,"
.. "colback=furthercolor!4!white,colframe=furthercolor!55!white,"
.. "boxrule=0.4pt,arc=1pt,colbacktitle=furthercolor!12!white,"
.. "coltitle=furthercolor!80!black,fonttitle=\\small\\bfseries,"
.. "title={" .. head_text(el, "\\enspace---\\enspace{}") .. "},"
.. "left=2mm,right=1.5mm,top=1mm,bottom=1mm]") })
blocks:extend(el.content)
blocks:insert(pandoc.RawBlock("latex", "\\end{tcolorbox}"))
return blocks
end
local function Div(el)
if not el.classes:includes("further") then return nil end
if fmt_is("html") then return html_box(el) end
if fmt_is("latex") then return latex_box(el) end
-- any other format: a plain titled block
local blocks = pandoc.Blocks({
pandoc.Para({ pandoc.Strong({ pandoc.Str(head_text(el) .. ".") }) }) })
blocks:extend(el.content)
return pandoc.Div(blocks, pandoc.Attr("", { "further" }))
end
return {
{ Meta = read_meta },
{ Div = Div },
}
+3 -4
View File
@@ -32,9 +32,9 @@ mjx-container a {
padding: 0.5rem 0.75rem;
border: 1px solid var(--calc-notecolor, #B45309);
border-radius: 0.4rem;
background: var(--bs-body-bg, #fff);
background: var(--calc-surface, #fff);
color: var(--bs-body-color, #1a1a1a);
box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
box-shadow: 0 4px 14px var(--calc-shadow, rgba(0, 0, 0, 0.15));
font-size: 0.9em;
line-height: 1.4;
}
@@ -62,8 +62,7 @@ mjx-container a {
scroll-margin-top: 5rem;
}
.gls-back {
font-size: 0.85em;
opacity: 0.75;
font-size: 0.85em; /* smaller, not fainter: at 0.75 opacity the link read 3.4:1 */
}
/* standalone property cards keep the section flow (no indent) */
+59 -24
View File
@@ -29,6 +29,7 @@
--
-- Usage (works for entries and properties):
-- in math: \gls{laplacian} \gls{laplacian.linearity}
-- \gls[\nabla^2 g]{laplacian} (shows a variant, links to the entry)
-- in prose: [laplacian]{.gls} [by linearity]{.gls key=laplacian.linearity}
-- the list: ::: {.glossary}\n:::
--
@@ -330,7 +331,11 @@ local function register_inline(el)
if b.t == "Div" and b.classes:includes("gls-prop") then
local pk = b.attributes.key
if pk == nil then
io.stderr:write("[glossary] .gls-prop without key= (in " .. key .. ")\n")
-- keep the text: it stays in the definition, unlisted as a property
io.stderr:write("[glossary] WARNING: .gls-prop without key= in '" .. key
.. "': its text is kept in the definition but is not listed as a"
.. " property; add key=<name> to list it\n")
entry.def:extend(b.content)
else
entry.props[pk] = {
sym = math_of_attr(b.attributes.symbol),
@@ -356,21 +361,30 @@ end
------------------------------------------------------------------ pass 3: usages & rendering
-- rewrite \gls{...} occurrences inside a TeX/math string
-- rewrite \gls{key} and \gls[shown]{key} occurrences inside a TeX/math
-- string. The optional [shown] is what the formula displays instead of the
-- entry's own symbol -- a variant of it, M_{n \times p}(\mathbb{K}) for the
-- entry M_{m \times n}(\mathbb{K}) -- and it links to the entry all the same.
local function gls_link(key, shown, target)
local r = resolve(key)
if r == nil then
warn_key(key)
return "\\text{??" .. key .. "??}"
end
local disp = shown or math_display(r)
if target == "latex" then
-- \protect: a link may sit in a moving argument (a figure caption)
return "\\protect\\hyperlink{" .. r.id .. "}{" .. disp .. "}"
end
return "\\href{" .. r.href .. "}{\\class{gls-sym gls-key-" .. key .. "}{" .. disp .. "}}"
end
local function replace_gls(txt, target)
txt = txt:gsub("\\gls%s*(%b[])%s*(%b{})", function(bracketed, braced)
return gls_link(braced:sub(2, -2), bracketed:sub(2, -2), target)
end)
return (txt:gsub("\\gls(%b{})", function(braced)
local key = braced:sub(2, -2)
local r = resolve(key)
if r == nil then
warn_key(key)
return "\\text{??" .. key .. "??}"
end
local disp = math_display(r)
if target == "latex" then
return "\\hyperlink{" .. r.id .. "}{" .. disp .. "}"
else
return "\\href{" .. r.href .. "}{\\class{gls-sym gls-key-" .. key .. "}{" .. disp .. "}}"
end
return gls_link(braced:sub(2, -2), nil, target)
end))
end
@@ -397,7 +411,7 @@ local function usage(key, display)
end
local out = pandoc.Inlines({})
if fmt_is("latex") then
out:insert(pandoc.RawInline("latex", "\\hyperlink{" .. r.id .. "}{"))
out:insert(pandoc.RawInline("latex", "\\protect\\hyperlink{" .. r.id .. "}{"))
out:extend(display)
out:insert(pandoc.RawInline("latex", "}"))
elseif fmt_is("html") then
@@ -436,6 +450,8 @@ end
local function RawInline(el)
if el.format ~= "tex" and el.format ~= "latex" then return nil end
-- (no [shown] form here: pandoc reads \gls[..]{..} in prose as plain text,
-- never as raw tex; a variant in prose is [$...$]{.gls key=...})
local key = el.text:match("^\\gls%s*{(.-)}$")
if key == nil then return nil end
local r = resolve(key)
@@ -443,6 +459,15 @@ local function RawInline(el)
return usage(key, pandoc.Inlines({ pandoc.Math("InlineMath", math_display(r)) }))
end
-- A definition is stored in pass 2, before its own usages are resolved: run
-- them on the stored copy wherever it is shown (in place, in the list, in
-- the tooltip data and the cross-file cache), or a \gls{..} / [..]{.gls}
-- written inside a definition would come out unresolved.
local function resolved(blocks)
if blocks == nil then return blocks end
return blocks:walk({ Math = Math, RawBlock = RawBlock, RawInline = RawInline, Span = Span })
end
-- head line "sym — **term**" (+ latex hypertarget when with_anchor)
local function head_line(id, sym, term, with_anchor)
local head = pandoc.Inlines({})
@@ -460,7 +485,7 @@ end
local function prop_div(base, pk, p, with_anchor)
local id = anchor(base .. "." .. pk)
local blocks = pandoc.Blocks({ head_line(id, p.sym, p.term, with_anchor) })
blocks:extend(p.def:clone())
blocks:extend(resolved(p.def:clone()))
return pandoc.Div(blocks,
pandoc.Attr(with_anchor and id or "", { "gls-entry", "gls-prop-entry" }))
end
@@ -473,7 +498,7 @@ local function render_inline_def(el)
if e == nil or not e.inline then return nil end
local id = anchor(key)
local blocks = pandoc.Blocks({ head_line(id, e.sym, e.term, true) })
blocks:extend(e.def:clone())
blocks:extend(resolved(e.def:clone()))
for _, pk in ipairs(e.porder) do
if not e.props[pk].standalone then -- standalone props render at their own spot
blocks:insert(prop_div(key, pk, e.props[pk], true))
@@ -493,7 +518,7 @@ local function render_list(el)
-- the list clone links back instead of re-anchoring
local with_anchor = not e.inline
local entry = pandoc.Blocks({ head_line(id, e.sym, e.term, with_anchor) })
entry:extend(e.def:clone())
entry:extend(resolved(e.def:clone()))
if e.inline then
for _, pk in ipairs(e.porder) do
local p = e.props[pk]
@@ -610,11 +635,11 @@ local function write_cache()
for pk, p in pairs(e.props) do
props[pk] = { sym = p.sym,
term = pandoc.utils.stringify(p.term),
def_html = blocks_to_html(p.def) }
def_html = blocks_to_html(resolved(p.def)) }
end
entries[key] = { sym = e.sym,
term = pandoc.utils.stringify(e.term),
def_html = blocks_to_html(e.def),
def_html = blocks_to_html(resolved(e.def)),
page = current_page,
props = props }
end
@@ -645,13 +670,23 @@ local function inject_data(doc)
if not fmt_is("html") then return doc end
write_cache()
if quarto == nil or quarto.doc == nil then return doc end
-- in sorted order: pairs() walks a table in a different order on every
-- run, which rewrote every page of a book on each rebuild
local function sorted_keys(t)
local ks = {}
for k in pairs(t) do ks[#ks + 1] = k end
table.sort(ks)
return ks
end
local parts = {}
for key, e in pairs(glossary) do
for _, key in ipairs(sorted_keys(glossary)) do
local e = glossary[key]
parts[#parts + 1] = '"' .. js_escape(key) .. '":"'
.. js_escape(head_html(e.sym, e.term) .. blocks_to_html(e.def)) .. '"'
for pk, p in pairs(e.props) do
.. js_escape(head_html(e.sym, e.term) .. blocks_to_html(resolved(e.def))) .. '"'
for _, pk in ipairs(sorted_keys(e.props)) do
local p = e.props[pk]
parts[#parts + 1] = '"' .. js_escape(key .. "." .. pk) .. '":"'
.. js_escape(head_html(p.sym, p.term) .. blocks_to_html(p.def)) .. '"'
.. js_escape(head_html(p.sym, p.term) .. blocks_to_html(resolved(p.def))) .. '"'
end
end
if #parts == 0 then return doc end
+316
View File
@@ -0,0 +1,316 @@
/* high-contrast.css — the high-contrast pair, taken from GitHub's
"GitHub Light High Contrast" and "GitHub Dark High Contrast" VS Code
themes (the Primer `light_high_contrast` / `dark_high_contrast` scales).
It is switched by `hc` on <html>, which calc-notes.lua sets from
high-contrast: true
in the document metadata, and which the same in-header script sets for a
reader whose system asks for `prefers-contrast: more`. One class rather
than a class and a media query, so the palette below is written once.
It rides on top of the ordinary light/dark pair: `html.hc` restyles the
light theme, `html.hc body.quarto-dark` the night one, so the reader's own
light/dark toggle keeps working.
GitHub's two high-contrast themes separate things by outline rather than by
fill: text sits at full strength (fg.muted == fg.default), borders are
strong, and the tinted panels of the ordinary themes lose their tint. The
rules here do the same to the notes environments. */
/* ---------------------------------------------------------------- light -- */
html.hc {
/* Primer light_high_contrast */
--hc-canvas: #ffffff; /* canvas.default */
--hc-inset: #ffffff; /* canvas.inset — separation is by border */
--hc-fg: #0e1116; /* fg.default, and fg.muted, which equals it */
--hc-subtle: #66707b; /* fg.subtle — the only softened ink */
--hc-border: #20252c; /* border.default */
--hc-border-soft: #88929d; /* border.muted */
--hc-accent: #0349b4; /* accent.fg */
--hc-danger: #a0111f; /* danger.fg */
--hc-success: #055d20; /* success.fg */
--hc-attention: #4e2c00; /* attention.fg */
--hc-severe: #702c00; /* severe.fg */
--hc-done: #622cbc; /* done.fg */
/* the extension's own tokens */
--calc-ink: var(--hc-fg);
--calc-muted: var(--hc-fg);
--calc-line: var(--hc-border);
--calc-grid: var(--hc-border-soft);
--calc-accent-a: var(--hc-accent);
--calc-accent-b: var(--hc-severe);
--calc-accent-c: var(--hc-success);
--calc-danger: var(--hc-danger);
--calc-surface: var(--hc-canvas);
--calc-faint: var(--hc-border-soft);
--calc-shadow: rgba(14, 17, 22, 0.4);
--calc-domface: var(--hc-canvas);
--calc-domtop: #d8dee4;
--calc-notecolor: var(--hc-attention);
--calc-furthercolor: var(--hc-done);
/* the page itself */
--bs-body-bg: var(--hc-canvas);
--bs-body-color: var(--hc-fg);
--bs-emphasis-color: var(--hc-fg);
--bs-secondary-color: var(--hc-fg);
--bs-tertiary-color: var(--hc-subtle);
--bs-border-color: var(--hc-border);
--bs-link-color: var(--hc-accent);
--bs-link-hover-color: var(--hc-accent);
--bs-code-color: var(--hc-fg);
--bs-heading-color: var(--hc-fg);
}
/* ----------------------------------------------------------------- dark -- */
html.hc body.quarto-dark {
/* Primer dark_high_contrast, except for the canvas: the theme's own
#0a0c10 still reads as a very dark grey next to a black one, so the page
goes fully black and every other value keeps its relation to it. */
--hc-canvas: #000000; /* canvas.default is #0a0c10 upstream */
--hc-inset: #000000; /* canvas.inset */
--hc-subtle-bg: #272b33; /* canvas.subtle */
--hc-fg: #f0f3f6; /* fg.default == fg.muted */
--hc-subtle: #9ea7b3; /* fg.subtle */
--hc-border: #7a828e; /* border.default */
--hc-border-soft: #7a828e; /* border.muted — the same in this theme */
--hc-accent: #71b7ff; /* accent.fg */
--hc-danger: #ff9492; /* danger.fg */
--hc-success: #26cd4d; /* success.fg */
--hc-attention: #f0b72f; /* attention.fg */
--hc-severe: #ff803d; /* severe.fg */
--hc-done: #cb9eff; /* done.fg */
/* a stroke on near-black wants the text colour, not the border grey */
--calc-line: var(--hc-fg);
--calc-grid: var(--hc-border);
--calc-domface: var(--hc-subtle-bg);
--calc-domtop: #3d444d;
--calc-shadow: rgba(1, 4, 9, 0.8);
}
/* the tokens that only alias, so they follow whichever block is in force */
html.hc body.quarto-dark {
--calc-ink: var(--hc-fg);
--calc-muted: var(--hc-fg);
--calc-accent-a: var(--hc-accent);
--calc-accent-b: var(--hc-severe);
--calc-accent-c: var(--hc-success);
--calc-danger: var(--hc-danger);
--calc-surface: var(--hc-canvas);
--calc-faint: var(--hc-border);
--calc-notecolor: var(--hc-attention);
--calc-furthercolor: var(--hc-done);
--bs-body-bg: var(--hc-canvas);
--bs-body-color: var(--hc-fg);
--bs-emphasis-color: var(--hc-fg);
--bs-secondary-color: var(--hc-fg);
--bs-tertiary-color: var(--hc-subtle);
--bs-border-color: var(--hc-border);
--bs-link-color: var(--hc-accent);
--bs-link-hover-color: var(--hc-accent);
--bs-code-color: var(--hc-fg);
--bs-heading-color: var(--hc-fg);
}
/* --------------------------------------------------------- page chrome -- */
/* Quarto's own furniture is compiled from the bootswatch theme, so the
variables above do not reach all of it. */
html.hc body {
background-color: var(--hc-canvas);
color: var(--hc-fg);
}
html.hc :is(h1, h2, h3, h4, h5, h6, p, li, dt, dd, caption, figcaption, th, td) {
color: var(--hc-fg);
}
html.hc :is(.text-muted, .quarto-figure figcaption, figcaption.figure-caption,
.quarto-title-meta-heading, .quarto-title-meta-contents,
.callout-title-container, .footnotes) {
color: var(--hc-fg);
}
html.hc a:not(.nav-link):not(.sidebar-item-text) { color: var(--hc-accent); }
html.hc a:focus-visible,
html.hc button:focus-visible,
html.hc summary:focus-visible { outline: 2px solid var(--hc-accent); outline-offset: 2px; }
html.hc :is(#quarto-sidebar, #quarto-margin-sidebar, .sidebar, .sidebar-navigation,
#quarto-header, .navbar, .quarto-secondary-nav) {
background-color: var(--hc-canvas);
color: var(--hc-fg);
border-color: var(--hc-border);
}
html.hc :is(.sidebar-item-text, .sidebar .nav-link, nav[role="doc-toc"] a, .navbar .nav-link,
.quarto-secondary-nav .nav-link) {
color: var(--hc-fg);
opacity: 1;
}
html.hc .sidebar nav[role="doc-toc"] ul > li > a,
html.hc .sidebar-navigation .sidebar-item a,
html.hc .sidebar-navigation .sidebar-item .sidebar-item-text {
color: var(--hc-fg);
opacity: 1;
}
/* the active entry: Quarto writes its colour with !important, so this is the
one place the palette has to answer in kind */
html.hc .sidebar nav[role="doc-toc"] ul > li > a.active,
html.hc .sidebar nav[role="doc-toc"] ul > li > ul > li > a.active,
html.hc .sidebar nav[role="doc-toc"] ul > li > a:hover,
html.hc .sidebar-navigation .sidebar-item a.active,
html.hc .sidebar-navigation .sidebar-item a:hover {
color: var(--hc-accent) !important;
border-left-color: var(--hc-accent);
font-weight: 600;
}
html.hc nav[role="doc-toc"] { border-left: 1px solid var(--hc-border-soft); }
/* the breadcrumb of the collapsed header carries its own fill in both
bootswatch themes, and its ink is the weakest contrast on the page */
html.hc .breadcrumb {
background-color: var(--hc-canvas);
border: 1px solid var(--hc-border);
}
html.hc :is(.breadcrumb, .breadcrumb-item, .breadcrumb-item a, .quarto-btn-toggle) {
color: var(--hc-fg);
}
html.hc .breadcrumb-item a { color: var(--hc-accent); }
html.hc :is(hr, .quarto-title-block .quarto-title-banner, header#title-block-header) {
border-color: var(--hc-border);
}
html.hc hr { background-color: var(--hc-border); opacity: 1; }
html.hc blockquote {
border-left: 4px solid var(--hc-border);
color: var(--hc-fg);
}
html.hc :is(table, th, td) { border-color: var(--hc-border-soft); }
html.hc thead { border-bottom: 2px solid var(--hc-border); }
/* ------------------------------------------------------------- code ----- */
/* GitHub's high-contrast themes give a block an outline instead of a fill. */
html.hc :is(pre, div.sourceCode, pre.sourceCode) {
background-color: var(--hc-inset);
border: 1px solid var(--hc-border);
color: var(--hc-fg);
}
html.hc :not(pre) > code {
background-color: var(--hc-inset);
border: 1px solid var(--hc-border-soft);
border-radius: 3px;
color: var(--hc-fg);
padding: 0 0.2em;
}
html.hc code { color: var(--hc-fg); }
/* the syntax palette of the same two themes, mapped onto pandoc's classes */
html.hc code span:is(.co, .cv, .do, .an, .in) { color: var(--hc-subtle); font-style: italic; }
html.hc code span:is(.kw, .cf) { color: var(--hc-danger); }
html.hc code span:is(.st, .ch, .sc, .ss, .vs){ color: #032563; }
html.hc code span:is(.dv, .bn, .fl, .cn) { color: #023b95; }
html.hc code span:is(.fu, .ex) { color: #512598; }
html.hc code span:is(.va, .at) { color: var(--hc-severe); }
html.hc code span:is(.dt, .bu) { color: var(--hc-success); }
html.hc code span:is(.im, .pp) { color: var(--hc-severe); }
html.hc code span:is(.er, .wa, .al) { color: var(--hc-danger); font-weight: 600; }
html.hc code span:is(.op, .ot) { color: var(--hc-fg); }
html.hc body.quarto-dark code span:is(.st, .ch, .sc, .ss, .vs) { color: #addcff; }
html.hc body.quarto-dark code span:is(.dv, .bn, .fl, .cn) { color: #91cbff; }
html.hc body.quarto-dark code span:is(.fu, .ex) { color: #dbb7ff; }
html.hc body.quarto-dark code span:is(.co, .cv, .do, .an, .in) { color: #bdc4cc; }
/* ------------------------------------------- the notes environments ----- */
/* out goes the tint; the outline carries the box, at full accent strength */
html.hc :is(.exo, .further, .quiz, .gls-inline, .gls-float, .calc-note,
.exo-sol, .exo-hint, .quiz-opt) {
background: var(--hc-canvas);
}
html.hc .exo { border-color: var(--calc-notecolor); }
html.hc :is(.exo-sol, .exo-hint) { border-color: var(--calc-notecolor); }
html.hc .exo-head strong,
html.hc .exo-hint > summary { color: var(--calc-notecolor); }
html.hc .further { border-color: var(--calc-furthercolor); }
html.hc .gls-float { border-color: var(--calc-notecolor); box-shadow: 0 4px 14px var(--calc-shadow); }
html.hc :is(.gls-inline, .calc-note) { border-left-width: 4px; }
html.hc .gls-sym { text-decoration-color: var(--calc-notecolor); }
html.hc .quiz { --quiz-ok: var(--hc-success); --quiz-bad: var(--hc-danger); --quiz-ink: var(--hc-fg); }
html.hc :is(.quiz-opt.quiz-ok, .quiz-opt.quiz-bad) { background: var(--hc-canvas); }
html.hc .quiz-opt.quiz-ok { outline: 2px solid var(--hc-success); }
html.hc .quiz-opt.quiz-bad { outline: 2px solid var(--hc-danger); }
/* Quarto's own callouts, so a page does not mix outlined boxes with filled
ones; the callout keeps its colour, in its left bar and its title */
html.hc .callout {
background-color: var(--hc-canvas) !important;
border: 1px solid var(--hc-border);
}
html.hc .callout > .callout-header {
background-color: var(--hc-canvas) !important;
border-bottom: 1px solid var(--hc-border-soft);
}
html.hc :is(.callout-body, .callout-title-container, .callout-body-container p) {
color: var(--hc-fg);
}
html.hc .callout.callout-style-default > div.callout-header { font-weight: 600; }
/* Quarto's search box: its widget is not themed by the bootswatch pair, so it
stays white on a dark page unless it is told otherwise (see theme.css) */
html.hc :is(.aa-Form, .aa-InputWrapper, .aa-Panel, .aa-Item) {
background-color: var(--hc-canvas);
color: var(--hc-fg);
border-color: var(--hc-border);
}
html.hc :is(.aa-Autocomplete, .aa-DetachedFormContainer)
.aa-Form .aa-InputWrapper .aa-Input,
html.hc :is(.aa-Autocomplete, .aa-DetachedFormContainer)
.aa-Form .aa-InputWrapperSuffix .aa-ClearButton,
html.hc :is(.aa-Autocomplete, .aa-DetachedFormContainer)
.aa-Form .aa-InputWrapperPrefix :is(.aa-Label, .aa-LoadingIndicator) svg {
color: var(--hc-fg);
}
html.hc :is(.aa-Autocomplete, .aa-DetachedFormContainer)
.aa-Form .aa-InputWrapper .aa-Input::placeholder {
color: var(--hc-fg);
opacity: 0.75;
}
/* the results panel: Quarto colours the cards through an id, so this does too */
html.hc :is(.aa-DetachedOverlay, #quarto-search-results) li.aa-Item .search-item,
html.hc :is(.aa-DetachedOverlay, #quarto-search-results) li.aa-Item .search-item
:is(.search-result-title-container, .search-result-text-container,
.search-result-section, .search-result-text, .search-result-more) {
background-color: var(--hc-canvas);
color: var(--hc-fg);
}
html.hc :is(.aa-DetachedOverlay, #quarto-search-results) li.aa-Item[aria-selected="true"] .search-item,
html.hc :is(.aa-DetachedOverlay, #quarto-search-results) li.aa-Item[aria-selected="true"] .search-item
:is(.search-result-title-container, .search-result-text-container,
.search-result-section, .search-result-text, .search-result-more) {
background-color: var(--hc-accent);
color: var(--hc-canvas);
}
/* a hit is marked by weight and a rule, not by a block of colour */
html.hc :is(.aa-DetachedOverlay, #quarto-search-results) li.aa-Item .search-item
:is(mark.search-match, .search-match.mark) {
background-color: transparent;
color: inherit;
font-weight: 700;
text-decoration: underline;
}
/* the figure buttons of the animated schemes */
html.hc :is(.ns-btn, .nc-btn, .nd-replay) {
background: var(--hc-canvas);
color: var(--hc-fg);
border-color: var(--hc-border);
}
html.hc :is(.notes-spiral, .notes-cantor) :is(.ns-btn, .nc-btn)[aria-pressed="true"] {
background: var(--hc-canvas);
border-color: var(--hc-accent);
color: var(--hc-accent);
font-weight: 600;
}
/* the last tinted fills: a calc box and a note keep their outline instead */
html.hc :is(.calc-box, .calc-note, .calc-note[open]) { background: transparent; }
+106
View File
@@ -0,0 +1,106 @@
/* narrow.css — the book on a phone.
Nothing in the flow may be wider than the screen: a wide formula, table or
figure scrolls inside its own box instead of pushing the whole page
sideways (which leaves the text cut off at the left edge).
Loaded with calc-notes.css, so every page of every book gets it. */
/* --- display maths ------------------------------------------------------
The boxes of this extension (.calc, .exo, .further) already scroll their
own maths; this covers every other display formula on the page. */
:is(main, .quarto-title-block) :is(mjx-container[display="true"], .math.display) {
max-width: 100%;
overflow-x: auto;
overflow-y: hidden; /* Firefox computes phantom vertical overflow */
padding-bottom: 0.35em; /* keep descenders clear of a scrollbar */
/* a centred formula that overflows would hide its left side out of reach,
so centre it only while it fits */
justify-content: safe center;
}
/* --- everything else that can be wider than a phone ---------------------- */
main :is(pre, .sourceCode) { max-width: 100%; overflow-x: auto; }
main :is(img, svg) { max-width: 100%; height: auto; }
main table:not(.ltx-table) { display: block; max-width: 100%; overflow-x: auto; }
/* the animated figures of lesson-style chapters */
.notes-cantor, .notes-spiral, .notes-dominos { max-width: 100%; overflow-x: auto; }
/* the glossary popup: never wider than the screen */
.gls-float { max-width: min(92vw, 26rem); }
/* --- phone-sized screens ------------------------------------------------- */
@media (max-width: 575.98px) {
/* the equation number of a labelled calc block goes under the line, so the
formula keeps the full width */
.calc { grid-template-columns: max-content 1fr; }
/* figure captions and the fold summaries read better tight */
.exo, .further { padding-left: 0.6rem; padding-right: 0.6rem; }
/* A bare url in prose, or a long identifier in a code span, is one word to
the line breaker and paints past its block on a narrow screen — no
element is oversized, so only the text itself overflows. */
#quarto-document-content :is(a, code) { overflow-wrap: break-word; }
/* Quarto lets inline code wrap only inside a <p> (white-space: pre-wrap);
in a list item or a table it keeps one line, and a formula such as
"{PersN} → {PersN, Name, Position, Room, …}" pushed a page to 947px. */
#quarto-document-content :not(pre) > code:not(.sourceCode) { white-space: pre-wrap; }
/* A long compound in running text — "Unternehmensarchitekturmanagement" in
a list item is 348px — has no break opportunity. The page's lang picks
the hyphenation dictionary; overflow-wrap is the fallback without one. */
#quarto-document-content { hyphens: auto; overflow-wrap: break-word; }
/* An inline formula MathJax cannot break (one long fraction or product)
is wider than a phone: 413px in ModernPhysics' first exercise. It scrolls
inside its own box instead of pushing the page; the padding keeps tall
glyphs clear of the box's edge. */
/* A Bootstrap grid (::: {.grid} with .g-col-* items) has 12 columns and 11
gaps of 1.5rem: 264px of gaps alone, more than a callout on a phone
(248px in SoftwareEngineering's git appendix), so the columns collapse to
0 and a full-width item overflows. A smaller gap keeps the layout;
min-width: 0 lets an item's text wrap instead of widening its track. */
.grid { --bs-gap: 0.75rem; }
.grid > [class*="g-col"] { min-width: 0; }
#quarto-document-content mjx-container:not([display="true"]) {
display: inline-block;
max-width: 100%;
overflow-x: auto;
overflow-y: hidden;
vertical-align: middle;
padding-block: 0.15em;
}
/* Quarto's own previous/next footer: the chapter titles are laid out in a
row that will not shrink, so a long title pushes the page sideways. */
.page-navigation { flex-wrap: wrap; row-gap: 0.75em; }
.nav-page, .nav-page .nav-page-text { min-width: 0; }
.nav-page .chapter-title { overflow-wrap: break-word; }
/* A long compound in a heading — "Implementierungsentscheidungen" is 366px
at h3 size — is wider than a 320px screen. The page's lang picks the
hyphenation dictionary; overflow-wrap is the fallback without one. */
#quarto-document-content :is(h1, h2, h3, h4, h5, h6),
.quarto-title .title {
hyphens: auto;
overflow-wrap: break-word;
}
/* The bar at the top of a phone page: menu button, the chapter's title,
search. The title is a flex item that will not shrink, so a long one
("3 Komplexitätsanalyse" in darkly's wider font) pushes the search button
off the screen. It now shrinks and ends in an ellipsis. */
.quarto-secondary-nav nav.quarto-page-breadcrumbs { min-width: 0; }
.quarto-secondary-nav nav.quarto-page-breadcrumbs .breadcrumb {
flex-wrap: nowrap;
min-width: 0;
}
.quarto-secondary-nav nav.quarto-page-breadcrumbs .breadcrumb-item {
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
}
+4 -6
View File
@@ -160,12 +160,10 @@
/* ---- dark theme ----------------------------------------------------- */
@media (prefers-color-scheme: dark) {
.quiz {
--quiz-ok: #4cb08a;
--quiz-bad: #e2798f;
--quiz-ink: #8b98a8;
}
body.quarto-dark .quiz {
--quiz-ok: #4cb08a;
--quiz-bad: #e2798f;
--quiz-ink: #8b98a8;
}
/* ---- print ----------------------------------------------------------
+240
View File
@@ -0,0 +1,240 @@
/* theme.css — one palette for every part of the notes extension, in light
mode, in night mode and in high contrast.
Night mode keys off Quarto's own `body.quarto-dark`, which the light/dark
toggle sets — never off `prefers-color-scheme`, so a book configured
light-only stays light for a reader whose system is dark.
A book opts in with, in _quarto.yml:
format:
html:
theme:
light: [cosmo]
dark: [darkly]
High contrast is a separate sheet, high-contrast.css, after GitHub's two
high-contrast VS Code themes. It keys off `hc` on <html>, which
calc-notes.lua sets from `high-contrast: true` in the metadata and for a
reader whose system asks for `prefers-contrast: more`.
Loaded with calc-notes.css, so every page of every book has these tokens. */
:root {
--calc-ink: #1a1a1a; /* figure text, strong strokes */
--calc-muted: #57606a; /* captions, readouts, button text */
--calc-line: #444444; /* axes and rules */
--calc-grid: #cccccc; /* lattice dots, faint grid */
--calc-accent-a: #1F6FB4; /* lineA of the tikz preamble */
--calc-accent-b: #D1541F; /* lineB */
--calc-accent-c: #2E8B57; /* lineC */
--calc-danger: #B91C1C; /* an error state, e.g. a failed code run */
--calc-surface: var(--bs-body-bg, #ffffff);
--calc-faint: #e7e9ec; /* hairlines between rows */
--calc-shadow: rgba(0, 0, 0, 0.15); /* floats above the page */
--calc-domface: #DCE7F2; /* the domino figure's front face */
--calc-domtop: #B8CFE4; /* its top face */
/* --calc-notecolor-src and --calc-furthercolor-src come from the document
metadata (calc-notes.lua / further.lua) and are the book's own colours;
--calc-notecolor and --calc-furthercolor are what everything draws with,
and equal the source here. The dark block lifts them. */
}
body.quarto-dark {
--calc-ink: #e6e9ed;
--calc-muted: #9aa4b2;
--calc-line: #b6bec7;
--calc-grid: #4b535d;
--calc-accent-a: #6fb0ea;
--calc-accent-b: #f0956a;
--calc-accent-c: #64c49a;
--calc-danger: #f08a8a;
--calc-faint: #3a4049;
--calc-shadow: rgba(0, 0, 0, 0.55);
--calc-domface: #2b3b4d;
--calc-domtop: #365070;
/* The book's own accent is kept, not replaced: its print value is too dim
on a dark ground, so it is lifted to a light tone at the same hue rather
than swapped for a generic amber. A book that wants a specific night
value sets `notecolor-dark:` / `furthercolor-dark:` in its metadata.
On a browser without relative colour syntax the lift is dropped and the
book's own colour is used unchanged. */
--calc-notecolor:
var(--calc-notecolor-dark,
oklch(from var(--calc-notecolor-src, #B45309) 0.78 c h));
--calc-furthercolor:
var(--calc-furthercolor-dark,
oklch(from var(--calc-furthercolor-src, #6B3FA0) 0.80 c h));
}
/* --- generated line art -------------------------------------------------
The tikz figures are black-and-colour line drawings on transparent white.
Inverting them keeps the drawing readable and, with the hue rotation,
keeps blue blue and orange orange. Photographs live under img/ and are
left alone; an svg that is a photograph, or that carries its own dark
palette, opts out with class="no-invert". */
body.quarto-dark main img[src$=".svg"]:not(.no-invert) {
filter: invert(1) hue-rotate(180deg);
}
/* --- captions -----------------------------------------------------------
Quarto's caption grey reads 4.4:1 on cosmo's white, under WCAG AA. The
muted token reads about 6.4:1 in light and in dark, and high contrast
makes it the foreground. The list ends with Quarto's most specific caption
selector so that :is() gives every entry its weight. */
:is(.panel-caption, .figure-caption, .subfigure-caption, .table-caption,
figcaption, caption, .margin-caption, .column-margin figcaption,
.quarto-layout-cell[data-ref-parent] caption) {
color: var(--calc-muted, #57606a);
}
/* --- breadcrumbs --------------------------------------------------------
Quarto greys the current page (#6c757d) and Bootstrap the separators; on
darkly's breadcrumb band that reads 2.1:1. The ink token passes in every
mode. `body` outweighs Quarto's own selectors; pseudo-elements cannot go
inside :is(), hence the separate rule. */
body :is(.quarto-title-breadcrumbs .breadcrumb li:last-of-type a,
.breadcrumb-item.active) {
color: var(--calc-ink, #1a1a1a);
}
body .breadcrumb-item + .breadcrumb-item::before,
body .quarto-secondary-nav nav.quarto-page-breadcrumbs .breadcrumb-item::before,
body .quarto-secondary-nav nav.quarto-page-breadcrumbs a {
color: var(--calc-ink, #1a1a1a);
}
/* --- Quarto's other greys -----------------------------------------------
Quarto hard-codes #6c757d for every fold label (details > summary) and for
the previous/next page links, and a mid grey for section numbers: 3.4:1 on
darkly, 4.4:1 on cosmo. The muted token reads about 6.4:1 in both, and
high contrast makes it the foreground. An exercise hint keeps its accent
(.exo-hint > summary outweighs these), and the active entry of the
contents still inherits its colour. */
body details > summary,
body .nav-page a,
body .header-section-number {
color: var(--calc-muted, #57606a);
}
/* Quoted text: Quarto's .blockquote grey is 4.4:1 on cosmo, and it names the
paragraphs, so they are named here too. */
body :is(blockquote, .blockquote, blockquote p, .blockquote p) {
color: var(--calc-muted, #57606a);
}
/* Inline code: Bootstrap's pill is #f8f9fa in both themes, so darkly's light
code text sat on near-white (1.05:1). The pill is now a faint tint of the
page, which keeps each theme's code colour readable, and inherited muted
text (code in a caption) too. */
body :not(pre) > code:not(.sourceCode) {
background-color: color-mix(in srgb, var(--calc-faint, #e7e9ec) 60%,
var(--calc-surface, #ffffff));
}
/* A code block inside a tinted box (exercise, hint, solution, "to go
further", quiz): Quarto's block ground is 65% opaque, so the tint shows
through and a11y-light's keyword red drops to 4.4:1. Here the ground is
opaque, and the same light grey as on the page. */
body :is(.exo, .exo-hint, .exo-sol, .further, .quiz) div.sourceCode {
background-color: color-mix(in srgb, var(--calc-faint, #e7e9ec) 45%,
var(--calc-surface, #ffffff));
}
/* A static (not executed) block also gives its <code> the translucent
ground, so the two layers stack and darken it. The block carries the
ground; the code inside is transparent, as in an executed cell. */
body div.sourceCode > pre > code.sourceCode { background-color: transparent; }
/* --- Jupyter output: ANSI colours ---------------------------------------
A traceback comes out in the notebook's terminal palette, made for a dark
terminal: yellow is 1.9:1 and cyan 2.0:1 on the page. Each colour name
takes the matching token with a fifth of ink, which keeps the hue and passes
in all four modes. IPython's 256-colour spans carry inline styles and no
name, so they take the text colour. */
body :is(.ansi-black-fg, .ansi-bright-black-fg) { color: var(--calc-ink); }
body :is(.ansi-white-fg, .ansi-bright-white-fg) { color: var(--calc-muted); }
body :is(.ansi-red-fg, .ansi-bright-red-fg) {
color: color-mix(in srgb, var(--calc-danger) 85%, var(--calc-ink));
}
body :is(.ansi-green-fg, .ansi-bright-green-fg) {
color: color-mix(in srgb, var(--calc-accent-c) 75%, var(--calc-ink));
}
body :is(.ansi-yellow-fg, .ansi-bright-yellow-fg) {
color: color-mix(in srgb, var(--calc-accent-b) 75%, var(--calc-ink));
}
body :is(.ansi-blue-fg, .ansi-bright-blue-fg) {
color: color-mix(in srgb, var(--calc-accent-a) 80%, var(--calc-ink));
}
body :is(.ansi-magenta-fg, .ansi-bright-magenta-fg) {
color: color-mix(in srgb, var(--calc-furthercolor) 85%, var(--calc-ink));
}
body :is(.ansi-cyan-fg, .ansi-bright-cyan-fg) {
color: color-mix(in srgb,
color-mix(in srgb, var(--calc-accent-a) 50%, var(--calc-accent-c)) 75%,
var(--calc-ink));
}
body .ansi-escaped-output span[style*="color"] { color: inherit !important; }
/* --- higher contrast ---------------------------------------------------
The high-contrast pair lives in high-contrast.css, which is loaded with
this file and keys off `hc` on <html>. */
/* --- Quarto's search box -------------------------------------------------
The search widget keeps its own white surface whatever the bootswatch
theme says, so on a dark page it is a white slab with dark text. It is
given the page's own surface here rather than in each book. */
body.quarto-dark :is(.aa-Form, .aa-InputWrapper, .aa-Panel, .aa-Item,
.aa-DetachedContainer, .aa-DetachedFormContainer) {
background-color: var(--calc-surface, #222);
color: var(--calc-ink, #e6e9ed);
border-color: var(--calc-faint, #3a4049);
}
/* The ink inside the form is a separate problem from its surface: Quarto's
dark bundle sets the input, its placeholder, the clear button and the
magnifier to rgb(45,45,45) through a four-class selector, so a short one
loses the cascade and the typed text stays unreadable. The shape below
matches Quarto's own, which is the only way to win without !important. */
body.quarto-dark :is(.aa-Autocomplete, .aa-DetachedFormContainer)
.aa-Form .aa-InputWrapper .aa-Input,
body.quarto-dark :is(.aa-Autocomplete, .aa-DetachedFormContainer)
.aa-Form .aa-InputWrapperSuffix .aa-ClearButton,
body.quarto-dark :is(.aa-Autocomplete, .aa-DetachedFormContainer)
.aa-Form .aa-InputWrapperPrefix :is(.aa-Label, .aa-LoadingIndicator) svg {
color: var(--calc-ink, #e6e9ed);
}
body.quarto-dark :is(.aa-Autocomplete, .aa-DetachedFormContainer)
.aa-Form .aa-InputWrapper .aa-Input::placeholder {
color: var(--calc-muted, #9aa4b2);
}
/* --- search: the selected result ----------------------------------------
Quarto marks it with cosmo's primary (#2780e3) under white text, 3.97:1,
and its matched words with a lighter blue, worse still. The same hue at a
lower lightness passes. Night mode (darkly's #375a7f, 7.2:1) and high
contrast (high-contrast.css) keep their own. */
html:not(.hc) body:not(.quarto-dark) :is(.aa-DetachedOverlay, #quarto-search-results)
li.aa-Item[aria-selected="true"] :is(.search-item, .search-item *:not(mark, .mark)) {
background-color: oklch(from var(--bs-primary, #2780e3) 0.42 c h);
}
html:not(.hc) body:not(.quarto-dark) :is(.aa-DetachedOverlay, #quarto-search-results)
li.aa-Item[aria-selected="true"] .search-item :is(mark.search-match, .search-match.mark) {
background-color: oklch(from var(--bs-primary, #2780e3) 0.52 c h);
}
/* --- the high-contrast switch -------------------------------------------
Built by calc-notes.js next to Quarto's light/dark toggle, and styled to
sit with it rather than stand out. */
.notes-contrast-toggle {
background: none;
border: 0;
color: inherit;
line-height: 1;
cursor: pointer;
opacity: 0.85;
}
.notes-contrast-toggle:hover { opacity: 1; }
.notes-contrast-toggle[aria-pressed="true"] {
opacity: 1;
color: var(--calc-accent-a, #1F6FB4);
}
.notes-contrast-toggle:focus-visible {
outline: 2px solid var(--calc-accent-a, #1F6FB4);
outline-offset: 2px;
}