# Reference

> Every block, part and run of the document format, with its fields

Generated from the format's registry, so it always matches what validators accept.

Every block, part and run of the format, from the registry. The rules for all of them are in [document.md](../specification/the-document-format.md).

## Where blocks go

| Context | Allows |  |
| --- | --- | --- |
| document | `text`, `media`, `flow`, `structure`, `layout` | The document's top level. |
| tab | `text`, `media`, `flow`, `structure`, `columns`, `steps`, `accordion` | A tab: everything but tabs. |
| layout | `text`, `media`, `flow`, `structure` | A column, a step, an accordion: no layout inside layout. |
| flow | `text`, `media`, `flow` | A quote, a callout, a list item: no tables, cards or layout. |
| cell | `paragraph`, `heading`, `code`, `list`, `image`, `file`, `divider` | A table cell: simple content. |

Groups: **text** (`paragraph`, `heading`, `code`): Blocks of text: paragraphs, headings, code. **media** (`image`, `video`, `file`, `embed`, `divider`, `fileTree`, `drawing`, `diagram`): Blocks that show one thing: images, videos, files, embeds, dividers, file trees, drawings, diagrams. **flow** (`quote`, `callout`, `list`): Containers of running content: quotes, callouts, lists. **structure** (`table`, `cards`): Tables and cards. **layout** (`tabs`, `columns`, `steps`, `accordion`): Blocks that lay content out: tabs, columns, steps, accordions.

## Blocks

Every block has an `id` (required, unique in the document) and its `type`.

### paragraph

A paragraph. Group: text.

| Field | Kind | Default |  |
| --- | --- | --- | --- |
| `align` | `"left"`, `"center"`, `"right"` | `"left"` | Text alignment. |
| `text` | text | none | The paragraph's text. |

### heading

A section heading. Group: text.

| Field | Kind | Default |  |
| --- | --- | --- | --- |
| `level` | `1`, `2`, `3` | `1` | 1 to 3. |
| `align` | `"left"`, `"center"`, `"right"` | `"left"` | Text alignment. |
| `text` | text | none | The heading's text. |

### code

Preformatted code. Group: text.

| Field | Kind | Default |  |
| --- | --- | --- | --- |
| `language` | string | `""` | The language it's written in, a lowercase name (typescript, go, bash, mermaid…); empty for none. |
| `filename` | string | `""` | Shown as a title above the code; empty for none. |
| `code` | string | `""` | The code: plain text, lines separated by \\n. |

### quote

A quotation. Group: flow.

| Field | Kind | Default |  |
| --- | --- | --- | --- |
| `blocks` | blocks (flow) | required | The quotation. |

### callout

A highlighted box. Group: flow.

| Field | Kind | Default |  |
| --- | --- | --- | --- |
| `tone` | `"info"`, `"success"`, `"warning"`, `"danger"` | `"info"` | How it looks: a note, a tip, a warning, a danger. |
| `blocks` | blocks (flow) | required | What it says. |

### list

A bulleted, numbered or task list. Group: flow.

