This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
VitePress documentation site for MathFlow (@mathflowjs/mathflow), served at https://mathflow.js.org. The library itself lives in a separate repo; this repo only holds docs plus an interactive playground.
Uses pnpm (CI uses pnpm 10).
pnpm dev: local dev server (vitepress dev docs)pnpm build: production build todocs/.vitepress/distpnpm format: Prettier write overdocs/pnpm check: Prettier check overdocs/
There are no tests or linters beyond Prettier. pnpm build is the only real verification, since it fails on broken pages and dead internal links.
docs/is the VitePress source root. Each.mdfile is a page.docs/.vitepress/config.tsholds the nav and sidebar. Both are hand-maintained, so a new page has to be added there to show up. The version label (v2.0.0) in the nav is also hardcoded there.docs/.vitepress/theme/index.tsextends the default theme and registersPlaygroundas a global component.docs/playground/index.mdrenders it inside<ClientOnly>because it runs the library in the browser.- The playground is a single component,
theme/components/Playground.vue, built from twocomputeds that re-run on every edit:outputcreates a fresh context on each run, so no variables leak between runs. It then callsctx.solveonce per line, which gives each line its own result or error. Each line is prefixed with"\n".repeat(i)so error positions match the editor's line numbers.programproduces the whole-program Tokens, LaTeX, and HTML tabs.- The colour scheme comes from VitePress's
isDark, not"auto"."auto"follows the OS rather than the site toggle.
- MathFlow v2 behaviour the playground works around:
ctx.solveonly evaluates the first line of its input.- Multi-line expressions don't parse.
log(x, base)needs a base;log(100)returnsNaN.- Undefined variables silently evaluate to
0. fractionDigits: 0means no rounding.- Rounding happens at every step, not just on the result. At 3 decimals,
pibecomes3.142first, so2pigives6.284. - Implicit multiplication across a space silently drops the term after the space (
pi r^2givespi).abis read as one unknown variable, which counts as0, not asa * b. - Underscores in names (
total_sum) cause a LexicalError, even thoughdocs/guide/variables.mdlists them as valid. - Because of these, check that every playground example gives the exact expected answer before adding it.
- The renderer's CSS has to be injected separately; the playground does this once with
<component is="style">.
- The API pages (
docs/api/*.md) document the@mathflowjs/mathflowversion installed as a dependency. Check signatures againstnode_modules/@mathflowjs/mathflow/dist/index.d.tsbefore documenting or changing API usage.
- Prettier: tabs (width 4), double quotes, semicolons,
trailingComma: es5. - Code samples in the docs use
tsfences, orts:line-numbersin the examples. - Brand color
#4169e1is set inconfig.ts(theme-color) andtheme/assets/styles.css(--vp-c-brand-1).
.github/workflows/deploy.yml runs on pushes to main under docs/, and can also be run manually. It builds and publishes docs/.vitepress/dist with peaceiris/actions-gh-pages. The custom domain comes from docs/public/CNAME.