<notatio-terminal>
The behaviour that differs between the REPL and command-line modes. */ interface Engine { banner(): string; prompt(): string; run(input: string): { text: string; graphic?: Graphic; clear?: boolean; exit?: boolean }; groups(): Group[]; }
function replEngine(color: boolean): Engine { const repl = new Repl({ color }); return { banner: () => repl.banner(), prompt: () => repl.prompt(), run: (input) => repl.eval(input), groups: () => demosByCategory(), }; }
function cliEngine(color: boolean): Engine { const trim = (s: string) => s.replace(/\n+$/, ""); return { banner: () => dim( "notatio — command line. Type the args after the prompt (the $ notatio is implied).", color, ), prompt: () => ${dim("$", color)} notatio , run: (input) => { const argv = splitArgs(input); if (argv.length === 0) return { text: "" }; const r = runCommand(argv); return { text: r.code === 0 ? trim(r.stdout) : red(trim(r.stderr), color) }; }, groups: () => cliDemosByCategory(), }; }
function graphicSvg(g: Graphic): string { return g.kind === "plot" ? linePlotSvg(g.points) : renderGlyph(g.glyph, g.values); }
let stylesInjected = false; function ensureTerminalStyles(): void { if (stylesInjected || typeof document === "undefined") return; stylesInjected = true; const style = document.createElement("style"); style.textContent = TERMINAL_CSS; document.head.appendChild(style); }
/** <notatio-terminal> — an in-browser terminal. mode is repl (default) or cli. seed is a JSON array of lines to run on mount; examples (default on) shows the dropdown + Play/Clear toolbar.
Attributes
| Attribute | Type | Default | Notes |
|---|---|---|---|
mode | "repl" | "cli" | "repl" | repl for the interactive session, cli for the command-line transcript. |
seed | string | "" | A JSON array of input lines to run on load. |
examples | boolean | true | Show the example picker beside the terminal. |