| Field | Kind | Default |  |
| --- | --- | --- | --- |
| `style` | `"bullet"`, `"ordered"`, `"task"` | `"bullet"` | Bullets, numbers or checkboxes. |
| `start` | integer ≥ 0 | `1` | Ordered lists: the first item's number. |
| `moveChecked` | boolean | `false` | Task lists: checked items move to the end. |
| `items` | [listItem](#listitem)\[\], at least 1 | required | The items. |

### table

A table. Group: structure.

| Field | Kind | Default |  |
| --- | --- | --- | --- |
| `columns` | [tableColumn](#tablecolumn)\[\] | `[]` | Column widths, set when someone resizes a column; empty for automatic layout. |
| `rows` | [tableRow](#tablerow)\[\], at least 1 | required | The rows. |

### cards

A grid of cards. Group: structure.

| Field | Kind | Default |  |
| --- | --- | --- | --- |
| `cards` | [card](#card)\[\], at least 1 | required | The cards. |

### tabs

Tabs, one of which shows at a time. Only at the top level of a document. Group: layout.

| Field | Kind | Default |  |
| --- | --- | --- | --- |
| `group` | string | `""` | Tab groups with the same name switch together: picking a tab in one picks the tab with the same label in the others. |
| `tabs` | [tab](#tab)\[\], at least 1 | required | The tabs. |

### columns

Side-by-side columns. Group: layout.

| Field | Kind | Default |  |
| --- | --- | --- | --- |
| `columns` | [column](#column)\[\], at least 1 | required | The columns, of equal width. |

### steps

Numbered steps. Group: layout.

| Field | Kind | Default |  |
| --- | --- | --- | --- |
| `steps` | [step](#step)\[\], at least 1 | required | The steps, numbered in order. |

### accordion

A section that opens and closes. Group: layout.

| Field | Kind | Default |  |
| --- | --- | --- | --- |
| `title` | text | none | What shows when it's closed. |
| `blocks` | blocks (layout) | required | What shows when it's open. |

### image

An image. Group: media.

| Field | Kind | Default |  |
| --- | --- | --- | --- |
| `src` | string | required | The image's address: an uploaded file (/files/…) or any URL. |
| `alt` | string | `""` | Alternative text. |

### video

A video file, played in place. Group: media.

| Field | Kind | Default |  |
| --- | --- | --- | --- |
| `src` | string | required | The video file's address. |
| `name` | string | `""` | The file name. |

### file

A file to download. Group: media.

| Field | Kind | Default |  |
| --- | --- | --- | --- |
| `src` | string | required | The file's address. |
| `name` | string | `""` | The file name. |
| `size` | integer ≥ 0 | `0` | Size in bytes; 0 when unknown. |

### embed

Embedded content from another site. Group: media.

| Field | Kind | Default |  |
| --- | --- | --- | --- |
| `url` | string | required | The page to embed. Renderers with a web view show it; others show a link card, and play YouTube and Vimeo links where they can. |

### divider

A dividing line. Group: media.

No fields but `id` and `type`.

### fileTree

A file and folder tree. Group: media.

| Field | Kind | Default |  |
| --- | --- | --- | --- |
| `entries` | [fileEntry](#fileentry)\[\] | `[]` | The top-level files and folders. |

### drawing

A drawing: shapes, arrows, freehand strokes, text and images. Group: media.

| Field | Kind | Default |  |
| --- | --- | --- | --- |
| `scene` | scene | none | The drawing (spec/drawing.md). |

### diagram

A diagram made from text, laid out by the diagram engine. Group: media.

| Field | Kind | Default |  |
| --- | --- | --- | --- |
| `kind` | `"flow"`, `"sequence"`, `"class"` | `"flow"` | The kind of diagram (spec/diagram-language.md). |
| `source` | string | `""` | The diagram text: the source of truth. |
| `layout` | [diagramLayout](#diagramlayout) | none | What the user changed by hand: positions of moved boxes, and the text the scene was last laid out from. |
| `scene` | scene | none | The drawing: the elements laid out from the text (they have keys) and any drawn next to them by hand (they don't). |

## Parts

Parts are the pieces of a block (a list's items, a table's rows). They have no `type`: the field they're in says what they are.

### listItem

A list item.

| Field | Kind | Default |  |
| --- | --- | --- | --- |
| `id` | string | required | Unique in the document. |
| `checked` | boolean | `false` | Task lists: whether it's done. |
| `blocks` | blocks (flow; first a paragraph or heading) | required | The item's content: a paragraph or heading first, then any blocks (nested lists among them). |

### tableColumn

A table column's width.

| Field | Kind | Default |  |
| --- | --- | --- | --- |
| `width` | number ≥ 0 | required | The column's width as a fraction of the table's; the widths add up to 1. |

### tableRow

A table row.

| Field | Kind | Default |  |
| --- | --- | --- | --- |
| `id` | string | required | Unique in the document. |
| `cells` | [tableCell](#tablecell)\[\], at least 1 | required | The cells. |

### tableCell

A table cell.

| Field | Kind | Default |  |
| --- | --- | --- | --- |
| `id` | string | required | Unique in the document. |
| `header` | boolean | `false` | A header cell. |
| `colspan` | integer ≥ 1 | `1` | Columns it spans. |
| `rowspan` | integer ≥ 1 | `1` | Rows it spans. |
| `blocks` | blocks (cell) | required | The cell's content. |

### card

A card.

| Field | Kind | Default |  |
| --- | --- | --- | --- |
| `id` | string | required | Unique in the document. |
| `title` | string | `""` | The card's title. |
| `description` | string | `""` | The card's text. |
| `cover` | string | `""` | A cover image's address; empty for none. |
| `href` | string | `""` | Where it links to; empty for nowhere. A note takes precedence. |
| `note` | string | `""` | The note it links to; empty for none. |
| `noteName` | string | `""` | That note's name when linked, for readers that can't look it up. |

### tab

A tab.

| Field | Kind | Default |  |
| --- | --- | --- | --- |
| `id` | string | required | Unique in the document. |
| `label` | string | `"Tab"` | The tab's label. |
| `blocks` | blocks (tab) | required | The tab's content. |

### column

A column.

| Field | Kind | Default |  |
| --- | --- | --- | --- |
| `id` | string | required | Unique in the document. |
| `blocks` | blocks (layout) | required | The column's content. |

### step

A step.

| Field | Kind | Default |  |
| --- | --- | --- | --- |
| `id` | string | required | Unique in the document. |
| `title` | text | none | The step's title. |
| `blocks` | blocks (layout) | required | The step's content. |

### fileEntry

A file or folder in a file tree.

| Field | Kind | Default |  |
| --- | --- | --- | --- |
| `name` | string | required | The file or folder name. |
| `dir` | boolean | `false` | A folder. |
| `highlight` | boolean | `false` | Highlighted (the file the text is about). |
| `entries` | [fileEntry](#fileentry)\[\] | `[]` | What's inside it. |

### diagramLayout

A diagram's layout state.

| Field | Kind | Default |  |
| --- | --- | --- | --- |
| `positions` | { key: box } | `{}` | Where boxes the user moved are, by element key (n:\<name>): x, y, and w and h when the user sized them. |
| `drawnFrom` | string | `""` | The text the scene was last laid out from, to recognise renames when the text changed elsewhere. |

## Runs

Text is a list of runs. Which kind a run is follows from its fields: `text`, `note` or `break`.

### text

Text with the same formatting.

| Field | Kind | Default |  |
| --- | --- | --- | --- |
| `text` | string | required | The text; never empty. |
| `bold` | boolean | `false` | Bold. |
| `italic` | boolean | `false` | Italic. |
| `underline` | boolean | `false` | Underlined. |
| `strike` | boolean | `false` | Struck through. |
| `code` | boolean | `false` | Inline code. |
| `link` | link | none | A hyperlink: href (a URL, a #heading anchor or a relative path) and an optional title. |

### note

A link to another note, shown with the note's current name. Counts as one position.

| Field | Kind | Default |  |
| --- | --- | --- | --- |
| `note` | string | required | The note linked to. |
| `name` | string | `""` | That note's name when linked, for readers that can't look it up. |

### break

A line break. Counts as one position.

| Field | Kind | Default |  |
| --- | --- | --- | --- |
| `break` | boolean | required | Always true. |
