Skip to content

ButterIX v1 is out: versions, multiple languages, Ask AI, and a per-site MCP server, all built in. →

Math and diagrams

Write math in LaTeX (rendered by KaTeX at build time), and draw flowcharts, sequence diagrams, and state diagrams with Mermaid.

Math

Math is rendered to HTML by KaTeX at build time, so readers' browsers don't need to run any math typesetting scripts. Only pages that use math load the KaTeX stylesheet.

Inline math

Rate limiting uses a token bucket: $r$ tokens are refilled per minute and the bucket holds $b$, so bursts are capped at $b$ requests.

Rate limiting uses a token bucket: tokens are refilled per minute and the bucket holds , so bursts are capped at requests.

Block math

$$
t_{\text{wait}} = \max\left(0,\ \frac{1 - n_{\text{tokens}}}{r}\right) \times 60\,\text{s}
$$

Another example — the BM25 formula used to score document chunks during retrieval:

Math syntax errors don't fail the build: KaTeX shows the faulty part as red source text so it's easy to find.

Mermaid diagrams

Code blocks with the language mermaid are rendered as diagrams. The Mermaid script loads on demand only on pages that contain diagrams, and diagrams re-render automatically to follow the site's light/dark mode. Click a diagram to enlarge it into a floating window, where you can zoom with the wheel, drag, and double-click to reset.

Zoom and pan

Diagrams taller than 120px show a set of buttons on hover: zoom in, zoom out, pan in four directions, reset, and the floating window. On touch screens the buttons are always visible. Holding Ctrl / ⌘ while scrolling (or pinching on a trackpad) zooms as well, and once a diagram is zoomed or panned you can drag it.

Add parameters after the language to adjust a single diagram:

```mermaid controls={true} placement="top-left"
flowchart LR
  A --> B
```
ParameterValuesDescription
controls (or actions){true}, {false}Always or never show the buttons; left out, the height of the diagram decides
placementtop-left, top-right, bottom-left, bottom-rightWhere the buttons are, bottom-right by default

Flowcharts

```mermaid
flowchart TD
  A[git push] --> B{Production branch?}
  B -- Yes --> C[Production build]
  B -- No, pull request --> D[Preview build]
  C --> E[Switch production pointer]
  D --> F["Preview URL site--shortid"]
```

Sequence diagrams

State diagrams

The diagram above is exactly the state flow of a deployment on the platform.

Supported diagram types

Every Mermaid diagram type is available. Common ones include flowchart, sequenceDiagram, classDiagram, stateDiagram-v2, erDiagram, gantt, pie, journey, gitGraph, mindmap, and timeline.

Diagrams are rendered with securityLevel: "strict": HTML in nodes and scripts in click callbacks are never executed. %%{init}%% can't change the security settings, the style text or the fonts either. When rendering fails, the source and error message are shown.

In the Markdown version

In a page's .md version and in llms-full.txt, Mermaid diagrams are kept as mermaid code blocks, so AI can read the diagram structure directly.