Skip to content

Claude's answers, rendered: Markdown, math, charts and diagrams drawn in the Claude Code terminal. Independent project, not affiliated with Anthropic.

TypeScript claude-code-mod

Add marketing renders: samples, Claude Code frame and build script

razorback1651e7c2bb8fe1
diff --git a/marketing/.gitignore b/marketing/.gitignore
new file mode 100644
index 0000000..3d6e79a
--- /dev/null
+++ b/marketing/.gitignore
@@ -0,0 +1,2 @@
+.work/
+out/raw/
diff --git a/marketing/build.sh b/marketing/build.sh
new file mode 100755
index 0000000..da3c865
--- /dev/null
+++ b/marketing/build.sh
@@ -0,0 +1,43 @@
+#!/bin/sh
+# Renders the sample answers with md-preview's own template, then frames them.
+# Usage: marketing/build.sh (needs typst 0.15)
+set -eu
+here=$(cd "$(dirname "$0")" && pwd)
+root=$(dirname "$here")
+out="$here/out"; work="$here/.work"
+mkdir -p "$out/raw" "$work/pkg-cache"
+export TYPST_PACKAGE_CACHE_PATH="$work/pkg-cache"
+width=${WIDTH:-560}; ppi=${PPI:-288}
+for md in "$here"/samples/*.md; do
+ name=$(basename "$md" .md)
+ python3 -c 'import json,sys; print(json.dumps({"base": sys.argv[2], "segments": [open(sys.argv[1]).read()]}))' "$md" "$here/samples" > "$work/$name.json"
+ for mode in dark light; do
+ typst compile --root / --package-path "$root/render/packages" --format png --diagnostic-format short --ppi "$ppi" \
+ --input theme=$mode --input width=$width --input doc="$work/$name.json" \
+ --input theme-dir="$root/render/themes/vscode-modern" --input term-font="${TERM_FONT:-MesloLGS NF}" \
+ --input top=6 --input row=0 --input code=0.9 \
+ "$root/render/md.typ" "$out/raw/$name-$mode-{0p}.png"
+ done
+done
+ls "$out/raw"
+
+# Frames: headline, subline and the prompt for each sample.
+frame() { # name title sub ask bullet-offset-pt
+ for mode in dark light; do
+ typst compile --root / --ppi 216 --input img="$out/raw/$1-$mode-1.png" --input mode=$mode --input bullet="$5" \
+ --input title="$2" --input sub="$3" --input ask="$4" "$here/frame.typ" "$out/$1-$mode.png" 2>/dev/null
+ done
+}
+frame 1-overview "Real Markdown, right in the terminal" "Tables, task lists, quotes and footnotes, drawn like VS Code's preview." "what is left for the v0.2.0 release?" 15
+frame 2-code "Syntax colours in your own font" "Code blocks use the terminal's font and size, with VS Code colours." "how should we pick light or dark mode?" 9
+frame 3-math "LaTeX math that reads like a paper" "Inline and display math, set by Typst." "why is 0.4 the cut-off?" 9
+frame 4-typst "Live diagrams and plots" "Claude writes Typst; md-preview draws it, offline." "show me how auto mode decides" 9
+ls "$out"
+
+# Hero: the same answer in a dark and a light terminal.
+typst compile --root / --ppi 180 --input layout=hero --input mode=dark --input bullet=7 \
+ --input img-dark="$out/raw/4-typst-dark-1.png" --input img-light="$out/raw/4-typst-light-1.png" \
+ --input title="Claude's answers, rendered" \
+ --input sub="Markdown, math and live Typst diagrams, in the colours of your terminal." \
+ --input ask="show me how auto mode decides" "$here/frame.typ" "$out/0-hero.png" 2>/dev/null
+ls "$out"
diff --git a/marketing/frame.typ b/marketing/frame.typ
new file mode 100644
index 0000000..2648240
--- /dev/null
+++ b/marketing/frame.typ
@@ -0,0 +1,95 @@
+// Marketing frame: md-preview renders in terminal windows, with a headline.
+// One window: --input img=<abs png> --input mode=dark|light --input ask=..
+// Hero (two): --input layout=hero --input img-dark=.. --input img-light=.. --input ask=..
+// Both: --input title=.. --input sub=.. (typst compile --root / frame.typ out.png)
+#let inp = sys.inputs
+#let hero = inp.at("layout", default: "one") == "hero"
+#let page-dark = inp.at("mode", default: "dark") == "dark"
+#let img-w = float(inp.at("img-w", default: if hero { "430" } else { "560" })) * 1pt
+#let mono = ("MesloLGS NF", "Menlo")
+#let sans = ("SF Pro Display", "Helvetica Neue", "Inter")
+
+// The Claude Code mascot, drawn from its pixels (1 unit = 1 px of a 2x screenshot).
+#let mascot(u, body, eye) = box(width: 75 * u, height: 48 * u, {
+ let r(x, y, w, h, c) = place(dx: (x + 9) * u, dy: y * u, rect(width: w * u, height: h * u, fill: c))
+ r(0, 0, 57, 36, body)
+ r(-9, 20, 75, 8, body)
+ r(9, 8, 4, 12, eye)
+ r(43, 8, 4, 12, eye)
+ for x in (0, 9, 43, 52) { r(x, 36, 4, 12, body) }
+})
+
+// A terminal window with Claude Code in it: the header, the prompt, the
+// answer (the md-preview picture beside the bullet), the input box and the
+// mode line. Colours are from a screenshot of Claude Code 2.1.301.
+#let window(img, dark, ask) = {
+ let c = if dark { (
+ bg: rgb("#283237"), fg: rgb("#ffffff"), dim: rgb("#a7a5a5"), hint: rgb("#9a9da1"),
+ bar: rgb("#21211f"), title: rgb("#b6b6b4"), edge: rgb("#3c4448"), sep: rgb("#7a7b7c"),
+ ask-bg: rgb("#343e43"), green: rgb("#52c96a"), mode: rgb("#ffd301"), eye: rgb("#050302"),
+ ) } else { (
+ bg: rgb("#ffffff"), fg: rgb("#1f1f1f"), dim: rgb("#6e6e6e"), hint: rgb("#8a8d91"),
+ bar: rgb("#ececec"), title: rgb("#4d4d4d"), edge: rgb("#d4d4d4"), sep: rgb("#b5b5b5"),
+ ask-bg: rgb("#f0f0f0"), green: rgb("#2f9e4b"), mode: rgb("#a07400"), eye: rgb("#050302"),
+ ) }
+ let light(col) = circle(radius: 4.2pt, fill: col)
+ let rule = line(length: 100%, stroke: 0.5pt + c.sep)
+ block(width: img-w + 40pt, radius: 10pt, clip: true, stroke: 0.6pt + c.edge, fill: c.bg)[
+ #block(width: 100%, fill: c.bar, inset: (x: 10pt, y: 8pt), below: 0pt)[
+ #grid(columns: (auto, 1fr, auto), align: horizon, column-gutter: 12pt,
+ stack(dir: ltr, spacing: 6pt, light(rgb("#ff5f57")), light(rgb("#febc2e")), light(rgb("#28c840"))),
+ text(font: sans, size: 9pt, weight: "semibold", fill: c.title)[Claude Code],
+ text(font: sans, size: 8pt, fill: c.dim)[⌥⌘1])
+ ]
+ #block(inset: (x: 8pt, top: 12pt, bottom: 8pt), below: 0pt)[
+ #set text(font: mono, size: 8.5pt, fill: c.fg)
+ #set par(leading: 0.45em)
+ #grid(columns: (auto, auto), column-gutter: 9pt, align: horizon,
+ mascot(0.42pt, rgb("#d77757"), c.eye),
+ [*Claude Code* #text(fill: c.dim)[v2.1.301] \
+ #text(fill: c.dim)[Opus 5.5 with high effort · Claude Max] \
+ #text(fill: c.dim)[\~/projects/md-preview ·] #text(fill: c.green)[/rc]])
+ #v(14pt)
+ #block(width: 100%, fill: c.ask-bg, inset: (x: 4pt, y: 4pt), below: 0pt)[❯ #ask]
+ #v(12pt)
+ #grid(columns: (12pt, auto),
+ move(dx: 3pt, dy: float(inp.at("bullet", default: "9")) * 1pt, text(size: 8pt)[●]),
+ image(img, width: img-w))
+ #v(10pt)
+ #text(fill: c.dim)[✻ Brewed for 6s]
+ #v(26pt)
+ #align(right, text(fill: c.dim)[● high · /effort])
+ #v(-4pt)
+ #rule
+ #v(-2pt)
+ ❯ #box(fill: c.fg, width: 5.2pt, height: 9pt, baseline: 1.5pt)
+ #v(-2pt)
+ #rule
+ #v(-2pt)
+ #let tri = box(polygon(fill: c.mode, (0pt, 0pt), (4.2pt, 2.6pt), (0pt, 5.2pt)), baseline: -0.6pt)
+ #text(fill: c.mode)[#tri#h(0.8pt)#tri auto mode on] #text(fill: c.dim)[(shift+tab to cycle)]
+ ]
+ ]
+}
+
+#set page(width: if hero { 2 * img-w + 80pt + 2 * 56pt + 24pt } else { img-w + 40pt + 2 * 56pt }, height: auto,
+ margin: (x: 56pt, top: 52pt, bottom: 60pt),
+ fill: gradient.linear(angle: 35deg,
+ ..if page-dark { (rgb("#14161f"), rgb("#2a1f3d"), rgb("#3b2416")) } else { (rgb("#fdf6ee"), rgb("#efe8fb"), rgb("#e6f1fb")) }))
+#set text(font: sans, fill: if page-dark { white } else { rgb("#1d1d1f") })
+
+#align(center)[
+ #text(size: 11pt, weight: "semibold", tracking: 1.5pt, fill: rgb("#d97757"))[MD-PREVIEW FOR CLAUDE CODE]
+ #v(4pt)
+ #text(size: if hero { 32pt } else { 27pt }, weight: "bold")[#inp.at("title", default: "")]
+ #v(-6pt)
+ #text(size: 13pt, fill: if page-dark { rgb("#b8b8c8") } else { rgb("#5d5d6b") })[#inp.at("sub", default: "")]
+]
+#v(14pt)
+#let ask = inp.at("ask", default: "")
+#if hero {
+ grid(columns: 2, column-gutter: 24pt, align: top,
+ window(inp.img-dark, true, ask), window(inp.img-light, false, ask))
+} else {
+ window(inp.img, page-dark, ask)
+}
diff --git a/marketing/out/0-hero.png b/marketing/out/0-hero.png
new file mode 100644
index 0000000..29dae57
Binary files /dev/null and b/marketing/out/0-hero.png differ
diff --git a/marketing/out/1-overview-dark.png b/marketing/out/1-overview-dark.png
new file mode 100644
index 0000000..bbb9584
Binary files /dev/null and b/marketing/out/1-overview-dark.png differ
diff --git a/marketing/out/1-overview-light.png b/marketing/out/1-overview-light.png
new file mode 100644
index 0000000..3ea76c9
Binary files /dev/null and b/marketing/out/1-overview-light.png differ
diff --git a/marketing/out/2-code-dark.png b/marketing/out/2-code-dark.png
new file mode 100644
index 0000000..7114e34
Binary files /dev/null and b/marketing/out/2-code-dark.png differ
diff --git a/marketing/out/2-code-light.png b/marketing/out/2-code-light.png
new file mode 100644
index 0000000..956c281
Binary files /dev/null and b/marketing/out/2-code-light.png differ
diff --git a/marketing/out/3-math-dark.png b/marketing/out/3-math-dark.png
new file mode 100644
index 0000000..b5d9b05
Binary files /dev/null and b/marketing/out/3-math-dark.png differ
diff --git a/marketing/out/3-math-light.png b/marketing/out/3-math-light.png
new file mode 100644
index 0000000..283560f
Binary files /dev/null and b/marketing/out/3-math-light.png differ
diff --git a/marketing/out/4-typst-dark.png b/marketing/out/4-typst-dark.png
new file mode 100644
index 0000000..0c2c6d0
Binary files /dev/null and b/marketing/out/4-typst-dark.png differ
diff --git a/marketing/out/4-typst-light.png b/marketing/out/4-typst-light.png
new file mode 100644
index 0000000..f1e3625
Binary files /dev/null and b/marketing/out/4-typst-light.png differ
diff --git a/marketing/samples/1-overview.md b/marketing/samples/1-overview.md
new file mode 100644
index 0000000..18b6846
--- /dev/null
+++ b/marketing/samples/1-overview.md
@@ -0,0 +1,18 @@
+## Release checklist for v0.2.0
+
+All **four** terminals now pick the right colours. Here is what changed and what is left:
+
+| Terminal | Mode source | Font source | Status |
+|---|---|---|---|
+| iTerm2 | profile background | profile font | ✅ done |
+| Ghostty | config and theme files | `font-family` | ✅ done |
+| kitty | `kitty.conf` and includes | `font_family` | ✅ done |
+| cmux | adaptive theme | Ghostty config | ✅ done |
+
+- [x] Read the terminal background before the OS appearance
+- [x] Send pictures as bytes over **ssh**
+- [ ] Test Rio on a real machine
+
+> **Note:** the saved answer stays plain Markdown, so `/copy` still gives you the source.[^1]
+
+[^1]: Only the drawing changes. Use `/copy` to copy an answer as Markdown.
diff --git a/marketing/samples/2-code.md b/marketing/samples/2-code.md
new file mode 100644
index 0000000..05729b5
--- /dev/null
+++ b/marketing/samples/2-code.md
@@ -0,0 +1,24 @@
+### Pick the mode from the terminal, not the OS
+
+The terminal knows its own background, so ask it first:
+
+```ts
+export function itermModeOf(p: Profile, look: Mode): Mode {
+ const key = p.separate
+ ? `Background Color (${cap(look)})`
+ : 'Background Color'
+ return modeOfLuminance(luminanceOf(p[key])) // > 0.4: light
+}
+```
+
+```python
+def luminance(r: float, g: float, b: float) -> float:
+ lin = lambda v: v / 12.92 if v <= 0.04045 else ((v + 0.055) / 1.055) ** 2.4
+ return 0.2126 * lin(r) + 0.7152 * lin(g) + 0.0722 * lin(b)
+```
+
+```diff
+- const os = await readOsMode($)
++ const term = await readItermMode($) ?? await readGhosttyMode($)
++ if (term) return term
+```
diff --git a/marketing/samples/3-math.md b/marketing/samples/3-math.md
new file mode 100644
index 0000000..3fe0bc9
--- /dev/null
+++ b/marketing/samples/3-math.md
@@ -0,0 +1,17 @@
+### Why 0.4 is the light/dark cut-off
+
+Relative luminance weights the linear sRGB channels:
+
+$$
+L = 0.2126\,R_{\text{lin}} + 0.7152\,G_{\text{lin}} + 0.0722\,B_{\text{lin}},
+\qquad
+C_{\text{lin}} =
+\begin{cases}
+\dfrac{C}{12.92} & C \le 0.04045 \\
+\left(\dfrac{C + 0.055}{1.055}\right)^{2.4} & \text{otherwise}
+\end{cases}
+$$
+
+The contrast of text on a background is $\dfrac{L_1 + 0.05}{L_2 + 0.05}$. At $L = 0.4$, black text has a contrast of $9.0$ and white text only $2.3$. So a background above $0.4$ reads as **light**.
+
+For Ghostty's default `#282c34`: $L \approx 0.025$, so the mode is **dark**.
diff --git a/marketing/samples/4-typst.md b/marketing/samples/4-typst.md
new file mode 100644
index 0000000..a6f8d82
--- /dev/null
+++ b/marketing/samples/4-typst.md
@@ -0,0 +1,39 @@
+### How `auto` finds the mode
+
+```typst
+#import "@preview/fletcher:0.5.8" as fletcher: diagram, node, edge
+#set text(fill: theme.fg, size: 10pt)
+#diagram(
+ node-stroke: theme.fg, edge-stroke: theme.fg, spacing: (14mm, 9mm),
+ node-corner-radius: 4pt,
+ node((0, 0), [Claude Code\ theme = auto], fill: theme.accent.transparentize(75%)),
+ edge("-|>"),
+ node((1, 0), [Terminal config\ iTerm2 · Ghostty · kitty · Rio · cmux], fill: theme.blue.transparentize(75%)),
+ edge("-|>", [none]),
+ node((2, 0), [COLORFGBG], fill: theme.purple.transparentize(75%)),
+ edge("-|>", [none]),
+ node((3, 0), [OS appearance], fill: theme.orange.transparentize(75%)),
+ edge((1, 0), (1, 1), "-|>", [found], label-side: left),
+ node((1, 1), [light / dark], fill: theme.green.transparentize(70%)),
+ edge((2, 0), (1, 1), "-|>"),
+ edge((3, 0), (1, 1), "-|>"),
+)
+```
+
+```typst
+#import "@preview/cetz:0.5.2"
+#import "@preview/cetz-plot:0.1.4": plot
+#set text(fill: theme.fg, size: 9pt)
+#cetz.canvas({
+ import cetz.draw: *
+ set-style(axes: (stroke: theme.fg, tick: (stroke: theme.fg)), legend: (fill: theme.bg, stroke: theme.border))
+ plot.plot(size: (11, 4.2), x-label: [sRGB channel value], y-label: [linear value],
+ legend: "inner-north-west", {
+ plot.add(domain: (0, 1), samples: 80,
+ x => if x <= 0.04045 { x / 12.92 } else { calc.pow((x + 0.055) / 1.055, 2.4) },
+ style: (stroke: 2pt + theme.blue), label: [sRGB decode])
+ plot.add(domain: (0, 1), x => x, style: (stroke: (paint: theme.muted, dash: "dashed")), label: [identity])
+ plot.add-hline(0.4, style: (stroke: 1pt + theme.orange), label: [light cut-off])
+ })
+})
+```