Diagrams, formulas and widgets
Three languages are drawn instead of shown as code: mermaid for diagrams, math for formulas and widget for a fixed view of HTML and CSS.
Diagrams
A mermaid (or mmd) block draws a diagram: flows, sequences, classes, states, Gantt charts, pies, timelines and the other kinds Mermaid draws.
```mermaid
flowchart LR
A{Raining?} -->|yes| B[Take an umbrella]
A -->|no| C[Go for a walk]
``````mermaid
sequenceDiagram
Ana->>Luis: Did you pay the fee?
Luis-->>Ana: Yes, yesterday
``````mermaid
pie title Spending this month
"Food" : 40
"Home" : 35
"Walks" : 25
``````mermaid
gantt
title Moving house
dateFormat YYYY-MM-DD
Boxes :a1, 2026-11-01, 5d
Van :a2, after a1, 1d
```- In Tisty, mind maps, schemas, freeform and class diagrams are drawn just as the diagram window draws them, with a small margin; other kinds, and a freeform diagram with icons or images, are drawn by the official Mermaid. All fit the width of the page, turn dark when Tisty is dark, and open large with a click.
- A
<br/>or<br>inside a diagram's words breaks the line. - When the document leaves Tisty as plain Markdown, an
mmdblock is writtenmermaid, the one word GitHub draws. - One too large to lay out — past 32 KiB, or a thousand boxes and arrows — or one that does not parse, is shown as code.
The diagram window
In Tisty, in a document that can be written, a double click on a diagram opens it in a window of its own, with the text on one side and the drawing on the other. A mind map (mindmap), a database schema (erDiagram), a freeform diagram (flowchart or graph) and a class diagram (classDiagram) are also edited by hand on the drawing; other kinds are edited in the text. On saving, the window rewrites only that block, and it stays Mermaid.
What the window needs to remember and Mermaid has no word for goes in %% tisty: comments inside the same block, which Mermaid does not draw:
- In freeform and class diagrams, one line per shape or class with where it sits:
%% tisty: A 40 40. A lane (subgraph) or a package (namespace) adds its width and height:%% tisty: g1 20 240 200 120. %% tisty: auto, in a freeform diagram, asks it to lay itself out after every change; while it is there, no shape's place is kept.- In a schema, one line per table, with where it sits if it was moved by hand and which columns are required.
```mermaid
flowchart TD
A[Order] --> B{Paid?}
B -->|yes| C[Ship]
subgraph g1 [Warehouse]
C
end
%% tisty: A 40 40
%% tisty: B 20 140
%% tisty: C 60 280
%% tisty: g1 20 240 200 120
``````mermaid
erDiagram
customer {
int id PK
string name
}
order {
int id PK
int customer_id FK
}
customer ||--o{ order : places
%% tisty: customer 60 60 required name
%% tisty: order required customer_id
```- Whoever writes the block by hand or through an agent leaves the
%% tisty:lines as they are. - Several required columns are separated by spaces, with no commas:
required id customer_id. - When a table or a class is renamed, its line changes with it; the line of something that is gone may be removed.
- There is no need to make up coordinates: a shape, class or table with no line, or a table whose line has no numbers, lays itself out beside the others.
Formulas
A formula inside a sentence goes between single dollars:
Energy is $E=mc^2$ and a circle's area, $\pi r^2$.Energy is and a circle's area, .
A math block, or a formula between double dollars on a line of its own, stands apart:
```math
\sum_{i=1}^{n} i = \frac{n(n+1)}{2}
```$$
\int_0^1 x\,dx = \tfrac{1}{2}
$$```math
\begin{pmatrix} a & b \\ c & d \end{pmatrix} \qquad |x| = \begin{cases} x & x \ge 0 \\ -x & x < 0 \end{cases}
```- A digit right after the closing dollar makes it a price, not a formula:
$5 and $10stays as written. \$is a dollar sign.- Past 8 KiB a formula is shown as code; a command it does not know is skipped.
Widgets
A widget block draws a fixed view, made only of HTML and CSS; its name goes in title. It runs nothing, ever, and names nothing outside itself, so it reads the same wherever the document is read. It comes with styles ready to use: stat, card, grid, two, head, badge (with ok, warn and bad), list, box (with done), gone, row, num, up and down, as well as tables.
```widget title="Rina this month"
<div class="grid">
<div class="stat"><small>Walks</small><b>42</b><em class="up">+6</em></div>
<div class="stat"><small>Kilometres</small><b>61</b><em class="down">−3</em></div>
<div class="stat"><small>Vaccines</small><b>up to date</b><span class="badge ok">done</span></div>
</div>
``````widget title="Glasses of water"
<div class="card">
<div class="head"><h3>Today</h3><span class="badge ok">6 of 8</span></div>
<details>
<summary>By the hour</summary>
<p>Two before noon and four after.</p>
</details>
</div>
```- It may hold text, lists, tables,
<details>,<svg>drawings, pictures written into it asdata:image/…, and a<style>of its own. - It holds no
<script>, noonclickor other handler, no link, button or form, no frame, sound or video, and nothing that comes from an address, in its HTML or in its CSS. - A block with anything else, or over 512 KB, is not a widget: it is shown as its code, with what is wrong, and none of it is drawn. An agent's call that writes one is refused.
- An attached
.htmlfile is a file like any other, shown as a chip; nothing a document holds ever runs.
GitHub draws every one of these fences but widget, and $…$ and $$…$$ too.