# Writing Koma
> The complete writing reference for Koma, a plain-text language for slides, articles and posters, in one file for language models and other programs. Every Koma example below passes `koma check` with the same version of the language.
Koma is new and is probably not in your training data. It looks like Markdown but is not Markdown, Marp, reveal.js or Pandoc slides: do not guess its syntax from them. Follow this file, keep what is already in a document, and run `koma check` before you hand a file back. The specification at https://komalang.org/spec/ is normative where this summary is shorter.
A Koma document is one UTF-8 text file ending in `.koma`. Elements in square brackets say where content goes, and Markdown and LaTeX inside them say what it is. The same file becomes HTML, PDF, PowerPoint or pictures.
## A whole document
```koma
===
title: Night Light and Moths
theme: default
size: 16:9
paginate: true
===
---
layout: cover
---
[title: Night Light and Moths]
[subtitle: A fictional survey of three streets]
[authors: Rin Asano]
[date: 12 June]
+++
[label: Survey]
[title: Warm light draws fewer moths]
[subtitle: Counts per lamp over one night]
[main:
[col:
| Street | Lamp | Moths |
| --- | --- | ---: |
| Elm | cool white | 48 |
| Oak | warm white | 17 |
| Ash | amber | 6 |
]
[col:
- Counted from 21:00 to 23:00
- The same lamp height on every street
- **Every number here is invented**
]
]
"""
Start with the amber lamp. [[Point to the last row]]
"""
+++
---
layout: section
---
[title: What we will try next]
[subtitle: Dimmer lamps on Elm Street]
```
## Document structure
A file is document settings, then pages.
- Document settings are YAML between two `===` lines at the very top. They belong to no page.
- `+++` alone on a line, in column 0, ends one page and starts the next. Write one blank line before and after it. The first page needs no `+++`.
- A page may start with page settings: YAML between two `---` lines, before any of the page's content.
- `---` is never a horizontal rule and never a page break. A horizontal rule is `***`.
- `"""` lines enclose speaker notes, and a `:::` line with attributes opens a memo for the author. Both start in column 0 directly on a page.
- A line starting with `;` is a comment: kept in the source, never shown or exported. Write `; comment` with one space. `//` is ordinary text.
- Indentation is two spaces per level. Tabs never count as indentation.
### Document settings
```koma
===
title: Harbour Ferry Timetable
type: slide
size: 16:9
theme: talk
lang: en
paginate: true
total-duration: 20:00
===
[title: Harbour Ferry Timetable]
```
- `title`: the document's name.
- `type`: `slide` (the default), `article` or `poster`. The kind never follows from the size.
- `size`: `16:9` (the default), `4:3`, a paper size with its kind (`type: article` and `size: A4`), or pixels such as `1080 x 1920`.
- `theme`: `default`, `talk`, `report`, or the path of a `theme.koma`, such as `./themes/harbour/theme.koma`.
- `lang`: the language of the text, such as `en` or `ja`.
- `paginate`: `true` shows page numbers.
- `total-duration`: the planned length of a talk in minutes and seconds, `20:00`.
- `css`: the document's own CSS (see Looks).
- `functions`: named formulas for curves (see Lines, shapes and curves).
- Settings are YAML 1.2. Quote a string that YAML would read as something else (`title: "2024"`). A YAML comment starts with `#`.
### Page settings
```koma
[title: Harbour Ferry Timetable]
+++
---
layout: section
class: night
duration: 1:30
---
[title: Night crossings]
```
- `layout`: `cover`, `section`, `content` (the default), `blank` (no frames), and the layouts a theme adds; the official themes add `outline`, a numbered contents page.
- `class`: a class for the page, which the document's CSS selects as `page.night`.
- `id`, `paginate: false` (hide this page's number), `skip: true` (leave the page out of presenting and audience exports), `duration: 1:30` (the time planned for this page), `transition: fade` (`none`, `fade` or `push`).
- `title`, `type` and `size` belong to the document. Written in a page's `---`, they are reported as `setting-out-of-scope`.
## Elements
An element is written in square brackets: a tag, a colon, then content.
```koma
[title: Harbour Ferry Timetable]
[main:
Ferries leave every **twenty minutes**.
[box #fare .tint:
Fares are paid on board.
]
]
[box .card x=62% y=70% w=30%:
Last boat at 23:40.
]
```
- One line: `[title: content]`.
- Several lines: the opening line ends with `:`, the content is indented two spaces deeper, and `]` alone closes it at the opening's depth. Nested elements are indented two more spaces each.
- The tag always ends with `:`. An element without content ends `:]`, as in `[image src="figures/route.svg" alt="The ferry route":]`.
- The standard tag is `name #id .class .class key=value`, separated by spaces.
- A value of a kind may go unquoted: a word, a number, a length such as `40%` or `240px`, or `#id`. Anything else is quoted: `alt="Ferry at the pier"`, `src="figures/pier.png"`. Several values are a list in parentheses: `widths=(2, 1, 1)`.
- A bracketed line without the colon, such as `[TODO]` or `[1]`, is text. To write a line that looks like an element as text, start it with a backslash: `\[theorem: literal]`.
- Positions and sizes carry a unit: `%` of the parent, or `px`. Only `0` may leave its unit out.
- Attributes of your own start with `data-`, as in `data-source=fig3`; any other unknown attribute is reported.
### Slots and roles
The theme's layout has frames, and slot elements put content in them by role.
- `[label: …]`: a short context line, such as the chapter or the event.
- `[title: …]`: what the page is about, usually a one-line noun phrase.
- `[subtitle: …]`: the one sentence the page wants to say. With the title it forms the page's heading.
- `[main: …]`: the body: text, lists, figures, tables, columns.
- `[footer: …]`: an optional footer.
- On a cover only: `authors`, `affiliations` and `date`, written as they should appear.
Write each slot once per page. A second one is drawn on top of the first and reported as `duplicate-slot`. Page numbers are not written: use `paginate`. References come from footnotes.
Elements with no fixed frame:
- `[box: …]`: a plain container, placed in the flow or with `x`, `y`, `w`, `h`.
- `[callout: …]`: a box with a marker on its left (see Boxes and callouts).
- `[shape: …]`: a rectangle or ellipse with text inside its outline.
- `[group: …]`: keeps elements together; it has no place, size or look of its own.
- `[col: …]` and `[row: …]`: columns and rows inside the element that holds them.
- `figure`, `image`, `table`, `math`, `code`, `diagram`, `line` and `curve`: described below.
A theme may define its own tags, whose names contain a hyphen. Any other name is `unknown-tag`.
### Placement
Without `x` and `y`, an element flows: a slot goes to its frame, and anything else follows the content before it. With `x` and `y` it is placed on its parent, which is the page itself when it stands directly on the page.
```koma
[title: Ferry routes]
[main:
[col weight=2:
The north route stops at **four** piers.
]
[col .ruled:
The south route runs at night only.
]
]
[box .fill x=74% y=78% w=20% h=12% style="text-align: center; align-content: center":
Free on Sundays
]
```
- `[col:]` side by side makes columns, and `[row:]` makes rows. `weight` sets their proportions.
- The space between columns or rows is `gap` in the `style` of the element that holds them: `[main style="gap: 24px":`.
- The class `ruled` on one column draws a thin line in each gap.
- `align-content` in `style` (`start`, `center` or `end`) places content down a column or box that is taller than it.
- Text written directly on a page, outside any element, flows in the page's padding. Put visible text in `[main: …]` or a box instead.
## Text
Text inside an element is Markdown.
```koma
[title: Pier rules]
[main:
# Before boarding
Keep *bicycles* at the **lower deck**; __never__ on the stairs.
1. Buy a ticket.
2. Wait behind the ==yellow line==.
Price
: Two coins a crossing
Sunday ferries are free.[^sun]
[^sun]: A fictional rule for this example.
***
Water temperature 14 °C, wind 3 m s^{-1}, [On time]{.chip}.
]
```
- `#` at the start of a line is a heading inside the body. Use `#` only; `##` and deeper are reported as `deep-heading`.
- `*emphasis*`, `**strong**`, `__underline__`, `~~strike-through~~`, `==highlight==`, `` `code` ``, links `[text](https://example.com)`.
- Superscript `^{…}` and subscript `_{…}`: `H_{2}O`, `1^{st}`.
- A class on a span: `[On time]{.chip}`. `.chip` draws a small rounded label in the official themes; other classes need the document's CSS, or are reported as `unknown-class`. A span may also take `style`: `[late]{style="color: #b42318"}`.
- A definition list is a term on one line, then a line starting with `: `.
- Footnotes are `[^label]` with `[^label]: text` in the same element; they collect at the foot of the page.
- `***` is a horizontal rule. A line break inside a paragraph is kept as a line break.
- Do not add no-break spaces or zero-width characters to steer line breaks; the renderer keeps numbers with their units.
- A backslash keeps a character as text: `\*`, `\[`, `\;`.
## Math
Math is LaTeX: `$…$` inside text, and `$$` on lines of their own around display math.
```koma
[title: How fast the wake fades]
[main:
The wave height falls as $h(t) = h_0\,e^{-t/\tau}$.
$$
\tau = \frac{2 m}{\rho C_d A v}
$$
The model ignores $\text{wind}$ and tides; $\ce{H2O}$ at $14\,^\circ\mathrm{C}$.
]
```
- Write names inside math with `\text{…}`, so that they take the face of the text around them.
- `\ce{…}` writes chemistry as mhchem does.
- A formula standing on its own, outside any text, is a `math` element.
- `style="--math-font: fira"` on an element draws its math in another face: `fira`, `stix2` or `newcm`.
- `$5 and $10` is not math, as in Pandoc. A root sign outside math, as in `√2`, is reported: write `$\sqrt{2}$`.
## Figures and pictures
```koma
[title: The north route]
[main:
[col:
[figure:
[image src="figures/north-route.svg" alt="Map of the north route with four piers":]
The north route, with its four piers
]
]
[col:

]
]
```
- A captioned picture is a `figure` holding an `image`, then its caption on the following lines.
- A picture with no caption is `[image src="…" alt="…":]` alone, or a Markdown picture alone on its line.
- `src` is relative to the document's folder and stays inside it. Keep the picture files beside the document.
- `alt` says what the picture shows; `alt=""` marks a decorative picture.
- Without `w` or `h`, a figure fills the space left in what holds it, keeping its proportions.
- `crop=(10%, 0, 5%, 20%)` on an image cuts the top, right, bottom and left, in that order; the file is not changed.
- Add the class `card` or `outline` to a figure for a frame.
## Tables
A Markdown table is written directly in the text. Wrap it in a `table` element for widths, a caption, notes or a style.
```koma
[title: Crossings this week]
[main:
[table .grid .striped widths=(2, 1, 1):
Crossings by pier, Monday to Friday
| Pier | Boats | Passengers |
| --- | ---: | ---: |
| North | 40 | 1,210 |
| South | 25 | 640 |
Counts are invented.
]
]
```
- In a `table` element, one paragraph before the table is its caption, and paragraphs after it are notes.
- `widths=(2, 1, 1)` shares the width by ratio, one number for each column.
- Styles are classes, which combine: `grid` (rule every row and column), `striped`, `accent`, `row-heads` (each row's first cell is its header).
- `
` breaks a line inside a cell.
- A table read from data: `[table src="data/piers.csv":` with its caption on the next line, then `]`. A `.tsv` file is separated by tabs. Cells are plain text.
## Diagrams
A fenced `mermaid` block draws a diagram with Mermaid.
````koma
[title: How a ticket is checked]
[main:
```mermaid
flowchart LR
A[Buy ticket] --> B[Board]
B --> C{Inspector}
C -->|valid| D[Ride]
C -->|missing| E[Pay fare]
```
]
````
- A `diagram` element holds a diagram on its own; its body is Mermaid.
- Mermaid's `accTitle` and `accDescr` give the diagram its alternative text.
- An invalid diagram shows its source with an error and does not stop the other pages.
## Code
````koma
[title: Counting passengers]
[main:
```python {2}
def total(counts):
return sum(counts)
```
]
````
- Name the language after the opening fence.
- `{2,4-5}` after the language highlights lines; `{1|2-3}` highlights groups one step at a time; `showLineNumbers` numbers the lines; `diff` marks additions and deletions.
- Everything inside a code or math fence is content: no element, setting or comment starts there. Only a `+++` in column 0 still breaks the page.
- A `code` element holds code on its own, outside any text.
## Boxes and callouts
```koma
[title: Before you sail]
[main:
[callout marker="⚠":
Life jackets are under every seat.
]
[box .outline:
Ask the crew about **bicycles**.
]
]
```
- The style classes, quietest first: `outline` (a thin line), `card` (a raised card), `tint` (a light ground), `bar` (a line down the left) and `fill` (solid accent with white text). With none, a box has no border or ground.
- A callout's `marker` is one emoji or one symbol (`marker="∴"`, `marker="※"`), or `none`; without it, 💡. A word is not a marker: `marker=Cost` is reported as `text-marker`. A callout with no style class is drawn `tint`.
- A `shape` with `type=ellipse` draws an ellipse with its text inside; `type=rect` with `radius=16px` makes a rounded rectangle.
## Lines, shapes and curves
```koma
===
functions:
swell(t): 0.5*(1-cos(2*pi*t))
===
[title: Pier to pier]
[box #north x=8% y=40% w=24%:
North pier
]
[box #south x=68% y=40% w=24%:
South pier
]
[line from=#north to=#south arrow=end:]
[curve x=30% y=70% w=40% h=12% f="swell(t)*sin(2*pi*5*t)":]
```
- A line joins two points, `x1`, `y1`, `x2`, `y2` in `px`, or two elements on the same page by their ids, as in `[line from=#a to=#b arrow=end:]`. `route=elbow` turns it at right angles and `route=curve` bends it.
- `arrow` is `start`, `end` or `both`. Head shapes are the classes `.stealth-head`, `.open-head`, `.dot-head` and `.diamond-head`.
- Width and dashes are `style="stroke-width: 4px; stroke-dasharray: 12px 8px"`. A line has no text: put a label in a box.
- A curve draws a formula of `t` from 0 at its left to 1 at its right; its values run from -1 at the bottom to 1 at the top. Write `*` for every product.
## Looks: classes, style and CSS
Attributes say what an element is and where it goes; classes and `style` say how it looks.
```koma
===
title: Harbour notices
css: |
title { color: #245b78; }
page.night { background: #10202c; color: #f2f5f7; }
.late { color: #b42318; }
===
[title: Day crossings]
[main:
The 08:20 boat is [late]{.late} today.
]
+++
---
class: night
---
[title: Night crossings]
[main:
[box style="font-size: 28px; padding: 16px":
Two boats an hour after 22:00.
]
]
```
- Never write a look as an attribute: `color=`, `fill=`, `opacity=`, `gap=` have no effect on a box and are reported as `presentation-attribute`. Put them in `style`.
- `style` takes CSS declarations such as `color`, `background-color`, `font-size`, `font-weight`, `padding`, `border-bottom`, `text-align`, `align-content`, `opacity` and `gap`.
- The document's `css:` styles elements by tag, id and class, pages with `page` and `page.class`, and one layout with `@layout cover { title { … } }`. Inside elements it reaches Markdown's parts by their HTML names: `p`, `li`, `h3`, `img`, `th`, `td`.
- `css:` may also name a CSS file inside the document's folder, or a list of files and literal blocks.
- There is no per-page CSS: give the page a `class` and select it.
## Themes
- `theme: default` is a quiet general starting point; `talk` has larger text and more space; `report` fits more figures and notes. A document that names no theme uses `default`.
- A theme is itself a Koma document, `theme.koma`. `koma theme copy default -o themes/harbour` makes an editable copy; then write `theme: ./themes/harbour/theme.koma`.
- `koma theme freeze talk.koma` copies the document's theme beside it and pins `theme:` to that copy, so the document keeps its look when the built-in theme changes.
- A theme's sample pages define its layouts and their frames. Positions written in the document win over the theme's.
## Speaker notes
Notes are Markdown for the presenter, between two lines of `"""`, written directly on the page after its content, with a blank line before and after. They never reach the audience's HTML, PDF or pictures; PowerPoint keeps them as speaker notes.
```koma
[title: Night crossings]
"""
Mention the new lamps on the pier. [[Point to the map]]
[[
If someone asks about fares:
- Night fares match day fares.
- Children ride free.
]]
"""
+++
[title: Questions]
```
- Inside notes, `[[Point to the map]]` on a line is a stage direction: the presenter sees it, and it is never read aloud. It is plain words, never a pause or a command.
- A line of `[[` alone opens an unspoken block and a line of `]]` alone closes it, both in column 0; indent the lines between by two spaces.
- Several notes on one page join in order.
- A page's planned time belongs in its settings, `duration: 1:30`, not in its notes.
- Notes are not an element: there is no `[notes: …]`.
## Memos
A memo is a note for the author, placed on the page in the editor and shown by no presentation or export. It opens with `:::` and attributes in column 0, and closes with `:::` alone.
```koma
[title: Night crossings]
::: x=64% y=18% w=28%
Check the timetable against the harbour office.
:::
```
- `x` and `y` place it (`%` of the page or `px`, and may lie off the page), `w` and `h` size it, and `collapsed` set to `true` folds it to a pin.
- Its text is plain text, never Markdown, elements or settings.
- Keep the memos you find in a document unless you are asked to resolve them. A bare `:::` with no attributes is not a memo and is reported.
## Steps and transitions
- `step=1`, `step=2` on an element reveals it on that step while presenting.
- `step-effect` is `appear`, `fade` or `rise`, on an element or in the settings.
- A page's `transition` is `none`, `fade` or `push`, in the document or page settings.
## The koma command
`koma` has eleven commands. Install it with `npm i -g @komalang/koma`, or run it once with `npx @komalang/koma`. Every command takes `--help`.
| Command | What it does |
| --- | --- |
| `koma new ` | Write a new document; `--type slide\|article\|poster`, `--size`, `--name` |
| `koma import -o ` | Translate Markdown to Koma source |
| `koma check ` | Report problems and formatting differences; `--write` applies safe fixes and the standard form; `--layout` also draws the pages |
| `koma lint ` | Report problems only |
| `koma format ` | Check the standard form; `--write` rewrites the file |
| `koma parse ` | Print the Koma syntax tree; `--json` for programs, with its `astVersion` |
| `koma export -o ` | Write HTML, PDF or PowerPoint by the ending of `-o`, or `--to png` a picture per page into a folder |
| `koma pack -o ` | Collect the document, its files and its theme into one `.komadoc` |
| `koma theme copy` and `koma theme freeze` | Make an editable copy of a theme, or pin the document's theme beside it |
| `koma mcp …` | Serve the named files to an MCP client over stdio, read-only: reading, drawing and checking |
| `koma lsp` | A Language Server for editors over stdio: problems, formatting, outline, completion and hover |
- Exit codes: 0 done, 1 a condition not met (findings above a note, or not in the standard form), 2 usage, I/O or internal errors.
- `--json` prints one JSON object with `file`, `digest` and `findings`.
- `export` and `check --layout` draw with Google Chrome, Chromium or Microsoft Edge already installed; `--browser ` names one. They never download a browser, never write over a file without `--force`, and never change the input.
### Check your work
1. Write or edit the `.koma` file.
2. Run `koma check talk.koma`. Each finding has a level, a code, a line and a message; it changes nothing.
3. Fix the errors and warnings it reports. `koma check --write talk.koma` applies the fixes that keep the meaning and writes the standard form (indentation, spacing around `+++` and `"""`).
4. Fixes that may change the meaning are applied only with `--write --unsafe`. Use it only when the person asked for that change.
5. When a browser is available, run `koma check --layout talk.koma` to find text that overflows its frame and pictures that cannot be read.
6. Repeat until `koma check` exits with 0.
## Typical mistakes and fixes
Each wrong example below is shown with the code `koma check` reports for it.
A tag without its colon is not an element (`missing-colon`):
```koma expect=missing-colon
[title Night Light and Moths]
```
Write `[title: Night Light and Moths]`.
`---` after content is not a page break or a rule (`misplaced-settings`):
```koma expect=misplaced-settings
[title: Day crossings]
---
[main: Two boats an hour.]
```
Write `+++` to start a new page, or `***` for a horizontal rule.
`---` inside an element is not a rule either (`dashes-not-rule`):
```koma expect=dashes-not-rule
[main:
Day crossings
---
Night crossings
]
```
Write `***`.
A look written as an attribute has no effect (`presentation-attribute`):
```koma expect=presentation-attribute
[box color=red:
Last boat at 23:40.
]
```
Write `[box style="color: red":`.
A position or size without its unit has no effect (`missing-unit`):
```koma expect=missing-unit
[box x=10 w=30%:
Last boat at 23:40.
]
```
Write `x=10%` or `x=10px`.
An element that is never closed hides the rest of its page (`unclosed-element`):
```koma expect=unclosed-element
[main:
Two boats an hour.
```
Close it with `]` alone at the opening's depth.
Notes that are never closed (`unclosed-notes`):
```koma expect=unclosed-notes
[title: Night crossings]
"""
Mention the new lamps.
```
Close them with a line of `"""`.
Speaker notes are not an element (`unknown-tag`):
```koma expect=unknown-tag
[title: Night crossings]
[notes: Mention the new lamps.]
```
Write them between `"""` lines.
A second title on one page is drawn on top of the first (`duplicate-slot`):
```koma expect=duplicate-slot
[title: Day crossings]
[title: Night crossings]
```
Keep one title per page, or start a new page with `+++`.
Document settings written in a page's `---` (`setting-out-of-scope`):
```koma expect=setting-out-of-scope
---
title: Harbour Ferry Timetable
---
[title: Harbour Ferry Timetable]
```
Write `title`, `type`, `size` and `theme` between `===` lines at the top.
Markdown's deeper headings (`deep-heading`):
```koma expect=deep-heading
[main:
## Night crossings
]
```
Write `# Night crossings`: a heading inside a page's text is always one `#`.
A word as a callout marker (`text-marker`):
```koma expect=text-marker
[callout marker=Cost:
Two coins a crossing.
]
```
Choose one emoji or symbol, or write the heading as a definition list.
A planned time written in the notes (`notes-time`):
```koma expect=notes-time
[title: Night crossings]
"""
0:59 + 0:04 = 1:03
"""
```
Write `duration: 1:03` in the page's settings.
Content that is not indented under its element (`not-formatted`):
```koma expect=not-formatted
[main:
Two boats an hour.
]
```
Indent it two spaces, or run `koma check --write`.
Other things to avoid:
- `//` is not a comment; it is drawn as text. Use `;`.
- Do not wrap a whole page in `[main: …]` with its title inside; write `[title: …]` beside `[main: …]`.
- Do not invent elements such as `slide` or `columns`: an unknown tag is reported as `unknown-tag` and drawn as a plain box. Use the elements in this file.
- Do not reformat or migrate a document you were asked to change in one place. Change only what was asked, and keep comments, memos, unknown settings and attributes as they are.
## Before you finish
- Each page is separated by `+++` with a blank line on either side.
- Every element's tag ends with `:`, and every multi-line element closes with `]`.
- Each page has at most one of each slot.
- Looks are in classes or `style`, never in attributes.
- Pictures and data files are inside the document's folder, and every picture that carries meaning has `alt` text.
- `koma check` exits with 0.
---
# The documentation
> Every page of the English documentation on komalang.org, as Markdown, in the order of its contents.
# Start
Write a first page in plain text and see it drawn. Try it here, then open it in KomaDocs or use the command.
## 1. Try it in the browser
Change the title, or put the `**` marks around another word to make it bold.
```koma
[title: Night at the library]
[subtitle: Friday · 7–10 pm]
[main:
Bring a book to **swap**.
]
```
> Night at the library, Friday 7–10 pm, with “swap” in bold.
## 2. Open it in KomaDocs
[KomaDocs](https://komadocs.com/) is the editor for Koma: the source and the canvas side by side on the web and macOS, drawn as above. Drag a box or change a colour on the slide, and the text is written for you. Nothing to install on the web.
## 3. Make a PDF with the command
The `koma` command is in preparation: the `@komalang/koma` package is not on npm yet, so the steps below do not work today.
Save the source above as `hello.koma`.
Install the `koma` command with npm. It needs Node.js 24 or later and Chrome, Chromium or Edge installed on your computer.
```
npm i -g @komalang/koma
```
Make the PDF:
```
koma export hello.koma -o hello.pdf
```
Open `hello.pdf` to see the slide.
For PNG images or a PowerPoint file, use:
```
koma export hello.koma --to png -o hello-png
koma export hello.koma -o hello.pptx
```
The PNG images are saved in `hello-png`. See the [command list](https://komalang.org/command/) for more options.
## Next
Use the [Guide](https://komalang.org/guide/) to add columns and a second page.
---
# Guide
Learn the language a topic at a time. Every example can be edited, and is drawn again as you type.
- [Why Koma](https://komalang.org/guide/why/)Write with Markdown, work on the same source with people and tools, and review changes in Git.
- [Elements and text](https://komalang.org/guide/elements/)An element’s name tells you its role; its text is written in Markdown.
- [Columns and boxes](https://komalang.org/guide/layout/)Let the theme lay out the page, or place a box yourself. Both stay in the text.
- [Lines and curves](https://komalang.org/guide/lines/)Join elements with lines, draw a path through points, or plot a formula.
- [Pages and settings](https://komalang.org/guide/pages/)Split the document into pages, and set a theme or a layout in a few lines.
- [Figures, tables and math](https://komalang.org/guide/figures/)Bring in pictures and data, and write math as you would in LaTeX.
- [Speaker notes](https://komalang.org/guide/notes/)Notes for the speaker stay in the source and never reach the slide.
- [Check and tidy](https://komalang.org/guide/checking/)One command finds problems and writes the standard form.
Start with [Why Koma](https://komalang.org/guide/why/)
---
[Guide](https://komalang.org/guide/) · 1 of 8
# Why Koma
Write slides with the ease of Markdown and the control of a layout tool. The source stays readable, whether you edit it yourself, work with an AI assistant, or review a change in Git.
## Write naturally, lay out precisely
Write the words in Markdown and the math in LaTeX. Use readable tags to say what belongs where: `[title: …]` gives a page its title, and `[col: …]` puts content in a column. Let the theme handle the layout, or place a box exactly where you need it. You can use columns, figures, tables and diagrams without giving up a text-first way of writing.
See [Elements and text](https://komalang.org/guide/elements/) or [Columns and boxes](https://komalang.org/guide/layout/) for examples.
## One source for people and tools
A `.koma` file is plain text, so you and an AI assistant can work on the same source. For example, ask the assistant to turn notes into a draft document or revise one page without rebuilding the rest. Scripts can read the [syntax tree](https://komalang.org/spec/semantics/#unist) as JSON through the CLI, or use the library in their own code.
Use `koma check` to check edits without changing the file, then `koma export` to produce PDF, PowerPoint or HTML. See the [CLI reference](https://komalang.org/command/) and the [diagnostics](https://komalang.org/spec/semantics/#diagnostics).
## Review changes with Git
When someone changes a title, revises a paragraph, or moves a box, Git can show the changed text or coordinates. You can review and discuss those changes in a pull request without comparing two exported documents.
`koma format` gives contributors a common way to write the source. Images and data can live alongside it as separate files, and their changes are tracked separately.
## Further reading
- [The standard form](https://komalang.org/spec/conformance/#standard-form)
- [Rewriting only what changed](https://komalang.org/spec/conformance/#minimal-rewrite)
- [Diagnostics](https://komalang.org/spec/semantics/#diagnostics)
- [The syntax tree and unist](https://komalang.org/spec/semantics/#unist)
---
[Guide](https://komalang.org/guide/) · 2 of 8
# Elements and text
An element’s name tells you its role. Inside it, write in Koma Markdown, a dialect based on CommonMark.
## Write an element
In `[title: Night at the library]`, `title` names the element, and the colon introduces its content.
```koma
[title: Night at the library]
[subtitle: Friday · 7–10 pm]
[main: Read, browse or bring a book to swap. The reading room stays open until ten.]
```
> Night at the library, Friday 7–10 pm. Read, browse or bring a book to swap; the reading room stays open until ten.
## Add emphasis
Start with the familiar: `*italic*` for italics and `**bold**` for bold. Koma also supports `==highlight==` and LaTeX math such as `$x^2$`. Some syntax differs from CommonMark: raw HTML is displayed as text. See the [text markup rules](https://komalang.org/spec/text/#inline-markup).
For a longer body, end the opening line with a colon, indent the content by two spaces, and close it with `]` on a line of its own. The sample uses both bold and Koma’s highlight syntax.
```koma
[title: Night at the library]
[subtitle: Friday · 7–10 pm]
[main:
Bring a book to **swap**.
==No booking needed.==
]
```
> The library notice emphasizes “swap” in bold and highlights “No booking needed”.
## List terms and what they mean
Write a term on one line, then start the next line with `: ` and its explanation, as Pandoc does. Give a term with two meanings a second `: ` line; to carry one explanation onto the next line, indent that line instead. Terms sit on the left with their explanations beside them; the class `stack-terms` on the box puts each explanation under its term.
```koma
[title: Words we use]
[subtitle: For the talk on echoes]
[main:
Echo time
: How long a sound takes to fall by 60 dB,
counted from the moment the source stops.
Reflection
: Sound bouncing back from a surface.
: How much a surface sends back, which shapes how a room sounds.
]
```
> A slide titled “Words we use”: the terms Echo time and Reflection in bold on the left, each with its description beside it; Echo time has one explanation over two lines, and Reflection has two meanings.
## Space paragraphs, lists and blocks
Separate paragraphs with a blank line; Koma sets the space between them. A heading keeps a small space below it and a larger one above. Paragraphs that follow one another are as far apart as list items. A list, and a display block such as maths, code, a table or a figure, takes the same space above and below, and where two meet the larger one counts. When the text does not fit, these gaps close up together before the text gets smaller. A Japanese document breaks lines between phrases, not inside words.
```koma
[title: Reading room rules]
[main:
# Before you sit down
Leave bags on the shelf by the door.
Phones stay silent after eight in the evening.
- Return books to the cart
- Ask at the desk for the late key
$$
t_{\text{quiet}} = 20{:}00 \text{ to } 22{:}00
$$
]
```
> Reading room rules: the heading Before you sit down, two short paragraphs, a list of two items and a displayed time range, each set apart by its own space.
## Related rules
- [Elements and text](https://komalang.org/spec/structure/#deck-model)
- [Elements](https://komalang.org/spec/elements/#element)
- [Text inside elements](https://komalang.org/spec/text/#inline-markup)
- [Definition lists](https://komalang.org/spec/text/#definition-list)
- [HTML elements and reading order](https://komalang.org/spec/semantics/#html-elements)
- [What a theme decides](https://komalang.org/spec/styles/#theme)
---
[Guide](https://komalang.org/guide/) · 3 of 8
# Columns and boxes
Let the theme lay out the page, or place a box yourself. Both stay in the text.
## Columns and a placed box
Put two `[col:` elements next to each other in the body to make columns. Give a separate box `x`, `y` and `w` to place it as percentages of the page.
```koma
[title: Night at the library]
[subtitle: Friday · 7–10 pm]
[main:
[col:
**Reading room**
A quiet place to settle in with a book.
]
[col:
**Swap table**
Leave one book and pick another.
]
]
[box .fill x=72% y=57% w=18% h=32% style="text-align: center; align-content: center":
Free entry
]
```
> Reading room and Swap table in two columns, with a Free entry box at the lower right.
## Multi-column flow
When one flow should run down a column and continue at the top of the next — as on a worksheet or handout — set CSS `columns` on the container instead of splitting by hand. Use `column-span: all` for a heading across all columns, and `break-inside: avoid` on boxes that should stay whole. See the full [Worksheet example](https://komalang.org/examples/worksheet/).
```koma
===
css: |
box.sheet {
columns: 2;
column-gap: 36px;
column-rule: 1px solid #c3c9d0;
row-gap: 16px;
}
.span { column-span: all; }
box.item { break-inside: avoid; }
===
[box .sheet:
[box .span:
# Tidepool field sheet
South Cove · low tide at 14:20
]
[box .item .outline:
**1. High shore**
Count barnacles in a 20 cm square near the dry line.
]
[box .item .outline:
**2. Mid shore**
Note limpets and dog whelks under damp ledges.
]
[box .item .outline:
**3. Lower pools**
Record water temperature $T$ and shade cover before moving on.
]
[box .item .tint:
**Reminder**
Leave turned stones face down so organisms underneath stay shaded.
]
]
```
> Field sheet titled Tidepool field sheet spanning two columns, with four numbered cards balanced across the two columns separated by a thin rule.
## Related rules
- [Placement](https://komalang.org/spec/semantics/#placement)
- [Who decides size](https://komalang.org/spec/semantics/#size)
- [Columns and rows](https://komalang.org/spec/semantics/#split)
- [Flow columns](https://komalang.org/spec/styles/#flow-columns)
- [Groups](https://komalang.org/spec/elements/#group)
---
[Guide](https://komalang.org/guide/) · 4 of 8
# Lines and curves
Join elements with lines, draw a path through points, or plot a formula.
## Join two elements
`[line from=#a to=#b arrow=end:]` joins the sides of `#a` and `#b` that face each other and follows them wherever they are drawn. `from-side` and `to-side` choose a side, and `route=elbow` turns at right angles. A class picks the head, as `.open-head` or `.dot-head`.
```koma
[title: Where the clap goes]
[subtitle: Sound, echo and what the curtain takes]
[box #clap .card x=6% y=48% w=20%:
Clap
]
[box #wall .card x=40% y=32% w=20%:
Wall
]
[box #ear .card x=74% y=48% w=20%:
Listener
]
[box #curtain .tint x=40% y=74% w=20%:
Curtain
]
[line .stealth-head from=#clap to=#wall arrow=end style="--head-size: lg":]
[box x=28% y=36% w=12% style="text-align: center":
sound
]
[line .open-head from=#wall to=#ear arrow=end:]
[box x=61% y=36% w=12% style="text-align: center":
echo
]
[line .dot-head from=#clap from-side=bottom to=#curtain to-side=left route=elbow arrow=end:]
[box x=20% y=72% w=16% style="text-align: center":
absorbed
]
```
> A slide titled “Where the clap goes”: an arrow labelled sound runs from a box, Clap, up to a box, Wall; an arrow with an open head labelled echo runs from Wall down to Listener; and a line labelled absorbed leaves the bottom of Clap, turns at a right angle and ends in a dot at a shaded box, Curtain.
## Go through points
`points=((430, 500), (760, 300), (1160, 300))` lists the points a line goes through, each `(x, y)` in logical pixels; the first and last are its ends. It goes straight from one to the next, or, with the class `.smooth`, along one smooth curve through them all.
```koma
[title: Two ways to the listener]
[subtitle: Reflected over the pillar, or around it]
[box #clap .card x=5% y=44% w=16%:
Clap
]
[box #pillar .tint x=44% y=40% w=12% h=22%:
Pillar
]
[box #ear .card x=79% y=44% w=16%:
Listener
]
[line .stealth-head points=((430, 500), (760, 300), (1160, 300), (1490, 500)) arrow=end:]
[box x=42% y=21% w=16% style="text-align: center":
reflected
]
[line .smooth points=((430, 590), (700, 800), (1220, 800), (1490, 590)) arrow=end:]
[box x=42% y=75% w=16% style="text-align: center":
around
]
```
> A slide titled “Two ways to the listener”: between a box, Clap, on the left and a box, Listener, on the right stands a shaded box, Pillar; a line with a sharp head labelled reflected goes up and over the pillar in straight pieces, and a smooth curved arrow labelled around bends below it.
## Plot a formula
`[curve f="x -> sin(x)" domain=(-pi, pi):]` draws a formula over the horizontal range from −π to π, inside the box its `x`, `y`, `w` and `h` give. Vertically, −1 is at the bottom of the box and 1 at the top unless `range=` says otherwise. Formulas used often can be named under `functions:` in the document settings.
```koma
===
functions:
rc(t): 0.5*(1-cos(2*pi*t))
drive(t): rc(t)*sin(2*pi*8*t)
===
[title: Driving the qubit]
[subtitle: A raised-cosine pulse, eight cycles]
[curve .muted x=8% y=28% w=84% h=44% f="rc(t)" style="stroke-dasharray: 12px 8px":]
[curve .muted x=8% y=28% w=84% h=44% f="-rc(t)" style="stroke-dasharray: 12px 8px":]
[curve .primary x=8% y=28% w=84% h=44% f="drive(t)" arrow=end:]
[box x=8% y=78% w=84%:
A sine under a raised-cosine envelope, $\tfrac{1}{2}(1-\cos 2\pi t)$, dashed.
]
```
> A slide titled “Driving the qubit”: a sine wave with eight cycles grows from zero and falls back to zero under a dashed raised-cosine envelope drawn above and below it, with an arrowhead at its right end, and the caption “A sine under a raised-cosine envelope, dashed.”
## Related rules
- [Curves from a formula](https://komalang.org/spec/elements/#curve)
- [Lists of values](https://komalang.org/spec/lexical/#lists)
- [The kinds of a value](https://komalang.org/spec/lexical/#value-kinds)
---
[Guide](https://komalang.org/guide/) · 5 of 8
# Pages and settings
Split the document into pages, and set a theme or a layout in a few lines.
## Start a second page
Put `+++` on a line of its own between pages. The first page needs no separator.
```koma
[title: Night at the library]
[subtitle: Friday · 7–10 pm]
+++
[title: Door to the reading room]
[subtitle: Second floor, east wing]
[main: Take the stairs beside the entrance.]
```
> Page 1: The title and time for Night at the library.
>
> Page 2: Directions to the reading room via the stairs beside the entrance.
## Set a theme or layout
Write document settings between `===` lines at the top. Page settings go between `---` lines, just after the page starts. Here they give the schedule its own section layout.
```koma
===
theme: default
===
[title: Night at the library]
[subtitle: Friday · 7–10 pm]
+++
---
layout: section
---
[title: Evening programme]
[subtitle: Two short talks, then the book swap]
```
> Page 1: The library notice uses the Default theme.
>
> Page 2: A section page titled Evening programme, with the subtitle Two short talks, then the book swap.
## Related rules
- [Page boundaries](https://komalang.org/spec/structure/#page-break)
- [Document settings](https://komalang.org/spec/structure/#deck-settings)
- [Page settings](https://komalang.org/spec/structure/#page-settings)
- [Page layouts](https://komalang.org/spec/structure/#layouts)
- [Choosing a theme](https://komalang.org/spec/styles/#theme-reference)
---
[Guide](https://komalang.org/guide/) · 6 of 8
# Figures, tables and math
Bring in pictures and data, and write math as you would in LaTeX.
## Bring in data
A figure can refer to an image file. A table can read a CSV. Paths are relative to the document’s folder.
```koma
[title: Three rooms]
[subtitle: Echo time after a balloon pop]
[main:
[col:
[figure:
[image src="assets/decay.svg" alt="Sound level falling over time in three rooms":]
Level after the balloon pop
]
]
[col:
[table src="assets/rooms.csv" widths=(2, 1, 1):
The rooms we measured
]
]
]
```
> A chart and table compare how long sound takes to fade in three rooms.
## Write math
Type a formula between `$` signs within text, or use `$$` on separate lines to give it a line of its own.
```koma
[title: Break a wave into frequencies]
[subtitle: The Fourier transform]
[main:
**Fourier transform** finds tones.[^f]
- $f(t)$ is the signal in time.
- $\hat{f}(\omega)$ is the spectrum.
$$
\hat{f}(\omega) = \frac{1}{\sqrt{2\pi}} \int_{-\infty}^{\infty} f(t)\,e^{-i\omega t}\,dt
$$
[^f]: The inverse recovers $f(t)$.
]
```
> The Fourier transform, with a bold term, two bullet points, a footnote, and a displayed equation showing a fraction and an integral.
## Choose a math face
A theme draws its math in one face. `style="--math-font: fira"` on an element draws the math inside it in another (`fira`, `stix2` or `newcm`), nested elements included.
```koma
[title: One formula, two math fonts]
[subtitle: Pick the face by where the formula sits]
[main:
[col style="--math-font: stix2":
**STIX** — for the text
$$
\omega = \Omega\cos\varphi + \alpha
$$
]
[col style="--math-font: fira":
**Fira** — for a figure
$$
\omega = \Omega\cos\varphi + \alpha
$$
]
]
```
> A slide titled “One formula, two math fonts”: on the left, labelled STIX — for the text, the formula ω = Ω cos φ + α in serif STIX letters; on the right, labelled Fira — for a figure, the same formula in sans-serif Fira letters, Greek included.
## Write chemistry
Inside math, `\ce{…}` writes formulas and reactions as the mhchem package does: numbers become subscripts (`\ce{H2O}`), a charge follows `^` (`\ce{Fe^3+}`), and `->` is the arrow of a reaction.
For ring structures like the ones below, insert an SVG image. The formulas under the rings use `\ce{…}`.
```koma
[title: One aromatic ring, two molecules]
[subtitle: Phenol has a hydroxyl group in place of one hydrogen]
[main:
[col:
[figure h=480px:
[image src="assets/benzene-ring.svg" alt="A hexagonal benzene ring with a circle inside":]
Benzene · $\ce{C6H6}$
]
]
[col:
[figure h=480px:
[image src="assets/phenol-ring.svg" alt="The same aromatic ring with one OH group bonded to a corner":]
Phenol · $\ce{C6H5OH}$
]
]
]
```
> A slide compares benzene on the left and phenol on the right. Both are drawn as a hexagon with an inner circle. Phenol has an OH group bonded to one corner. The formulas beneath are C6H6 and C6H5OH.
## Related rules
- [Inline and display math](https://komalang.org/spec/lexical/#math-delimiters)
- [Code and math are isolated](https://komalang.org/spec/lexical/#isolation)
- [Text faces](https://komalang.org/spec/styles/#text-faces)
---
[Guide](https://komalang.org/guide/) · 7 of 8
# Speaker notes
Notes for the speaker stay in the source and never reach the slide.
## Keep notes off the slide
Write speaker notes between lines of three double quotes. They stay in the source and are absent from the slide.
```koma
===
title: Why echoes fade
css: |
page.closing { background: #111; color: #eee; }
===
; Swap in the June measurements before the talk
[title: Why echoes fade]
[subtitle: What happens to a clap in an empty hall]
"""
Pop the balloon first, then show the curve.
"""
+++
---
class: closing
---
[title: Thank you]
[main: Bring a question about your own room.]
```
> Page 1: An opening slide about echoes.
>
> Page 2: A closing slide inviting questions about your own room.
## Leave parts out of speech
An app that rehearses the talk aloud reads the notes. Double brackets mark what is not read. Inside a line, write a space around a stage direction such as `[[Wait for the echo]]`; both source highlighting and the presenter view show it quietly (as `[Wait for the echo]` when presenting). For more, put `[[` and `]]` on lines of their own, at the start of the line, and indent what is between by two spaces. That block is Markdown with lists, emphasis and math, shown quietly in the source and presenter view and never read aloud: a good place for answers to likely questions.
```koma
[title: Why echoes fade]
[subtitle: What happens to a clap in an empty hall]
"""
Clap once. [[Wait for the echo]]
Each echo is weaker.
[[
If someone asks:
- *Why weaker?* Each wall keeps a little.
- Spare balloon in the left pocket.
]]
"""
```
> An opening slide about echoes; its notes hold a stage direction and a block of answers that is not read aloud.
## Related rules
- [Elements](https://komalang.org/spec/elements/#element)
---
[Guide](https://komalang.org/guide/) · 8 of 8
# Check and tidy
One command finds problems and writes the standard form.
## Check the source
`koma check talk.koma` reports problems and formatting differences, and changes nothing. Add `--write` to apply the safe fixes and write the standard form. Every problem it can report is in the [diagnostics](https://komalang.org/spec/semantics/#diagnostics); the whole command is on the [CLI](https://komalang.org/command/) page.
## Related rules
- [The standard form](https://komalang.org/spec/conformance/#standard-form)
- [Diagnostics](https://komalang.org/spec/semantics/#diagnostics)
---
# Specification
The rules of the Koma language, chapter by chapter. Each rule has a named link.
Version 0.0.0, in development. The rules come from the specification in the Koma repository; the syntax tree and the `.komadoc` package are in the [reference](https://komalang.org/reference/).
## Chapters
- [Lexical structure](https://komalang.org/spec/lexical/)Characters, line ends, delimiter lines, comments, and code and math fences.
- [Document structure](https://komalang.org/spec/structure/)Document settings, pages, page settings, page size and layouts.
- [Elements and attributes](https://komalang.org/spec/elements/)The form of an element, names and attributes, groups, callouts and curves.
- [Text and inline markup](https://komalang.org/spec/text/)Markdown and LaTeX inside elements, definition lists and footnotes.
- [Styles and themes](https://komalang.org/spec/styles/)Document CSS, looks for one layout, style classes and theme documents.
- [Semantics](https://komalang.org/spec/semantics/)Placement, size, splitting an area, the syntax tree and every diagnostic.
- [Conformance](https://komalang.org/spec/conformance/)What conforms, the conformance suite, and rendering described in prose.
To search all of it with your browser’s find, read [the specification on one page](https://komalang.org/spec/all/).
## How to read this specification
A rule is normative unless it is marked *Informative*. Normative rules define syntax and meaning, and the [conformance suite](https://komalang.org/spec/conformance/#promise) checks them. Informative rules describe how output is drawn; they are written in prose and promise no pixel-equal result.
---
[Specification](https://komalang.org/spec/) · Chapter 1 / 7
# Lexical structure
How a `.koma` file is read as characters and lines, before any element is recognised.
## Grammar
The individual rules are normative. The grammar outlines the structure. Indentation depth starts at zero, with two spaces per level. Root delimiter lines (`===`, `---`, `+++`, `:::`, `"""`) start in column 0.
```
# Document and pages
Document <- BOM? Preamble Page (PageBreak Page)*
Preamble <- BlankLine* (DocumentSettings BlankLine*)?
DocumentSettings <- DelimiterLine('=') YamlLine* DelimiterLine('=')
Page <- (BlankLine / CommentLine(0))* PageSettings? PageItem*
PageSettings <- DelimiterLine('-') YamlLine* DelimiterLine('-')
PageBreak <- DelimiterLine('+')
PageItem <- Element(0) / Notes / Memo / CommentLine(0) / BlankLine / Recovery / PageText
Notes <- '"""' (HorizontalSpace+ AttributeAssignment)* HorizontalSpace* LineEnd NoteLine* '"""' HorizontalSpace* LineEnd
Memo <- ':::' ':'* (HorizontalSpace+ AttributeAssignment)+ HorizontalSpace* LineEnd MemoLine* ':::' ':'* HorizontalSpace* LineEnd
# Elements and tags
Element(depth) <- Indent(depth) (SingleLineElement / MultiLineElement(depth))
SingleLineElement <- '[' Tag HorizontalSpace* ':' ' '? Content? ']' HorizontalSpace* LineEnd
MultiLineElement(depth) <- '[' Tag AttributeLine(depth)* TagEnd(depth) ' '? Content? LineEnd ContentLine* ElementEnd(depth)
Tag <- TagName? IdShorthand? ClassShorthand* (HorizontalSpace+ Attribute)*
AttributeLine(depth) <- HorizontalSpace* LineEnd Indent(depth + 1) Attribute (HorizontalSpace+ Attribute)*
TagEnd(depth) <- (HorizontalSpace* LineEnd Indent(depth + 1))? HorizontalSpace* ':'
# Attributes and values
Attribute <- IdShorthand / ClassShorthand / AttributeAssignment
IdShorthand <- '#' Id
ClassShorthand <- '.' ClassName
AttributeAssignment <- AttributeName '=' AttributeValue
AttributeName <- Word
AttributeValue <- QuotedString / ValueList / UnquotedScalar
QuotedString <- '"' (Escape / !('"' / '\\' / LineEnd) .)* '"'
UnquotedScalar <- (Dimension / Percentage / Number / HashValue / Word) &(HorizontalSpace / ':' / ']' / LineEnd)
Word <- [A-Za-z] [A-Za-z0-9_-]*
Number <- [+-]? (Digit+ ('.' Digit+)? / '.' Digit+) ([eE] [+-]? Digit+)?
Percentage <- Number '%'
Dimension <- Number Unit
HashValue <- '#' Id
ValueList <- '(' HorizontalSpace* (ValueListItem (HorizontalSpace* ',' HorizontalSpace* ValueListItem)*)? HorizontalSpace* ')'
ValueListItem <- QuotedString / ValueList &(HorizontalSpace* (',' / ')')) / Expression
Expression <- (Parenthesized / !(',' / ')' / '(' / '"' / LineEnd) .)+
Parenthesized <- '(' (Parenthesized / !(')' / LineEnd) .)* ')'
# Common lexical rules
DelimiterLine(c) <- c c c c* ReservedDelimiterSuffix? HorizontalSpace* LineEnd
ReservedDelimiterSuffix <- HorizontalSpace+ (!LineEnd .)+
BlankLine <- HorizontalSpace* LineEnd
CommentLine(depth) <- Indent(depth) ';' (!LineEnd .)* LineEnd
Indent(0) <- ''
Indent(depth + 1) <- ' ' Indent(depth)
HorizontalSpace <- ' ' / '\t'
LineEnd <- '\r\n' / '\n' / '\r'
# Recovery and diagnostics
Recovery <- MisplacedPageSettings / ReservedBlock
MisplacedPageSettings <- DelimiterLine('-')
# Marks a reserved block. Its full extent is described below.
ReservedBlockStart <- ':::' ':'*
```
- A `+++` in column 0 breaks the page even inside an element, code, math, CSS, YAML or notes. Recognize page breaks first and confine other structures to a page ([Page boundaries](https://komalang.org/spec/structure/#page-break)).
- `PageText` is prose written directly on a page. Each consecutive run enters the page's flow as one `[box:]` with no explicit position. A line beginning with `[` in column 0 that produces `missing-colon` or `unclosed-element` falls outside that prose ([Placement](https://komalang.org/spec/semantics/#placement)).
- An ID or class shorthand can also be joined to the tag name. Attribute lines are two spaces deeper than the opening line. The tag-ending `:` can follow the last token or stand alone at the same depth as an attribute line ([Elements](https://komalang.org/spec/elements/#element) and [Tag and content](https://komalang.org/spec/elements/#tag-and-content)).
- `ContentLine` and `ElementEnd` follow the rules for the kind of content. An ordinary multiline element closes with a `]` on its own line at the opening depth or at the end of the last content line. Comments are recognized at the start of a page or notes line or after structural indentation in an element. Code and math fences and raw element content keep them as text ([Page boundaries](https://komalang.org/spec/structure/#page-break), [Elements](https://komalang.org/spec/elements/#element), [Text inside elements](https://komalang.org/spec/text/#inline-markup) and [Code and math are isolated](#isolation)).
- `Recovery` shows the main line-based recovery cases. A `---` after content is preserved as a line. A `ReservedBlock` is isolated starting at a `:::` in column 0 that does not open a `Memo` and ending at its matching closing line or the end of the page. An unquoted attribute value with no lexical kind is preserved, and the attribute's rules determine its interpretation and diagnostic ([Document settings](https://komalang.org/spec/structure/#deck-settings), [Page settings](https://komalang.org/spec/structure/#page-settings) and [The kinds of a value](#value-kinds)).
## Characters and line ends
### Encoding and line ends
A `.koma` file is UTF-8 text. Line ends are read as LF, and the line ends that were read are kept when saving.
#### How to write
Save as UTF-8. Line ends may be LF, CRLF or CR ([Page boundaries](https://komalang.org/spec/structure/#page-break)).
#### Details
- A file with mixed line ends is saved with the most common one (LF on a tie).
- A UTF-8 file that began with a byte order mark keeps it when saved.
## Code and math fences
### Code and math are isolated
Everything inside a code or math fence is content: no element and no page starts there.
#### How to write
Fence with lines of ` ``` ` or `~~~` (four or more are fine too; a fence closes at a line of the same character, at least as many as opened it), or with lines of `$$`.
#### Example
```koma
[title: Inside a fence is content]
[main:
```
[box: this line is code, not an element]
```
]
```
> The line [box: this line is code, not an element] inside a code fence, drawn as code text rather than as an element.
#### Details
- The exception is a `+++` in column 0, which is a page break even inside a fence ([Page boundaries](https://komalang.org/spec/structure/#page-break)).
## Math delimiters
### Inline and display math
Math in text is written `$...$`, and displayed math `$$ ... $$`.
#### How to write
Math in text is `$x^2$`; displayed math is enclosed in `$$`. The delimiters of displayed math may stand on their own lines or on the formula's line (the recommended form is in [Text inside elements](https://komalang.org/spec/text/#inline-markup)).
### An escaped dollar sign
`\$` is not a math delimiter but a literal `$`.
#### How to write
To write `$` as a character, as in prices, write `\$` (`\$5`).
## Attribute values
### The kinds of a value
An attribute's value has one of seven kinds, decided by how it is written; only a value that is not a string or a list may go unquoted.
**How to write it**
| Kind | Form | Examples |
| --- | --- | --- |
| Word | a letter, then letters, digits, `-` and `_` | `end`, `elbow`, `stix2`, `fig-3` |
| Number | a CSS number (a sign, a fraction, an exponent) | `2`, `-0.5`, `.5`, `1e-3` |
| Percentage | a number and `%` | `40%`, `-5%` |
| Length | a number and a CSS unit | `240px`, `0px`, `2em` |
| `#` value | `#`, then letters, digits, `-` and `_` (as an `#id`) | `#plot`, `#2d287f`, `#図1` |
| String | always double-quoted | `"assets/fig.svg"`, `"Distance from the nest"`, `"sin(x); cos(x)"` |
| List | values apart by commas in parentheses | `(0, 40)`, `("a", "b")` |
```
[image x=10% w=240px src="assets/decay.svg" alt="How sound fades" crop=(0, 0, 10%, 0):]
[box #clap x=10% y=40% w=20%:]
[box #wall x=70% y=40% w=20%:]
[line from=#clap to=#wall arrow=end:]
```
#### Details
- A number is a CSS ``: a sign `+` or `-`, `1.5` and `.5` (`1.` is not a number), and an exponent with `e` or `E`. A dimension consists of a number and a CSS unit (lengths, angles, times, resolutions and `fr`; case does not matter). Which units an attribute takes stays as [Elements](https://komalang.org/spec/elements/#element) says (`%` and `px` for `x`, `w` and the like, `px` for a line's ends); any other CSS unit is `bad-unit`. A number with a unit CSS does not have (`3foo`) has no kind.
- A `#` value: a colour (`#` and 3, 4, 6 or 8 hexadecimal digits, as in CSS) and a reference to an element (`from=#a`) are the same `#` value as written, and the attribute decides which it is (as CSS's hash). `from=#abc` reads as a reference, never a colour.
- Only a word, a number, a percentage, a dimension or a `#` value may go unquoted. A value starting with `:`, a blank, `/` or `.`, or holding Japanese, an emoji, a URL or an expression (`drive(t)`) is a string and is quoted. An unquoted value of no kind (`src=assets/a.svg`, `alt=日本語`, `marker=⚠`, `f=drive(t)`) keeps its source, reads as a string, is reported as `invalid-unquoted-scalar` (warning) and has one fix that adds the quotes. The fix keeps what is read, so `koma check --write` and `koma format --write` make it. On a length attribute, a value of no kind is reported by `missing-unit` or `bad-unit`.
- A quoted value on an attribute of a set kind (a length; a number such as `step`, `rotate` or `weight`; a word such as `arrow`; an attribute that takes a list) reads as it does unquoted (`w="240px"`), and the formatter ([The standard form](https://komalang.org/spec/conformance/#standard-form)) takes the quotes off. On an attribute with no definition (`data-` and the like), a quoted value is kept apart as a string.
- A number written with a sign, a fraction or an exponent (`+1`, `.5`, `1e3`) on a text attribute (`label`, `id` and the like) reads as the text it was written as.
- Escapes inside a string are as in JSON (an invalid one is `bad-value`). `style="…"` stays a string of CSS declarations.
### Lists of values
Several values are written as a list: values apart by commas in parentheses.
**How to write it**
```
[curve f="x -> sin(x)" domain=(-pi, pi) range=(-1, 1):]
[table src="assets/results.csv" widths=(1, 3, 2):]
[line .smooth points=((430, 500), (760, 300), (1160, 300)):]
```
#### Details
- A list is written in parentheses only. Square brackets are never used for values, and there is no other form for a tuple.
- An item is a value of a kind (a word, a number, a percentage, a dimension, a `#` value or a string, [The kinds of a value](#value-kinds)) or a list. Blanks around a comma are free; the formatter writes `(a, b)` (one space after each comma, none inside the parentheses). An empty list `()` and a list of one item `(a)` may be written; the attribute decides whether they mean anything.
- An unquoted value starting with `(` is a list when its first parenthesis closes at its end, or never closes. A value whose parenthesis closes before its end (`(1-x)*x`, `(draft)v2`) is no list but a value of no kind ([The kinds of a value](#value-kinds)).
- An item of more than one word (`2 * pi`, `-pi`) is an expression, read only by the attributes that take expressions (`domain` and `range`). Parentheses inside an expression pair (`(0, (1 + 2) * pi)`). An expression on any other attribute is `bad-value`.
- An item of `crop` is a percentage from 0, or `0`; an item of `widths` is a number above 0 (both written as CSS numbers).
- Each attribute takes its own number of items; another number is reported as `bad-value`, the attribute has no effect and the source is kept: `crop` takes 4 (top, right, bottom, left, in the order of CSS `inset()`), `domain` and `range` 2, `points` two or more lists of two numbers (`points=((0, 0), (100, 50))`), `widths` one or more (as many as the table has columns).
- A trailing comma (`(a, b,)`), an empty item (`(a, , b)`) and a parenthesis left open are reported as `bad-value`; the attribute has no effect and the source is kept. A list left open ends at a `:` or `]` outside quotes, or at a blank before the next `key=`, so the attributes after it are read as their own. Neither the app nor MCP `setAttributes` rewrites a tag holding a list left open.
- The `:` that ends a tag is the first `:` outside quotes and lists (a `:` or `]` in a string inside a list is the value's). A list does not run across lines.
- The attributes that take a list: `crop=(top, right, bottom, left)`, `widths=(…)`, `domain=(left, right)`, `range=(bottom, top)`, `points=((x, y), …)` (pairs of unitless logical px).
- There are no dictionaries (`{…}`). Pairs of a name and a value are attributes, and nesting is written with child elements. A `{` at the start of an attribute's value is reserved and is `bad-value` unquoted.
---
[Specification](https://komalang.org/spec/) · Chapter 2 / 7
# Document structure
A document is document settings followed by pages. Each line that separates them has one job.
## Document and pages
### Elements and text
A document is made of elements placed on its pages and the text inside them. The specification keeps the names for what is written (the source) apart from the names for what is read (the core).
#### How to write
An element is written in square brackets, `[tag attr: content]`, with text in Markdown and LaTeX inside.
#### Details
- Source: the whole bracketed block `[tag attr: content]` is a Koma element, or simply an element. The leading name (such as `title` or `col`) is the tag name. Markdown and LaTeX may be written inside an element. This is not HTML's tag syntax.
- Core: the tree that reading produces. Its `Node` is a general node that also stands for pages, notes and the like; it is not the same idea as an element in the source. The core's code uses names that fit each responsibility and does not call every general node an element. A generated area or a drawn rectangle is not, by itself, an element written in the source. Drawing, export and the GUI use the core.
- The theme decides the look and the default positions and sizes of the layouts. Positions and sizes written in the document take precedence over those defaults ([Who decides size](https://komalang.org/spec/semantics/#size)).
### Document settings
Document settings apply to the whole document and are written as YAML between `===` lines at the top of the file.
#### How to write
Put a `===` line at the top of the file, write `title`, `type`, `size`, `theme` and the like in YAML, and close with another `===` line. Page settings are written separately, in each page's `---` block ([Page settings](#page-settings)).
```
===
title: Talk
size: 16:9
===
---
layout: cover
---
[title: Why echoes]
+++
[title: Next]
```
#### Details
- Document settings belong to no page. Reordering, duplicating or deleting pages leaves them at the top, comments and unknown keys included.
- `title`, `type`, `size`, `theme` and the like apply to the whole document. `type` is the document kind (`slide`, `article`, `poster`, [Kinds of page](#page-kind)) and `size` the page size ([Page size](#page-size)); the two are independent. The rules for each value follow [Page settings](#page-settings) and [Settings YAML](#settings-yaml).
- Editing settings keeps unknown information, quoting, comments and line breaks. Unclosed YAML keeps its source and is reported as `unclosed-settings`; its content is never read as elements instead.
- No `#lang` declaration is needed. Document settings and page settings may each be left out; content without an opening marker is the first page.
A document declares no language version. The document setting key `koma` is reserved: written in document or page settings, it is reported as `reserved-setting` and sets nothing.
## Page breaks and comments
### Page boundaries
A page break is a line of three or more `+` in column 0, separating one page from the next.
#### How to write
After a page, write a line of `+++` alone, starting at the beginning of the line. None is needed before the first page.
#### Example
```koma
[title: A night at the library]
[main: Friday, 7–10 pm]
+++
[title: Finding the room]
[main: Take the stairs beside the entrance.]
```
> Page 1: Page 1: the title A night at the library and its time.
>
> Page 2: Page 2: the title Finding the room and directions up the stairs.
#### Details
- A line of three or more `+` in column 0, followed by the end of the line or a space, is a page break. It opens nothing, and the next page starts with a fresh reading state. Even inside an element, code, math, CSS, YAML or notes, it is a boundary in column 0, and a structure left unclosed is not carried to the next page. An indented mark stays in the body.
- Each delimiter has one role: `===` document settings ([Document settings](#deck-settings)), `---` page settings ([Page settings](#page-settings)), `+++` a page break. `---` is never a horizontal rule; a horizontal rule is `***` (`___` is read too, [Text inside elements](https://komalang.org/spec/text/#inline-markup)).
- `===`, `---` and `+++` are delimiters with three or more characters in column 0. The count has no meaning and is kept as written when editing. Nothing is reported for the count; only explicit tidying makes it three ([The standard form](https://komalang.org/spec/conformance/#standard-form)).
- What follows a delimiter is reserved for attributes added later. Any character other than trailing spaces keeps its source, is reported as `delimiter-text-reserved`, and means nothing. A `+++` with text still works as a recovery point.
- The first page needs no leading `+++`. Consecutive boundaries make empty pages. Trailing spaces, a byte order mark, line ends and source outside the language are kept.
- **Comments**: from a `;` at the start of a line to the line's end is a comment for yourself, neither shown nor exported, and kept in the source. It is a comment directly on a page, inside an element, in bare text and in notes. Inside an element, a `;` after the structural indentation (up to depth × two spaces) starts a comment. Inside code and math fences, the bodies of `[code:]`, `[math:]` and `[diagram:]`, settings YAML (whose comments are `#`) and CSS, it does not. A `;` in the middle of a line and a full-width `;` are text. To start a line with a literal `;`, write `\;` (`\;` draws `;` in the middle of a line too). A comment at the root is not guessed to belong to a page, and a move, deletion or duplication whose owner is unclear is not applied.
- The standard form is `; comment` (one space after the `;`). `;comment` without the space is read as a comment too. The app and the examples write the standard form. Ordinary saving keeps what was written; only explicit tidying ([The standard form](https://komalang.org/spec/conformance/#standard-form)) adds the space. A `;` line with nothing after it, and a line of several `;` such as `;;`, get no space. `//` is ordinary text, not a comment.
## Page settings and YAML
### Page settings
Page settings apply to one page and are written as YAML between `---` lines in the page's preamble.
#### How to write
At the start of a page (after `+++`, or after the document settings on the first page), put a `---` line, write `layout` and the like in YAML, and close with another `---` line. A blank line may stand between `+++` and the settings.
#### Example
```koma
===
theme: default
===
[title: A night at the library]
+++
---
layout: section
---
[title: Evening programme]
```
> Page 1: Page 1: an ordinary page titled A night at the library.
>
> Page 2: Page 2: Evening programme, set to the section opener layout by its page settings.
#### Details
- `---` always opens settings; whether what follows is settings or body is never guessed from the next line. A `---` in column 0 inside settings always closes them, even inside an unclosed YAML quote, `[` or `{` (the unclosed value is `bad-yaml`, and the block is kept, [Settings YAML](#settings-yaml)).
- The preamble is the part after `+++` (after the document settings on the first page) and before the page's elements and text start. Tidying puts one blank line between `+++` and the settings ([The standard form](https://komalang.org/spec/conformance/#standard-form)). Blank lines and comments do not end the preamble. The first page needs no `+++`. Page settings are independent of the document's `===` settings.
- A `---` in column 0 written after a page's elements or text is not settings: that one line is reported as `misplaced-settings` (error) and not shown. The lines after it are not isolated; they read as if the line were not there. Two fixes are offered, and neither is chosen automatically: `***` for a horizontal rule, `+++` for a page break. The message adds “a page break is `+++`”.
- When the preamble's `---` does not close (`unclosed-settings`) or its YAML cannot be read (`bad-yaml`), the message also adds “a page break is `+++`”. When unreadable settings YAML has a value containing `:`, it adds that the value should be quoted. When document-wide settings (`title`, `size` and the like) are written in the first page's `---`, it adds that document settings go in `===`.
- A page may set `layout`, `id`, `class`, `paginate`, `skip`, `logo`, `logo-alt`, `lang`, `duration` ([Planned speaking time](#planned-time)), and `style` for the line around the page's edge ([Page-edge lines](https://komalang.org/spec/styles/#page-edges)). `title`, `type` and `size` belong to the document only. Unknown or unsupported settings are kept and reported.
- Editing keeps the rest of the source, and never drops comments or unknown information. Page settings move with their page; document settings (with their `css:`) stay at the top.
### Settings YAML
Document and page settings are read as YAML 1.2 Core, and each setting's value is checked for its type.
#### How to write
`title`, `theme`, `layout` and the like are strings; `paginate` and `skip` are booleans. To write `true` or a number as a string, quote it. A YAML comment is `#`; `;` is not a comment inside YAML.
```
===
title: "2024"
theme: default
===
---
layout: section
paginate: false
---
[title: Evening programme]
```
#### Details
- The document's and the theme's `functions` map function heads to expressions ([Curves from a formula](https://komalang.org/spec/elements/#curve)).
- Strings, quoting, multi-line values, maps and lists are read as YAML means them; unknown settings keep their source and are reported. A theme's `tags` follow their schema, and custom tags are never guessed from sample elements. A theme's layout frames are defined not in YAML but by sample elements with positions and sizes ([Frames from sample elements](https://komalang.org/spec/styles/#theme-frames)). `slots:` is not read as a setting.
- Invalid syntax and duplicate keys leave the whole block unapplied, are reported, and keep their source. Circular references and oversized alias expansion are refused. No YAML tag is ever run as code.
## Planned time
### Planned speaking time
Planned times are settings for how long to speak on a page (`duration:`) and in the whole talk (`total-duration:`).
#### How to write
Write `duration:` in page settings (`---`) and `total-duration:` in document settings (`===`). Both take minutes and seconds as `m:ss` (`1:03`, `20:00`; up to three digits of minutes, and two digits of seconds up to 59). In YAML 1.2, `1:03` is a string, so no quotes are needed.
```
===
title: Talk
total-duration: 20:00
===
---
duration: 1:03
---
[title: Why echoes fade]
```
#### Details
- `duration` may be written only on pages, `total-duration` only on the document. Written in the other block, it is reported as `setting-out-of-scope` ([Page settings](#page-settings)).
- A value of another form (`2m`, `1:75`, an unquoted number such as `90`) is reported as `bad-value` (warning), with how to write it (as `duration: 1:30`). The page (for `total-duration`, the document) is treated as having no plan, and the source stays as written.
- Without `total-duration`, the plan for the whole talk is the sum of the `duration` of the pages that have one. A page with `skip: true` is not presented, so its `duration` is left out of the sum and out of the presenter view's counting. Pages without a plan are left out of the sum.
- The key for a page's plan is `duration:`. A page's `time:` is not read as a plan: like any unknown key it is reported as `unknown-setting` (warning) and is not a plan. No fix or rewrite by tidying is offered, and the GUI does not rewrite it. A document's `time:` is `unknown-setting` too.
- Notes ([Elements](https://komalang.org/spec/elements/#element)) are text for people, not read as times. When a page has no `duration` and the first line of its notes (not counting blank lines and `;` lines) has the form of `m:ss` joined by `+` and ending in `= m:ss` (`0:59 + 0:04 = 1:03`), or is a bare `m:ss`, it is reported as `notes-time` (note), with one fix that moves that line to `duration:` in the page settings. The value moved is the one right of `=` (read as this page's time), or else the sum. If the page has no settings block, one is made; notes left with nothing else are removed with it. Nothing is rewritten automatically (choose the fix in the GUI, run `koma check --write --unsafe`, or fix it by hand; the fix may change the meaning).
- How the presenter view shows it is the presenter view’s rules. HTML and PDF do not show it.
### Page transitions
A page's `transition` determines how it comes into view. Use `none`, `fade`, or `push` in the document or page settings. A page setting overrides the document setting. The default is `none`.
A forward turn to an adjacent page takes the arriving page's effect. Going back reverses the same boundary. A push enters from the right when going forward and from the left when going back. Non-adjacent turns, direct number entry, Home, End, and starting a presentation show the page immediately. Skipped pages are left out of the sequence. An invalid value is reported as `bad-value` and uses the inherited value. Articles and posters retain the setting with a `type-unused-feature` note.
## Page size and coordinates
### Page size
The size of the pages is chosen with `size` in the document settings. The size decides only the pages' dimensions and the PDF's paper size.
#### How to write
Write `size: 4:3`, `size: A4`, `size: A4 landscape` or `size: 1080 x 1920` in the document settings. Without it, `16:9`.
```
===
type: article
size: A4
===
```
#### Example
```koma
===
size: 4:3
===
[title: A 4:3 page]
[box .card x=10% y=40% w=80%:
1440 by 1080 logical px.
]
```
> A page in the ratio 4 across to 3 down, with the title A 4:3 page and a card giving its size in logical px.
#### Details
- Screen ratios: `16:9` (1920×1080), `4:3` (1440×1080).
- Paper sizes: `A5`, `A4`, `A3`, `A2`, `A1`, `A0`, `B5`, `B4`, `letter`. An orientation may follow, as in `A4 landscape`; portrait is the default.
- Dimensions written directly: `1189mm x 841mm`, `1080 x 1920` (logical px without a unit).
- `aspect: 4:3` of other settings problems means the same as `size: 4:3`.
- The size never decides the kind ([Kinds of page](#page-kind)): any kind takes any size. For example: slides at 16:9 (no `size`), slides on A4 landscape (`size: A4 landscape`, a lecture handout to print), a portrait A4 document (`type: article`, `size: A4`), a 4:3 document read on screen (`type: article`, `size: 4:3`), a portrait A0 poster (`type: poster`, `size: A0`), a poster for an upright screen (`type: poster`, `size: 1080 x 1920`).
### Paper in logical pixels
Paper sizes are converted to logical px at 96 logical px to the inch (the same as CSS px).
#### How to write
On paper pages too, an element's `x`, `y`, `w`, `h` are written in these logical px (the coordinate system of [Coordinates](#coordinates), extended to the page's size). For example, portrait A4 is 794×1123, and portrait A0 is 3179×4494.
### Kinds of page
The document kind (slide, article or poster) is chosen with `type` in the document settings. Without it, the document is slides. The kind decides how the document is used.
#### How to write
Write one of `type: slide`, `type: article` or `type: poster` in the document settings. Without it, `slide`. It can be written in the document settings only, not in a page's settings (`---`). The retired `kind:` key is unknown. Use `type: article` for an article.
```
===
title: Field notes
type: article
size: A4
===
```
#### Details
- The kind is never inferred from the size ([Page size](#page-size)). A document without `type` is slides whatever its `size`, so existing documents read as before.
- A value it does not read (`type: slides`, `type: report`) is drawn as slides and reported as `bad-value` (a warning); the source stays as written. `type` in a page's settings is `setting-out-of-scope`.
- Slides are shown one page at a time and presented, with the presenter view, speaker notes, animation, skipped pages (`skip`) and planned times (`duration`, `total-duration`). An article is read page after page, from the top. A poster is one large page looked at by zooming and moving; it is usually one page, but may have more.
- The kind does not change the notation (elements, attributes, layouts, the document's CSS), the page size, or the formats a document exports to. In an article or a poster, speaker notes, animation, `skip` and `duration` stay in the source and are kept through reading and saving; they are only not used.
- `paginate` defaults to off for slides and posters and on for articles; `paginate` written in the document or a page decides ([Page settings](#page-settings)).
- Notes (the lightest level; exit code 0): `type-not-set` when there is no `type` and the `size` is paper ("this document is drawn as slides; write `type: article` for a document, `type: poster` for a poster"). With `type: slide` written, nothing is said (slides on A4 landscape, for example). `type-unused-feature` on each line where a document or a poster has speaker notes, animation (`step`), `skip`, `duration` or `total-duration`.
### An unreadable size
An unreadable `size` is drawn as the default `16:9` and reported as a problem of the document settings.
#### How to write
Write a value of [Page size](#page-size) in `size`.
#### Details
- An unreadable one (such as `size: huge`) is treated as in other settings problems.
### Coordinates
The coordinate system is logical px with its origin at the page's top left; the default slide page is 1920×1080 ([Page size](#page-size)).
#### How to write
Lengths written in `px` (`x=96px`, `w=480px`) and a line's ends `x1`, `y1`, `x2`, `y2` are logical px of this system (positions are measured from the parent, [Elements](https://komalang.org/spec/elements/#element)). When the page size changes, it becomes the logical px of that size ([Page size](#page-size), [Paper in logical pixels](#paper-units)).
## Layouts
The kinds of `.koma` page, and the default position and size of the generated areas (logo, footnotes, page number, footer, cover fields). The numbers are tuning values of the layout, neither notation nor rules of the language. A theme decides only the look, and a position and size written in the document take precedence ([Who decides size](https://komalang.org/spec/semantics/#size)).
### Page layouts
A page layout is the pattern of what goes where on a page, chosen with `layout:` in the page settings. It is never guessed from the content.
#### How to write
Write `layout: cover` and the like in page settings. There are four basic layouts: the cover (`cover`), the section opener (`section`), the ordinary page (`content`) and the page with no frames (`blank`). Without it, `content`. Written in the document settings, it is the default for every page.
#### Example
```koma
---
layout: cover
---
[label: Night at the library · 2]
[title: The book swap]
[subtitle: Leave one book, take another]
[authors: Mira Okafor]
[affiliations: Central Library]
[date: Friday, 7 pm]
```
> A page in the cover layout: a label, the title The book swap, a subtitle, and under them the author, affiliation and date stacked in order.
#### Details
- `blank` is a layout that only has no frames; it is treated like any other. The logo and `paginate` work as on other layouts (to hide the logo, `logo: none`), and content is placed freely with `x` and `y`. A frame's tag (`title`, `main` and so on) written there is reported as `slot-not-in-layout`, as for a tag with no frame on any other layout.
- A theme document may add named layouts ([Frames from sample elements](https://komalang.org/spec/styles/#theme-frames)). A table of contents is written as the content of an ordinary page.
- The cover's frames are the six `label`, `title`, `subtitle`, `authors`, `affiliations` and `date`; there is no `main` frame (a `[main:]` on a cover is reported as `slot-not-in-layout`, like any tag with no frame). The cover stacks the subtitle under the title, then the authors, affiliations and date under it, only those written, in order (no space is kept for what is not written; each has a set height, and adding lines in one never moves the others).
- An ordinary page's subtitle has room for one short sentence on one line by default. There is no variant for a two-line subtitle. Two-line text itself is not forbidden, and no text is cut. A page that needs more stays an ordinary `content` page, and the author adjusts the subtitle's height and the body's position and height with explicit positions and sizes. Subtitles and labels (`label`) are never shrunk to fit; `koma check --layout` reports when they do not fit. Unless explicit positions and sizes change, pages of the same layout start their body at the same place whatever their headings hold.
- Columns and rows of content are written with `[col:]` and `[row:]` in the body ([Columns and rows](https://komalang.org/spec/semantics/#split)). A theme may also define default placements for them. The official four themes have only five layouts: the basic four and `outline` for a table of contents. Two columns, a figure with its explanation, three side by side and a summary are made with `[col:]` and `[row:]` in a `content` body; no layouts are added for them.
- An unknown name is not accepted as an alias: it is reported as `unknown-layout`. The preview uses the `content` placement, but the written settings and body are kept, and tidying alone never replaces them.
- Posters are outside this rule.
### The document's logo
A logo is an image written in the document or page settings, drawn in the top right place the layout sets aside.
#### How to write
Write `logo` (the image's path, relative inside the document's folder) and `logo-alt` (its alternative text) in settings. In the document block they are every page's default; in a page block they apply to that page only ([Page settings](#page-settings)). To leave it off a page, `logo: none`.
#### Details
- Written nowhere, there is no logo, and no empty place is left. There is no notation for its position.
- Not written, `none` and an empty string are read as different things (not mixed up as truthiness).
- The alternative text goes with `logo` as a pair. A page that replaces the image does not inherit the document's `logo-alt`. A page may rewrite only the `logo-alt` of an image it inherits. An image in effect without alternative text is reported as `missing-logo-alt` (warning) and is not taken as decorative. Only `logo-alt: ""` makes it decorative; nothing is guessed from the file name or the document's name. A `logo-alt` written with no image in effect is `setting-not-applied` (warning).
- The layout decides the place, and the theme only the look ([Who decides size](https://komalang.org/spec/semantics/#size)). The cover, section opener and ordinary page all use the same top right place. On a page with a logo, the layout first takes that place and the gap, and sets the default width of label, title and subtitle to its left. Nothing overlaps. The widths are tuning values of the layout, neither notation nor rules of the language (the values: the logo at 80% from the left and 3% from the top, 15% wide and 10% high, with a 3% gap; headings that would meet it end at 77% from the left; an ordinary page's label and title are 72% wide).
- A layout never hides the logo implicitly; hiding it is written as `logo: none`.
- Elements with their own positions are never rewritten to avoid the logo. Overlaps and overflow are reported by `koma check --layout`.
- The image fits its place keeping its aspect ratio (never cut or stretched), aligned to the top right. Slides do not change colour with the app's light or dark mode, so there are no separate light and dark images.
- Over the page's bands ([Layout grids](https://komalang.org/spec/styles/#layout-grid)): the logo is placed at its corner from the page's top left, as an element with `x` and `y` is; it is not drawn in the header band and takes none of its height.
- Meaning: the logo is generated, owned by the document or page settings. In HTML it sits in the page's heading area, outside `hgroup` (which cannot hold the logo's image). No free element is made.
- The image uses the same lookup, sanitising and bundling into exports as other images. No outside image service or new permission is used. A missing image is reported by `koma check`, like other images, and export stops, naming the page.
### Footnotes and the page number
Footnotes ([Footnotes](https://komalang.org/spec/text/#footnote)) are gathered in the page's footer band ([The bottom band](https://komalang.org/spec/styles/#bottom-band)), 5% from the page's left edge, in the order their definitions are written. Their width is what remains after the left 5%, the common physical margin used by the page number at the lower right, the actual `current / total` and a 1em gap. A page without a number uses the full width.
The page number `current / total` at the lower right stands right of the body's right edge, with the same margin in logical px from the right and bottom edges: the common `--koma-counter-margin`, by default 3% of the page height (32.4 px on 1920×1080).
The baseline of the footnotes' last line aligns with the page number's baseline, and more lines grow upward, the body above giving up as much room. Footnotes sit at the bottom even on a page without a number. Short items stand side by side and wrap between items; a long item wraps inside, never separating its mark from its first word.
### The footer and footnotes
`[footer: sources and the like]` is an element directly on any page, selected, moved, resized and edited like any other. It is never added automatically to a new page. Its default frame, the same on every layout, is one line at 5% from the left, 68% wide (89.5% from the top, 7.5% high). A footer frame declared by the theme is used if there is one. A footer with no position or height written stands in the footer band at the frame's left edge and width ([Frames from sample elements](https://komalang.org/spec/styles/#theme-frames), [The bottom band](https://komalang.org/spec/styles/#bottom-band)): the bottom of its last line's text sits on the page number's line, 3% above the page's bottom, and more lines grow upward at the same size, the body above giving up as much room, up to the band's `max-height` (one third of the page inside its padding unless the theme sets it); beyond that the text shrinks (down to half), and if it still does not fit, this is reported. A footer with `y` or `h` written keeps that position and height, from the page's top left; with `h`, the height is fixed and the text shrinks to fit.
The page's footnotes follow the first explicit footer's content after a 0.5em gap, and move with it. In the footer band, the last line including the footnotes sits on the page number's line and the footer moves up by that much; a footer placed with `y` or `h` leaves its footnotes in the band. The footer and the generated footnotes are separate areas: editing the footer never mixes in footnotes, and footnote definitions and the page's text are never moved or copied. Several footers are not joined; they stay separate and are reported as `duplicate-slot`. A nested footer, or a box merely given `role=footer`, is never where footnotes go.
Without a footer, footnotes stand alone in the footer band. The page number stands at the lower right whatever the footer does. The editor, HTML, PDF and PowerPoint use the same placement; overflow off the page is reported by the layout check.
### Authors and affiliations on the cover
On the cover, the authors and affiliations stand close together as one group, with a small break before the date. By default the authors are 5% of the page high, the affiliations 6.5% (room for two lines) and the date 4.5%, with a 1% gap before the date when authors or affiliations precede it. Fields not written leave no height, and a date with nothing before it has no gap. Coordinates and sizes written for a field take precedence; the source, title, subtitle and text look are not changed.
---
[Specification](https://komalang.org/spec/) · Chapter 3 / 7
# Elements and attributes
Everything placed on a page is an element in square brackets: a tag, a colon, and the content.
## The form of an element
### Elements
A Koma element (below, simply an element) is something placed on a page, written in square brackets.
#### How to write
Write `[tag: content]`. Separate the tag name and attributes with spaces and follow the tag with `:`. Write attributes as `key=value` or with the shorthands `#id` and `.class`. When the content runs over several lines, open with a `[tag:` line and usually close with a line of `]` alone at the opening's depth. Elements written inside are indented two spaces deeper per level.
```
[title: a one-line element]
[box #memo .card x=10% y=50% w=40%:
a multi-line element
[box .tint: a nested element]
]
```
#### Example
```koma
[title: Night at the library]
[box .card x=6% y=30% w=36%:
The reading room is upstairs.
Read in quiet.
]
[shape .primary x=60% y=28% w=10% h=18% type=ellipse:]
[line x1=860px y1=400px x2=1120px y2=400px arrow=end:]
[math x=52% y=66% w=36%:
19{:}00 + 3\,\mathrm{h} = 22{:}00
]
```
> The title Night at the library. A card about the reading room on the left, an arrow from it to a circle on the right, and the formula 19:00 + 3 h = 22:00 below.
#### Details
- **One-line form**: `[tag: content]`. The whole line is in brackets, and the brackets match.
- **Multi-line form**: it starts with `[tag:` and runs to its closing `]`. The tag ends with `:`, and may be split over several lines ([Tag and content](#tag-and-content)). The body may start right after the colon or on the next line. At most one space right after the colon on the opening line is a separator; anything after it is body. On later lines, up to depth × two spaces are structural; tidying adds what is missing, and more is kept as body. The closing `]` may stand on its own line or end the body's last line. Matching brackets in the body, Markdown links, images and footnotes, an escaped `\]`, and brackets in inline code, math or fences do not close. To write an unmatched `]` at a line end as text, write `\]`. An opening line without `:` is not an element ([When brackets are an element](#element-recognition)). A `:` inside quotes is part of the value. An unclosed element keeps its source and a diagnostic.
- **Tag**: the standard form is `name #id .class .class key=value…`, ending with `:`. A tag holds a name and attributes, written as `#id`, `.class` or `key=value`. The name, `#id` and classes may each be left out (without a name, `box`). The joined form (`box#id.card`) is read too. Newly inserted elements, examples and explicit tidying use the standard form; ordinary saving and dragging keep the form that was written.
- **Attribute values**: in the `key=value` form, the right-hand side is the attribute value. A value's kind (a word, a number, a percentage, a dimension, a value starting with `#`, a string or a list) follows from how it is written, and only a value of a kind may go unquoted ([The kinds of a value](https://komalang.org/spec/lexical/#value-kinds)). Several values are written as a list in parentheses, `(a, b)` ([Lists of values](https://komalang.org/spec/lexical/#lists)). For lengths, `weight`, `step` and `rotate`, quoting does not change the meaning. For undefined attributes, a quoted number or value with a unit is kept apart as a string. The formatter leaves quotes out only for a value of a kind, when syntax and the value's type and meaning are kept. Inside a double-quoted value, quotes, backslashes and the like are escaped as in JSON. An invalid escape is reported as `bad-value`, the value is not applied, and the source is kept. In a correctly double-quoted string, `[` and `]` are characters of the value and are not counted as brackets of an element or its body.
- **Lengths and units**: a length attribute carries a unit: `x` and `w` as `%` of the parent's width, `y` and `h` as `%` of its height, or logical pixels `px` (`x=10% w=40%`, `w=240px`). A line's ends `x1`, `y1`, `x2`, `y2` take only `px`. `0` may omit its unit. A number without a unit is reported as `missing-unit`, an unaccepted unit (`mm`, `%` for a line's ends, …) as `bad-unit`, and the attribute has no effect (the source stays as written, and the bracket is still an element even when the value has no effect). `x` and `y` may be negative. `w=0` and `h=0` are reported as `zero-size`.
- **Parent**: the parent that positions and sizes are measured against is the whole page directly on a page, or else the parent element's content rectangle (inside padding and border). Moving an element into or out of another in the GUI also rewrites its position against the parent's content rectangle as drawn, so it does not move on the page (`px` stays `px`). Writing back keeps the value's unit (`px` stays `px`, `%` stays `%`); new values are `%` to one decimal place. Only an explicit action changes the unit.
- **Text direction**: the direction of text is the attribute `dir`: `dir=rtl` (right to left) or `dir=ltr` (left to right, the default). Other values are reported as `bad-value` and have no effect.
- **Unquoted words**: a word without `=` in a tag (like `rtl` in `[box rtl: …]`) is not in the grammar: its source is kept as written, it has no effect, and each is reported as `bare-word` (warning). `rtl` is a bare word too, with no fix offered. A bare word is read as a word of the tag only when the name is a known tag name ([Kinds of name](#names)) or the tag has an `#id` or class, and only before the `:`. Other bracketed lines (`[see figure: 3]`) stay text ([When brackets are an element](#element-recognition)).
- **Nesting and indentation**: elements may nest. Openings, one-line elements and standalone closing lines start at the beginning of the line or after the current depth × two spaces; a standalone closing line aligns with the depth of the parent it closes. In a multi-line body, up to the element's depth × two leading spaces are structural and more are kept as body. Explicit tidying adds only the structural spaces a line lacks. Tabs do not count as structural space. To write a bracketed line that is reserved at that position in a deep nest as text, escape it with a backslash or put it in a code fence. Code and math fences and their content are read as Markdown after the same structural indentation is removed, keeping any extra indentation. Notes at the root have no structural indentation and keep their source.
- **The same attribute twice**: when the same attribute is written twice (`#a` and `id=b`, `.red` and `class=blue`, `x=1% x=2%`), none is removed and `duplicate-attribute` (warning) is reported. The first one takes effect, and the tag's `#id` and `.class` count before `id=` and `class=` wherever they stand. Changing the value rewrites the one in effect, in its own form (`#a` to `#c`). Removing removes every occurrence, so no other value starts to take effect. A new ID or class is written in the tag as a standalone `#id` or `.class`, unless reading it back would not give the same value (it contains `.` or a space, or is empty): then it is written `id="…"` or `class="…"`, and the `#id` or `.class` that would take precedence is removed, so the written value takes effect. An empty value is written as a value; only no value (null) removes. The app (the format panel) and MCP `setAttributes` write with the same writer (`setAttrs`).
- **Attributes and looks**: attributes say what an element is and where it goes (`x`, `y`, `w`, `h`, `rotate`, a line's ends and `arrow`, `marker`, `#id` and `id=`, `.class` and `class=`, and so on). The look is said by classes and `style`, each in one way. Looks layer as theme, class, then `style`, the later winning. A look written as an attribute (`gap=`, `opacity=`, `color=`, `fill=`, `stroke=` and the like) has no effect, keeps its source as written, is reported as `presentation-attribute` (warning), and when `style` can read the value, one fix moves it there. The app (the format panel, inserting), MCP `setAttributes` and `koma format` never write a look as an attribute.
- **The language's attributes and the user's**: an attribute whose name has no prefix belongs to the language. Users who want attributes of their own add `data-` (`[box data-source=fig3: …]`). A `data-` attribute stays in the source, has no effect, and is not reported. An unprefixed attribute the language does not have (other than the name of a look) has no effect, keeps its source as written, and is reported as `unknown-attribute` (warning). Reordering ([Order of attributes](#attribute-order)) puts it after the language's attributes. A line runs from end to end, so `h` has no effect on it and is reported as `line-no-height` (warning).
- **Look classes**: styles ([Named styles](https://komalang.org/spec/styles/#style-classes)) are classes: `[box.tint: …]`, `[box.fill: …]`, `[box.outline: …]`, `[box.bar: …]`, `[box.card: …]`. Callouts and shapes take the same classes. The look classes (`tint`, `fill`, `outline`, `bar`, `card`) are drawn by the theme. No class changes content, placement or reading order. A class whose name is not in the theme stays in the source, for the theme's or the document's CSS to draw. To split across or down, write `[col:]` and `[row:]` ([Columns and rows](https://komalang.org/spec/semantics/#split)).
- **`style`**: `style="color: red; border-width: 2px"` holds CSS declarations for that element; placement is decided by `x`, `y`, `w`, `h`. These declarations of appearance may be used: `align-content`, `background-color`, `border-color`, `border-style`, `border-width`, the per-side lines `border-top`, `border-right`, `border-bottom`, `border-left` with their `-width`, `-color` and `-style` (for example `style="border-bottom: 2px solid #2d287f"`), `border-radius`, `box-shadow`, `color`, `font-family`, `font-size`, `font-style`, `font-weight`, `gap` (between split areas, [Columns and rows](https://komalang.org/spec/semantics/#split); in an element without a split, between its direct children, [Cards without positions](https://komalang.org/spec/semantics/#cards)), `letter-spacing`, `line-height`, `opacity`, `padding` and the per-side `padding-top`, `padding-right`, `padding-bottom`, `padding-left` (a length or percentage like one side of `padding`; other values are `bad-value`; with `padding`, the one written later wins, as in `style="padding: 8px; padding-left: 32px"`), `stroke-dasharray` and `stroke-width` (a line's dashes and width), `text-align`, `text-decoration-line` (strike-through of the whole element), `text-spacing-trim` (the space of full-width brackets at line ends; CSS Text 4 values, [Brackets at line ends](https://komalang.org/spec/styles/#bracket-spacing)), the arrow-head variables `--head-start` and `--head-end` (`triangle`, `stealth`, `open`, `dot`, `diamond`) and `--head-size`, `--head-start-size`, `--head-end-size` (`sm`, `md`, `lg`), and the face of the math inside, `--math-font` (`fira`, `stix2`, `newcm`), where the innermost wins. Other values of these variables are `bad-value`. Values that load outside resources and unsupported declarations are not applied, give a warning, and keep their source. A theme's shared CSS and ordinary `var()` work too. Precedence follows the ordinary CSS cascade.
- Per-side lines: no new attribute or class is added; they are written with their CSS names in `style`. A theme's CSS can hold the same declarations (`title { border-bottom: 2px solid #2d287f; }`). HTML and PDF draw them as the browser does. A side line takes inner space like a full border, as on an element with a surface ([Named styles](https://komalang.org/spec/styles/#style-classes)). PowerPoint writes four sides of the same width and colour as the shape's outline, a left side alone as a left band, and otherwise each side as a thin rectangle filled at the line's width along the inside of the frame (rotated with the element). Sides that are not solid (dashed, dotted, double and so on) are reported before export, which stops. On a rounded element, side lines are straight bands without the rounding. The `border` shorthand is not supported.
- **Rotation**: an element on a page that has no child elements and is not the footer can be rotated in degrees, as `[box x=10% y=20% rotate=30: Example]`; quoting does not change the meaning. Rotating the footer, a nested element or an element with children is not supported: the source is kept, reported, and not applied when drawing. HTML, PDF and the PowerPoint output that supports it show the rotation.
- **Steps**: the common attribute `step` ([Steps](#step)): `[box step=1: text]`, `[col step=2: text]`, `[row step=2: text]`. Only a safe integer of 1 or more is valid; an invalid value is reported as a `bad-value` warning, keeps its source, and is ignored as a step. A nested element's step is the largest of its own and its ancestors'; a child without one inherits its parent's. There is no attribute syntax for a standalone Markdown paragraph.
- **Shapes and lines**: a rectangle or an ellipse is written `shape` with `type=rect|ellipse` and `x`, `y`, `w`, `h`; a rectangle's rounded corners are `radius` ([Shapes](#shape)). A freely placed line is written `line` with `x1`, `y1`, `x2`, `y2` in logical px, with `arrow` left out or `start`, `end` or `both`. A line through three or more points is written `points=((x, y), (x, y), …)`: each point is a list `(x, y)` of unitless logical px, and there are two points or more ([Lists of values](https://komalang.org/spec/lexical/#lists)). `.smooth` makes it a curve through the points.
- **Math, code and diagrams**: to place them on their own, write `[math: x^2]`, `[code language=python: print(1)]` and `[diagram: graph LR; A --> B]`. Their bodies are read as TeX, code in the named language and Mermaid, and are never converted as Markdown (how each element reads its body: [How an element reads its body](#body-kinds)). Code without `lang` has no language. `$…$`, `$$…$$` and code fences in text work as well.
- Each line of a multi-line body is written at least two spaces deeper than the element; after the structural indentation is removed, the remaining indentation and characters are the body. The closing `]` stands on its own line at the opening's depth. An indented `]`, `---` or `;` inside is body text. A missing close is reported, and never takes in the next page or an unindented element. In the one-line form, the last `]` closes and earlier brackets are body text.
- Standalone math, code and diagrams share placement and selection. A theme's custom tag that `extends` them is not supported: it is reported, and the source is kept.
- **Figures**: write `[figure:`, on the next line the picture `[image src="assets/result.svg" alt="Line chart of the measurements":]`, then the caption, and close with `]`. A picture without a caption is written as `[image src="…" alt="…":]` alone ([Figures and images](#figure)). `src` follows the same path and safety rules as other image references, `alt` is the image's alternative text, and the text of the figure's body outside what it shows is the caption in Markdown. `alt` may be left out, and nothing is reported; a decorative image has `alt=""`. An empty `[figure:]` is kept as an unfilled field of a new page; a caption alone or an empty `src` is reported as a missing reference. A figure goes in the theme's figure slot if there is one, else in the body's flow; coordinates written in the document take precedence.
- Size: a figure with a height written scales its image, keeping the aspect ratio, within its frame less the caption's area. A figure with only a width written fits its image to that width, keeping the aspect ratio. A figure with neither takes all the space left in its parent as its area and fits its image there in the same way as a figure with a height. Several such figures in one parent share what is left equally. The caption is part of the figure's area. When the parent has no height of its own (inside an element that grows with its content), or the figure is placed with `x` and `y` and no size, the image is drawn at its natural size. A parent has a height of its own in the page's flow, in a layout frame, in a `[col:]` or `[row:]` area (when the parent holding it has a height), and when `h` is written.
- Picture-only paragraphs: a paragraph holding only `` on its line is drawn the same way, as a figure without a caption. Directly in a parent with a height, it takes all the space left as its area, fits the picture there keeping its aspect ratio, and shares what is left equally with the other figures and picture-only paragraphs of that parent. A run of pictures written directly on a page is drawn the same way, as figures in the page's flow. A picture-only element placed with `x` and `y`, and a picture inside an element that grows with its content, are drawn at their natural size (the placed element's width).
- Caption: picture and caption are one group, the caption always right under the picture, with the theme's caption gap between them. A figure with only a width written is as high as the fitted picture plus the caption, and its text is not shrunk ([Who decides size](https://komalang.org/spec/semantics/#size)). When the frame is taller than the group, the group sits at the top by default, centred across. `align-content` in the figure's `style` (`start`, `center`, `end`, also with `safe`) puts the group at the top, middle or bottom of the frame. HTML, PDF, images, PowerPoint, editing and drawing all use the same place. PowerPoint too keeps the position and proportions of the image as shown.
- Resources: a figure's resources are dependencies when saving, packing and exporting, like other images. HTML uses `figure`, `img` and `figcaption`.
- Cropping: `crop=(top, right, bottom, left)` on `[image:]` is how much to cut from each side of the original image (the order of CSS `inset()`, all four written; values are `%` or `0`, [Lists of values](https://komalang.org/spec/lexical/#lists)). The aspect ratio of what remains becomes the image's, and the frame's size (`w`, `h`, a column's width) is decided as it would be anyway. The original image file is never changed. An unreadable value is reported as `bad-value` (`crop`), and the image is drawn uncropped. A cropped image fits its frame by the same rules as an uncropped image of the remaining size (whether the figure has `h`, a position, no size, is alone in a column, or stands in a row). Only the inside of the frame is drawn: the cut parts are not drawn and the page does not move (a page clips its content and never scrolls). A PDF page used as a figure is cropped the same way. HTML and PDF are as drawn; PowerPoint places the whole image and crops it to the same area (`srcRect`). A PDF page goes in as a figure of the remaining part only.
- **CSV and TSV tables**: write `[table src="assets/results.csv": Results]`. `.tsv` is separated by tabs, anything else by commas. The body is a Markdown caption. CSV cells are plain text, never read as elements, Markdown or math. The first row is the column headings. UTF-8 (with or without a byte order mark), commas, double quotes, doubled quotes and line breaks inside quotes are read; a row with a different number of columns loses nothing, is padded with empty cells, and gives a warning. Invalid quoting or UTF-8, missing files and files over the limit never produce an incomplete table. `widths=(1, 3, 2)` on `[table:]` is the ratio of column widths; for a Markdown table, wrap just the table in `[table widths=…:` … `]` without `src`.
- A table's `src` is limited to a relative `.csv` or `.tsv` path inside the document's folder, and only referenced files are read. Nothing is written to files and no formula is evaluated. The file is read again when presenting or exporting starts. A package includes the referenced CSV; when it cannot be read, no incomplete package is made.
- **Notes**: Markdown attached to a page and never shown to the audience. They open with `"""` directly on a page and close with a line of the same characters alone. The opening line may hold `key=value` attributes in the form of an element's tag. None is defined: each is kept and reported as unknown, including the retired `speak`, whose block is now read like any other. Several notes are joined in order with a blank line between. A slide app uses them as speaker notes. They are not tied to the next element. The recommended form puts one blank line before the opening `"""` line and one after the closing `"""` line, like `+++` and `---` (none inside at the start or end, and none at the start or end of the file). Tidying and the app write notes in this form ([The standard form](https://komalang.org/spec/conformance/#standard-form)). Reading is the same without the blank lines.
- Within notes, double brackets mark what is not said. On one line, `[[Point to the figure]]` is a stage direction in plain words: nothing inside it is read as an instruction, so `[[look here about 10s]]` is only words, never a pause. The speaker sees it quietly in single brackets (`[Point to the figure]`); PowerPoint's speaker notes do the same. Speech skips it. Empty brackets, `\[[` and the same text inside a code span or fence are literal, and the page outside notes never reads double brackets. The former `[…]{speak=false}` and `[…]{pause=…}` are plain text.
- In the recommended form, put one ASCII space between a stage direction and the text on either side of it. At the start or end of a line, only the side with text needs a space. For example, `Clap once. [[Wait for the echo]] Then listen.` Both spaced and unspaced directions are recognized. Tidying preserves the author's spaces ([The standard form](https://komalang.org/spec/conformance/#standard-form)).
- For more than a line, a line of `[[` alone in column 0 opens an unspoken block and a line of `]]` alone in column 0 closes it; spaces after either mark are allowed. Without `]]` the block runs to the end of the notes. The recommended form indents the lines between by two spaces, as Koma indents structure; that indent, up to two spaces shared by every written line, is not part of the content, so unindented lines read the same. The content is Markdown (lists, emphasis, math, blank lines), shown to the speaker as a quiet block, kept in PowerPoint's speaker notes as a quiet memo, and left out of speech and measured speech time. `[[` and `]]` inside a code or math fence, or indented, are text. Tidying keeps the block as written.
```
[title: Why echoes fade]
"""
Pop the balloon first. [[Point at the window]]
[[
If someone asks:
- *Why does it fade?* Each wall keeps a little.
- Keep a spare balloon nearby.
]]
"""
+++
```
- A `---` inside closed notes is kept as part of their Markdown and is not a page break. A `;` at the start of a notes line is a comment, shown neither in the presenter view nor in PowerPoint's speaker notes ([Page boundaries](https://komalang.org/spec/structure/#page-break)). Quotes and marks inside code and math fences belong to the fence. Notes end at a `"""` outside any code or math fence that closes. An unfinished fence in the text is not mistaken for unclosed notes.
- When notes do not close, reading recovers at the first page break at the root outside a fence, or at the end, and reports `unclosed-notes` (error). The text up to there is isolated from the audience and kept. Empty notes are allowed.
- The `.koma` file, the presenter view and PowerPoint's speaker notes carry the notes on purpose. The audience's HTML, PDF, slides and thumbnails never carry their text, not even in hidden elements or attributes. Diagnostics never copy it. The older form and unclosed notes fail `koma check` and `koma format`, and `koma export` refuses before writing output.
- **Memos**: a `:::` line with attributes directly on a page opens a memo for the author, which no output shows ([Memos](#memo)).
### Tag and content
A colon separates an element's tag from its content, and a tag always ends with `:`.
#### How to write
Before the `:` is the tag, after it the content: `[box.tint x=5% y=8%: content]`, `[title: let x = 5]`. An element without content still has its `:` and closes with `:]` (`[title:]`). When a tag is long, continue its attributes on lines two spaces deeper than the opening line, and put the `:` right after the last attribute or on its own line at the depth of the attribute lines.
```
[box
.card
x=10%
w=40%
:
content
]
```
#### Example
```koma
[title: A tag over several lines]
[box
.card
x=10%
y=32%
w=50%
:
A box with one attribute per line.
]
[box .tint x=10% y=64% w=50%:]
```
> A card box written with one attribute per line, and an empty soft box below it.
#### Details
- The `:` may be attached to the tag's last word or stand apart.
- An attribute continuation line contains one or more attributes in the `#id`, `.class` or `key=value` form. An attribute value is never broken across lines. The body starts after the `:`. Tidying puts one attribute per line and the `:` on its own line.
- Elements without content: `[title:]`, `[box.card:]`, `[title x=5%:]`. A multi-line element's tag ends with `:` too. A tag without `:` is not an element ([When brackets are an element](#element-recognition)).
- A line with a word that cannot be read as a tag (`[title Koma]`) is not an element. If the name is a known tag name, it is reported as `missing-colon` with one fix that adds `:` after the name. The line is a half-made element: it is not drawn, and is not put in a bare-text box ([Placement](https://komalang.org/spec/semantics/#placement)). To draw it as text, start it with `\`. Everything after the name is never read as content.
- In a one-line element, at most one space right after the `:` is syntax; further leading spaces and trailing spaces of the body are body, kept and shown. `[label:text]` without a space is valid. The body of `[label: text]` is `text`; that of `[label: text]` starts with one space. A colon inside an attribute value, as in a URL, is not this boundary.
### When brackets are an element
A bracketed line is read as an element only in set forms; any other bracketed line stays text.
#### How to write
To make an element, end the tag with `:` (`[title: content]`, `[box.card:]`). A bracketed line without `:`, such as a name alone (`[1]`, `[NOTE]`, `[Note this matters]`), is drawn as text (for the exceptions, see element-shaped lines below). To draw a line shaped like an element as text, start it with `\` (`\[theorem: literal]`).
#### Example
```koma
[title: Brackets that stay text]
[main:
[NOTE]
Doors open at 7 pm.
\[theorem: this line is text]
See [1], Library News, issue 3.
]
```
> The bracketed [NOTE], [theorem: this line is text] and [1] are all drawn as text in the body.
#### Details
- **One-line form**: a line whose tag ends with `:` is an element. A line without `:` is text (`[1]`, `[NOTE]`, `[title:]`, `[box:]`, `[TODO]`, `[Note this matters]`).
- **Multi-line form**: the tag has the form of [Elements](#element), ends with `:`, and has a matching line of `]` alone.
- **Element-shaped lines** (`missing-colon`): lines without `:` that are one of these. (a) One-line, readable as a tag, with an attribute after the name (including an assignment whose value is invalid and has no effect): `[box#memo]`, `[box.card x=5%]`. (b) One-line, a known tag name ([Kinds of name](#names)) followed by a word that is not an attribute: `[title Koma]`. (c) Multi-line, an opening line with a [Elements](#element) tag and a matching line of `]` alone: `[box x=10%` … `]`. These are not drawn, are not put in a bare-text box ([Placement](https://komalang.org/spec/semantics/#placement)), and are reported as `missing-colon` (error) with one fix that adds `:` (at the end of the tag for (a) and (c), after the name for (b)). For (c), the lines and child elements inside are held back with it.
- **Lines with a name alone**: `[title]` and `[NOTE]` are not (a) and are drawn as text. They are reported only when the name is known: a built-in tag name ([Kinds of name](#names)), or a tag name or layout frame name of the theme in use ([Frames from sample elements](https://komalang.org/spec/styles/#theme-frames)), is taken as a forgotten `:` and reported as `name-without-colon` (note). Other names (`[AM1]`, `[TODO]`, `[1]`, a definition-list term on its line) report nothing. Tidying leaves these lines as written and never adds `:`.
- **Elements with an unknown name**: `[theorem: content]` and `[theorem:` / `content` / `]` are both elements, keeping their source, range and children. Names are resolved when drawing. A name that is neither built in ([Kinds of name](#names)) nor a tag or frame name defined by the theme in use ([Frames from sample elements](https://komalang.org/spec/styles/#theme-frames)) is an `unknown-tag` error, shown with its line number and range, and the element's content is drawn where it is written, in the flow, as a plain `[box:]` with no placement or style (directly on a page, the same as bare text, [Placement](https://komalang.org/spec/semantics/#placement)). Neither the name nor the tag's attributes take effect, and it does not go into that name's frame. Child elements and footnotes are drawn as inside a `[box:]`. Only `[notes: …]` draws its content on no page (speaker notes are written in `"""` blocks, [Elements](#element)). Once the name is fixed or the definition is loaded, it is an ordinary element. The canvas, HTML, PDF, PowerPoint and image output all draw it the same way. An unknown element alone never makes the export of the whole document fail.
- **The command line**: a check without a browser reads `theme.koma` in the document's folder to know the names; only when the theme cannot be read does it report a pending name with a theme reference as `theme-tag-unchecked` instead. `koma check` and `koma lint` report `unknown-tag` as an error and exit with 1. The CLI returns the diagnostics of the tree actually resolved.
- **Elements without a close**: the search for a close never crosses a `+++` in column 0. When no close is found, the opening line keeps its source, is reported as `unclosed-element`, and reading recovers on the next page. That line, and directly on a page what follows it to the end of the page, are not drawn, being the content of an element without a close ([Placement](https://komalang.org/spec/semantics/#placement)).
- **Keeping a line as text**: when a line meant as text is read as an element (`unknown-tag` and `missing-colon` for `[Note: …]`), the message says that a leading `\` keeps it as text. A `\` at the start of a line stops it being read as an element or a list item. `[docs](https://example.com)`, images, footnotes, `[0, 1)` and `[[wiki]]` keep their Markdown meaning; no name is guessed into an element. A line of a reserved form meant as text is written `\[theorem: literal]` or in a code fence.
## Names and attributes
### Kinds of name
There are three kinds of element name: slot names, which go to fixed places of the layout; reserved words, which have no fixed place in the layout; and custom tags, which a theme declares.
#### How to write
Write what goes to a fixed place of the layout with a slot name (`[label: …]`, `[title: …]`, `[subtitle: …]`, `[main: …]`, `[footer: …]`). A cover also takes the cover-only slots `authors`, `affiliations` and `date`. Write an element with no fixed place in the layout with a reserved word: `box`, `callout`, `shape` or `group`.
#### Example
```koma
[label: Night at the library · 2]
[title: How the swap works]
[subtitle: Leave one book, take another]
[main:
The swap table is by the entrance.
]
[box .tint x=60% y=70% w=32%:
No booking needed.
]
```
> The label Night at the library · 2 at the top, the title How the swap works with its subtitle, the body, and a No booking needed box at the lower right.
#### Details
- **Slot names** (`label`, `title`, `subtitle`, `main`, and the optional `footer`) go to fixed places of the layout ([Page layouts](https://komalang.org/spec/structure/#layouts)). They are named for the role of their content: `label` is a short label of the page's or the talk's context, such as the chapter or the event; `title` is what the page discusses (usually a one-line noun phrase); `subtitle` follows the title with the one sentence the page wants to say; `main` holds figures, tables and explanation. On every page, `subtitle` forms one heading with the title ([HTML elements and reading order](https://komalang.org/spec/semantics/#html-elements)). References at the bottom of a page (`references`) are not a place to write; they are made from footnotes ([Footnotes](https://komalang.org/spec/text/#footnote)). The page number is not written but turned on with `paginate`.
- The slot `label` has no alias and is not the layout name `section`. `layout: section` (a kind of page, the section opener) and `[label: …]` (a slot for the chapter or event name) are different things.
- **Slots of the cover only**: `authors` (the presenters; one or more), `affiliations`, `date` (as written; never today's date). Their content is ordinary text (Markdown), with no pairing of authors and affiliations. On any other layout they are reported as `slot-not-in-layout` (warning), like other slots, and the content is kept.
- **Reserved words**: `box` (a plain element), `callout` (a box with a marker column, [Callouts](#callout)), `shape` (a shape with its text inside its outline, [Shapes](#shape)), `group` (a container that only gathers elements, [Groups](#group)). Speaker notes are written in `"""` blocks ([Elements](#element)).
- **Custom tags** are declared in the theme's YAML and follow HTML's valid custom element names: they start with an ASCII lower-case letter, contain a hyphen, contain no ASCII upper-case letter, space, NUL, `/` or `>`, and are not names HTML reserves. Standard tags never use a hyphen (nor will tags added later). A declaration of a name not of this form (such as `card`) or of a standard tag's name is reported as a problem of the theme (in `koma check`, a warning on the theme document), and only that declaration is unused. The theme's source stays as written. An element of that name in a document is `unknown-tag` ([When brackets are an element](#element-recognition)), like an undeclared name: its content is drawn as an ordinary box, and its source is unchanged. While the theme has a problem, export (PDF, HTML, PowerPoint, `koma export`) reports it and stops. A tag and where it goes are separate: a custom slot takes `[box slot=left: …]`. Elements of the same tag may appear on a page any number of times.
- **One pair of brackets is one element.** The same slot written twice on a page is not joined: the second stays a separate element, with its id, and is reported.
- Two or more of the same slot on one page are **all drawn**: none is dropped, merged or made an error. `duplicate-slot` stays a warning and does not stop export. Without positions they are drawn on top of each other in the same frame, so the message says what happens and how to fix it: they are drawn on top of each other; give one a position, or keep one.
- Where one title of the page is needed (the document's name, the heading read aloud, checks of the title's content), **the first in the source** is used, as with HTML's ``.
### Order of attributes
The order of attributes in an element's tag has no meaning: any order reads the same, and only explicit tidying puts them in a set order.
#### How to write
Write attributes in any order. When an attribute is written twice, the first takes effect ([Elements](#element)). Tidying orders them as name, `#id`, classes, `x` `y` `w` `h` `rotate` `z`, other known attributes, and unknown attributes. For example, tidying turns `[box.note style="color: red" w=40% x=10.5% data-n=1:` into `[box .note x=10.5% w=40% style="color: red" data-n=1:`.
#### Details
- Explicit tidying (`koma format`, `koma check --write`, the app's Tidy) separates the tag's words with spaces in this order: 1. The element's name; 2. `#id`; 3. each `.class` (keeping their order among themselves). `id=` and `class=` come after them. 4. `x` `y` `w` `h` `rotate` `z` 5. Other known attributes in this order: what to draw (`slot` `src` `alt` `crop` `lang` `widths` `f` `range` `baseline` `fill` `fill-opacity` `stroke` `points`), a line's ends and connections (`x1` `y1` `x2` `y2` `from` `from-side` `from-at` `to` `to-side` `to-at` `route` `arrow` `label-at` `label-side`), and the rest (`weight` `marker` `dir` `step` `step-effect` `style`) 6. Unknown attributes (including looks written as attributes, like `opacity=`) last, in the order written
- Values move as written: no rounding, no change of unit, no change of quoting (quotes are removed only where tidying could always remove them, [Elements](#element)).
- A tag with a duplicated attribute (`#id` and `id=`, `.class` and `class=` count as the same attribute), with a bare word (`bare-word`), or with `name=` or `role=`, has its joined name, ID and classes separated, and keeps the order of each word.
- Rewrites other than explicit tidying (moving or resizing on the canvas, the format panel, MCP `setAttributes`) keep the written order. Attributes whose value changes are rewritten in place; attributes whose value does not change are not rewritten. A new attribute goes into its place in the order above without moving written ones: before the first written attribute that comes later in that order, or else at the end of the tag (even when the written order differs from the order above). Several attributes added at once follow the order above. So a tidied tag stays tidy after the GUI rewrites it.
- The command line and the app use the same tidying function.
## Groups
### Groups
A group is a container that only makes its elements belong together, with no position, size or look of its own.
#### How to write
Open with a `[group:` line, list the elements to gather one level deeper, and close with a line of `]` alone. The tag takes only an `#id` and classes.
#### Example
```koma
[title: Two rooms]
[group #venue:
[box .card x=10% y=40% w=35%:
Reading room, first floor
]
[box .card x=55% y=40% w=35%:
Swap table by the entrance
]
]
```
> Two cards side by side, for the reading room and the swap table. The group does not change how they look.
#### Details
- The elements inside are read and drawn as they would be without the group. A positioned element keeps its position relative to the group's parent ([Elements](#element)), a flowing element flows in the parent's flow, and a frame element (`[title:]` and the like) goes into the layout's frame. Text inside reads as if written in the group's parent (directly on a page, bare text, [Placement](https://komalang.org/spec/semantics/#placement)). The group's opening and closing lines break a run of bare text, like any element's lines. Otherwise, wrapping elements in a group or unwrapping them does not change what is drawn.
- Any element may go inside: frame elements, positioned elements, flowing elements, `[col:]` and `[row:]`, other `[group:]`s. Nesting has no depth limit. `[col:]` and `[row:]` splits ([Columns and rows](https://komalang.org/spec/semantics/#split)) are counted from outside the group: a `[col:]` wrapped in a group joins the same split as the `[col:]` beside it.
- Attributes other than the `#id` and classes keep their source, have no effect, and are each reported as `group-attribute` (warning). A group with nothing inside (including one of only blank lines and comments) is reported as `empty-group` (warning) and kept. A group without `:` is held back with its content as `missing-colon`, like any element ([When brackets are an element](#element-recognition)).
- Its extent is the rectangle around its elements as drawn (a rotated element as rotated), never written in the source. Stacking order is source order (an element with `z` follows the stacking-order rules). Reading order ([HTML elements and reading order](https://komalang.org/spec/semantics/#html-elements)), footnotes ([Footnotes](https://komalang.org/spec/text/#footnote)) and steps ([Steps](#step)) belong to each element inside.
- HTML, PDF and images draw as without the group. Tidying indents it like other containers ([The standard form](https://komalang.org/spec/conformance/#standard-form)).
## Callouts
### Callouts
A callout, `[callout: …]`, is a box with a marker column on the left and a content column on the right.
#### How to write
Write `[callout marker="⚠": content]`. `marker=` takes one emoji or symbol; without it, the marker is 💡. A callout takes the same attributes as a box.
#### Example
```koma
[title: What to bring]
[main:
[callout marker="⚠":
Bring your own cup; there is no kitchen.
]
[callout:
Write your name in your book, so it can find its way back.
]
]
```
> A callout with a ⚠ marker above one with a 💡 marker; in both the content lines up to the right of the marker.
#### Details
- The marker is drawn at the top of the left column. All content (paragraphs, lists, math, nested elements) flows in the right column and never wraps under the marker.
- The marker is written `marker=`: one emoji, one symbol (⇒ ∴ ※ ✔ ⚠ ⓘ and the like: one character that is neither a letter nor a digit), or `none`. Without it, 💡.
- Emoji and symbols are drawn a little larger than the text (1.25 times). A symbol takes the box's text colour; an emoji keeps its own colours. What a reader sees as one character (one grapheme, such as a skin tone or a flag) counts as one.
- Text (any value that is not one emoji or symbol: two or more characters, or one letter or digit, such as `marker=Cost`) is not a marker. It keeps its source, 💡 is drawn, and it is reported as `text-marker` (warning). The fix is to choose an emoji or symbol, or to write a text heading as a definition list ([Definition lists](https://komalang.org/spec/text/#definition-list)).
- `marker=none` draws neither marker nor column; the content starts at the inner padding.
- An empty value or one with a line break is reported with the general attribute warning `bad-value`, keeps its source, and 💡 is drawn.
- The class `badge` has no special meaning. Like any class it stays in the source, changes nothing unless the theme's or document's CSS defines it, and is not reported.
- The column is as wide as a symbol (`1.25em`), with `0.5em` (of the body text size) between marker and content. Every marker has the same width, so consecutive callouts align their content's left edge. When the marker column is wider than a quarter of the callout's inner width (between its left and right padding, including the column), `koma check --layout` reports `long-marker` (warning) with the percentage of the width the marker takes.
- With `padding` written in `style`, the marker column is still taken inside that padding: the left padding is the written one plus the column (`padding: 0` puts the marker at the box's left edge). The marker never leaves the box. Editing, drawing and PowerPoint agree.
- The content is centred vertically, with equal top and bottom inner padding ([Named styles](https://komalang.org/spec/styles/#style-classes)). In a frame taller than its content (with `h` written, or stretched to a column's height), the content sits in its middle; `align-content` in `style` wins. The marker aligns with the content's first line (the first even when there are several), and its line is as high as one line of body text, so even with one line the marker's and the text's centres line up, and the marker never makes the box taller. Editing and drawing put it in the same place.
- A callout without a style class ([Named styles](https://komalang.org/spec/styles/#style-classes)) is drawn `tint`. It takes the same attributes as a box, can go wherever a box can, and nests.
- `[box:]` has no marker. A `marker=` on a box keeps its source, draws nothing, and is not reported.
- Tidying indents it like other containers ([The standard form](https://komalang.org/spec/conformance/#standard-form)). HTML, PDF and images draw it as the screen does.
## Shapes
### Shapes
A shape (`[shape:]`) is an element that draws the outline of a rectangle or an ellipse and puts its text in the rectangle inside it; its kind is written `type`, and a rectangle's rounded corners `radius`.
#### How to write
`[shape type=rect: …]` is a rectangle and `[shape type=ellipse: …]` an ellipse. Without `type` it is a rectangle. For a circle, write the same `w` and `h`. Round the corners with `radius`: `[shape radius=16px: …]`, or a share of the shorter side, `[shape radius=10%: …]` (`50%` makes the ends half circles). The text is written as in a `[box:]` and drawn in the middle of the rectangle inside the shape.
```
[shape x=10% y=30% w=320px h=180px type=rect radius=16px:
Measure
]
[shape .tint x=55% y=30% w=240px h=240px type=ellipse:
Compare
]
```
#### Details
- `[shape:]` is an element apart from `[box:]`. A box is a container for text and layout (flow, columns and rows, frames, the base of a theme's custom tags), and its rounded corners only shape its fill without changing where its text goes. A shape's outline comes first: it decides the text rectangle, the points lines connect to and the PowerPoint shape.
- The values of `type` are `rect` and `ellipse`, the names of the SVG elements (``, ``). Any other value is reported as `bad-value` (`type`) and drawn as a rectangle. The attribute has the same name as a chart's kind (`type` on a chart).
- `radius` is a length: `px`, or `%` of the shape's shorter side (not a share of each side as CSS's `%`, so the corners never turn elliptical). `0` may leave out its unit. A value over half the shorter side (`50%`) is taken as half, as CSS rounded corners are, and nothing is reported. A number without a unit is `missing-unit`, another unit or a value that is no length `bad-unit`, and a value below 0 `bad-value` (`radius`).
- `radius` has no effect on an ellipse: its source is kept as written and it is reported as `radius-on-ellipse` (warning), with a fix that removes it (safe: what is drawn does not change). It takes effect again if the shape becomes a rectangle, so `koma format --write` does not remove it.
- Only `radius` decides the corners. `border-radius` written for a shape (in `style`, a theme or the document's CSS) is not used; in `style` it is reported as `shape-border-radius` (warning). The fix moves it to `radius` on a rectangle (it may change the meaning, since what is drawn changes) and removes it on an ellipse (safe). A theme cannot round every shape's corners: the shape is what its source says.
- The text rectangle: the text goes in the rectangle that fits inside the outline's line, less its `padding`.
- Rectangle: the rectangle inside the line, and with a `radius` of r, a further r × (1 − 1/√2) (about 0.29 r) in from each side: the rectangle that touches the corner arcs at 45°.
- Ellipse: the rectangle inscribed in the ellipse inside the line, with the ellipse's proportions (its width and height 1/√2 of the ellipse's), centred.
- Alignment: by default centred both ways (the theme's CSS `shape { text-align: center; align-content: safe center; }`). Change it with `text-align` and `align-content` in `style`.
- Size: without `h`, the text rectangle is as tall as its text (a rectangle as a `[box:]`; an ellipse √2 times the text rectangle's height). Placement (free or in the flow), the width without `w`, what the body may hold (Markdown and child elements), shrinking and overflow ([Who decides size](https://komalang.org/spec/semantics/#size)) are as for `[box:]`, each taking the text rectangle as the box's content rectangle.
- Look: by default a thin line in the text colour and no fill. The style classes (`tint`, `fill`, `outline`, `bar`, `card`, `.accent` and so on) and `style` take the same declarations as `[box:]`. Themes and the document's CSS select `shape` and `shape.tint`.
- Connected lines: a rectangle, rounded or not, has the connection points top 0, left 1, bottom 2, right 3; an ellipse top 0, left 2, bottom 4, right 6. A line's end stops on the outline.
## Figures and images
### Figures and images
A figure (`[figure:]`) is a container holding what it shows and the text of its caption; the picture itself is written as an image (`[image:]`). A figure is written one way: what it shows as a child, and the rest of its text as the caption.
**How to write it**
```
[figure:
[image src="assets/decay.svg" alt="Sound level falling over time in three rooms":]
How the echo fades in each room
]
[image x=70% y=10% w=20% src="assets/logo.svg" alt="":]
```
A picture without a caption is written as `[image:]` alone. A chart with a caption is wrapped in `[figure:]` the same way.
#### Details
- The attributes of `[image:]`: `src` (the same path and safety rules as other image references), `alt` (alternative text; nothing is reported when it is left out; a decorative image has `alt=""`), `crop` (cropping, as a list `crop=(0, 0, 10%, 0)`, with the order and meaning of the cropping in [Elements](#element)), and the common `x`, `y`, `w`, `h`, `#id`, classes, `style`, `step` and `rotate`. It has no body. Text in its body keeps its source, is not drawn and is reported as `image-body` (error), with one fix that wraps it in a figure as its caption (it may change the meaning). An empty `src` is reported as a missing reference, `bad-value` (`image src`).
- The attributes of `[figure:]` are only the common `x`, `y`, `w`, `h`, `#id`, classes, `style` and `step`. An `[image:]` inside a figure gives the figure's picture only its `src`, `alt` and `crop`; the figure decides place, size, `#id`, classes, look and `step`. `src`, `alt` and `crop` on the tag of a figure that holds an `[image:]`, and the other attributes of the inner `[image:]`, have no effect: their source is kept and they are reported as `figure-attribute-ignored` (warning); the picture is the `[image:]`'s.
- What a figure shows: `[image:]`, `[chart:]`, `[diagram:]`, `[math:]` and `[code:]`. A line at the structural position of the figure's body (after depth × 2 spaces) that starts an element with one of these names (the element form of [When brackets are an element](#element-recognition)) is shown; every other line is the caption's Markdown. The caption's lines join in the order written, whether before or after what is shown. The formatter does not reorder them.
- Two or more shown elements stand side by side at equal widths in the figure's area, with one caption under them all (no caption for each). Any other element (`[box:]`, `[table:]`, `[col:]` and so on) as a child keeps its source, is drawn in the same row as what is shown, and is reported as `figure-child-unsupported` (warning). A table has its own caption and notes, so it is not wrapped in a figure.
- Size, the caption's place, `align-content`, lines (`border-*`) and rounded corners follow the figure rules of [Elements](#element), reading "the picture" as "the area of what is shown". An `[image:]` placed on its own is drawn by the size rules of a figure without a caption.
- An empty `[figure:]` is kept as an unfilled field of a new page. A figure with a caption and nothing shown is reported as a missing reference.
### How an element reads its body
An element's body is read in the one way set for the element's name. For each element, one rule says where child elements may stand, what is read as Markdown and what goes to another grammar.
**How to write it**
| Element | Child elements | Markdown | Body in another grammar |
| --- | --- | --- | --- |
| Directly on a page | Allowed | Text between elements (a bare text box, [Placement](https://komalang.org/spec/semantics/#placement)) | None |
| Frames (`title`, `main` and so on), `box`, `callout`, `shape`, `col`, `row` | Allowed | Text between the children | None |
| `group` | Allowed | As if written in the parent ([Groups](#group)) | None |
| `figure` | What it shows ([Figures and images](#figure)) | Text outside what it shows is the caption | None |
| `table` | Not allowed | The caption and notes; without `src`, one table | The CSV or TSV of `src` (a file) |
| `math` | Not allowed | Not read | TeX |
| `code` | Not allowed | Not read | The language of `language` |
| `diagram` | Not allowed | Not read | Mermaid |
| `chart` | Not allowed | Not read | CSV |
| `image`, `curve` | Not allowed | No body (`:]`) | None |
| `line` | Not allowed | The body is kept and not drawn | None |
#### Details
- In a body in another grammar (`math`, `code`, `diagram`, `chart`), neither elements, Markdown nor comments (a `;` at the start of a line) begin. What remains of each line after its structural indentation (depth × 2 spaces, and 2 more) is the body: further indentation, symbols, `[`, `]`, `$` and `;` are kept as body text. The closing `]` stands on its own line at the opening's depth ([Elements](#element)).
- A `+++` at column 0 is a page break in any body, and a recovery point that does not carry an unclosed element over to the next page ([Page boundaries](https://komalang.org/spec/structure/#page-break)). The same holds inside a `chart`'s CSV.
- Text written in an element without a body (`image`) keeps its source, is not drawn and is reported (`image-body`, [Figures and images](#figure)).
- A theme's custom tag reads its body as the element it `extends`. An element whose body is in another grammar cannot be extended.
## Curves
### Curves from a formula
A curve is an element for pulses and envelopes that draws the values of a formula `f` in its box, and has no fixed shapes (`shape=`) or carrier attributes (`carrier=`).
#### How to write
Write the formula in `f`, and place the box with `x`, `y`, `w` and `h` as for any element. A curve has no content (`:]`). `domain=` gives the horizontal range and `range=` the vertical one; arrows are `arrow=`, as on lines. Formulas used often can be named and defined under `functions:` in the document's settings.
```
[curve x=10% y=20% w=30% h=10% f="sin(2*pi*6*t) * 0.5*(1-cos(2*pi*t))" arrow=end:]
```
#### Example
```koma
===
functions:
rc(t): 0.5*(1-cos(2*pi*t))
drive(t): rc(t)*sin(2*pi*6*t)
===
[title: A pulse with an envelope]
[curve .muted x=10% y=30% w=80% h=45% f="rc(t)" style="stroke-dasharray: 12px 8px":]
[curve .muted x=10% y=30% w=80% h=45% f="-rc(t)" style="stroke-dasharray: 12px 8px":]
[curve .primary x=10% y=30% w=80% h=45% f="drive(t)" arrow=end:]
```
> A pulse oscillating inside a dashed envelope, ending in an arrow at the right.
#### Details
- The horizontal range is given as a list of the left and right ends, as `domain=(-pi, pi)` ([Lists of values](https://komalang.org/spec/lexical/#lists)). Each end is a finite constant expression. Without it, 0 to 1. An invalid end, or two equal ends, is reported as `bad-value` (`domain`), nothing is drawn, and the source is kept. `x=` and the like place the box as for any element.
- The left side of `f="x -> sin(x)"` is the input variable, local to the formula. Without it, `x` and, for compatibility, `t` both name the horizontal value. Vertically, −1 is at the bottom of the box and 1 at the top by default; `range=(0, 1)` (a list of the bottom and top, each a constant expression as an end of `domain` is) changes that. To show the amplitude as it is, the range never adapts to the values; values outside it are drawn outside the box. A `range` that is not two finite values, or two equal ones, is reported as `bad-value` (`range`) and nothing is drawn.
- A curve without `h` is a quarter as high as it is wide.
- Formulas: numbers (`2`, `0.5`, `1e-3`), the input variable, `pi`, `e`, `+ - * / ^`, unary minus, parentheses and function calls. `^` binds tighter than unary minus and associates to the right (`-2^2` is −4, `2^3^2` is 2⁹). Multiplication cannot be left out (`2t` does not read). Built-in functions: `sin cos tan asin acos atan atan2 sinh cosh tanh exp log log10 sqrt abs sign floor ceil round min max mod erf erfc sinc gamma step`. `log` is the natural logarithm, `sinc(x)` is sin(x)/x (`sinc(0)` is 1; not divided by π), `step(x)` is the Heaviside step (1 for `x` ≥ 0, 0 below), `mod(a, b)` takes the sign of `b`, `round` rounds halves up, and `min` and `max` take two or more arguments. `erf` and `erfc` use the Numerical Recipes approximation (error below 1.2×10⁻⁷), and `gamma` the Lanczos approximation with the reflection formula, with no value at 0 or negative integers. The app reads formulas itself, with neither `eval` nor a library.
- Defining functions: under `functions:` in the document's settings (`===`), list `name(arguments, …): expression`. A theme's settings (`===`) may hold them too; for the same name, the document's wins. A function has one or more arguments; its name starts with a letter followed by letters, digits or `_`. Definitions may call other definitions. A definition that calls itself directly or through others (recursion), takes the name of a built-in function, `pi` or `e`, cannot be read, or uses a name that is not an argument (inside a function, `t` is usable only when written as an argument) is reported on the `functions:` line as `bad-value` (`functions`, with the definition's head and the reason), and only that definition is unused. `functions:` in page settings (`---`) is `setting-out-of-scope`.
```
===
functions:
rc(t): 0.5*(1-cos(2*pi*t))
drive(t): rc(t)*sin(2*pi*6*t)
===
[curve x=10% y=30% w=40% h=20% f="drive(t)" arrow=end:]
```
- When `f` cannot be read, uses an unknown name, or calls with the wrong number of arguments, it is reported as `bad-value` (`f`, naming an unknown name; for `pulse`, the screen says “The formula uses pulse, which is not defined”), and nothing is drawn; the source is kept.
- Drawing: the formula is evaluated at about one point per px of the box's width (at least 2, at most 2000) and the points are joined. A point whose value is not a finite number (`sqrt(-1)`, `1/0`, a pole) breaks the line, which starts again at the next finite point. Once on the page, points are taken again at the drawn size (a nested curve, a size in `%`).
- Heads and look are those of lines: `arrow=start|end|both`, the head-shape classes and `--head-start`, `--head-end`, sizes such as `--head-size`. A triangle's tip is at the curve's end; the point one head-length back along the curve is the centre of its base, and the line stops there. The triangle points from the centre of its base to the tip, with butt line caps. An open head follows the end's direction; dots and diamonds are centred on the end. Colour, width and dashes take the same classes as lines (`.accent`, `.muted`, `.thick`, `.dashed`) and `style` (`stroke-width`, `stroke-dasharray`).
- Fill: `fill=` shades the area between the curve and a horizontal baseline, drawn behind the line. It takes a colour role (`primary`, `secondary`) or a CSS colour (a name, `#2563eb`, `#2563eb33`, `rgba(37, 99, 235, 0.18)`, `hsl(…)`); `fill-opacity=` (0 to 1) fades it further. `baseline=` is a finite constant expression on the vertical scale; without it, the baseline is 0 when 0 is inside `range`, else the bottom of `range`. Each run of the curve is filled on its own, closed straight down (or up) to the baseline at its first and last points. `stroke=` set to `none` draws the fill alone, with no line and no heads; a line width of 0 (`style="stroke-width: 0"`) draws no line either. A `fill`, `fill-opacity` or `baseline` that cannot be read (a `baseline` that is not finite or not constant) is reported as `bad-value` (`fill`, `fill-opacity`, `baseline`) and no fill is drawn; a `stroke` other than `none` is `bad-value` (`stroke`). The curve itself is still drawn. On a curve these four are its own attributes, not looks ([Elements](#element)); built-in `min` and `max` shade where curves overlap.
```
===
functions:
g(x, m): exp(-((x - m) / 8)^2)
===
[curve x=10% y=40% w=40% h=12% f="g(x, 35)" domain=(0, 100) range=(0, 1) fill="rgba(37,99,235,0.18)":]
[curve x=10% y=40% w=40% h=12% f="g(x, 55)" domain=(0, 100) range=(0, 1) fill="rgba(37,99,235,0.18)":]
[curve x=10% y=40% w=40% h=12% f="min(g(x, 35), g(x, 55))" domain=(0, 100) range=(0, 1) fill="rgba(220,38,38,0.32)" stroke=none:]
```
- HTML and PDF draw an SVG path, the fill as a path of its own under the line.
## Step-by-step display
### Steps
Steps reveal elements one stage at a time while presenting.
#### How to write
Write the order to show in the common attribute `step`: `[box step=1: text]`, `[col step=2: text]`, `[row step=2: text]`. An element without `step` is shown from the start. The form `{step=1}` is not in the grammar.
#### Example
```koma
[title: Tonight]
[main:
[col:
7 pm Doors open
]
[col step=1:
8 pm Book talks
]
[col step=2:
9 pm The swap
]
]
```
> Three columns: 7 pm, 8 pm and 9 pm. A drawn picture shows every column, steps included.
#### Details
- The value is a safe integer of 1 or more. Presenting reveals the valid steps from the smallest, those with the same number together, and goes to the next page once all are shown. A nested element's step is the largest of its own and its ancestors'; a child without one inherits its parent's. The written value is never rewritten. No empty steps are made for numbers no element uses.
- Going back hides the last step shown. Going to the previous page shows its last step; Home is the first page's start, End the last page fully shown. Restarting the presentation shows the chosen page's start. A hidden element still takes its space.
- Editing, static HTML, PDF and PowerPoint show everything. No timelines or animations are added.
### Entrance effects
An entrance effect (`step-effect`) decides how an element first becomes visible on its step. Write it in the document or page settings, or use it as an element attribute. The accepted values are `appear`, `fade`, and `rise`. The element's value wins, followed by the nearest ancestor that provides a value, then the page, then the document. The default is `appear`. A rise reveals the element from its bottom edge without moving it.
Only the outermost element that becomes visible on a step animates. Children that share their parent's step appear with that parent. A child with a later step enters with its own effective effect. Going backward hides a step immediately. `step-effect-unused` identifies an effect written where the element enters together with a parent or where neither the element nor its descendants have a step. Invalid values are reported as `bad-value` and fall back to the inherited effect. Quoting a value keeps its meaning. The formatter places the attribute after `step`. Articles and posters retain it with a `type-unused-feature` note.
## Memos
### Memos
A memo is a note for the author placed on a page, which no presentation or export shows.
#### How to write
Open with `:::` and `key=value` attributes in column 0 on a page, write the text on the lines after it, and close with a line of `:::` alone. `x` and `y` place the memo, and `w` and `h` size it.
```
[title: Results]
::: x=64% y=18% w=28%
Check the units on the axis.
:::
```
#### Details
- Attributes: `x` and `y` are `%` of the page or `px`, and may be negative or beyond 100% to place the memo on the pasteboard around the page; a missing one is `0`. `w` and `h` are optional positive lengths of the same kinds. Without `w` the editor gives the memo its default width, and without `h` it is as tall as its text. `collapsed` set to `true` folds it to a pin; `false` is the default. Another attribute is kept and reported as `unknown-memo-attribute` (warning). An unreadable value is reported as `bad-value` (warning), and the default applies. Later attributes, such as a colour, are added in the same form.
- Text: plain text, kept as written. It is not read as Markdown, elements, settings or notes. A `+++` in column 0 still breaks the page ([Page boundaries](https://komalang.org/spec/structure/#page-break)). A line of the text that would close the memo or break the page is written with a leading `\`, which is not part of the text.
- A memo that does not close ends at the next page break or the end of the file, keeps its text and is reported as `unclosed-memo` (error).
- Only a `:::` line followed by attributes and nothing else opens a memo. A bare `:::` and `::: name` keep `misplaced-scoped-block` and `unsupported-declaration` ([Document settings](https://komalang.org/spec/structure/#deck-settings)) in the preamble and on a page. An indented `:::` inside an element is text.
- A memo belongs to its page and takes no part in its layout, flow, reading order, notes or footnotes. The presentation, the presenter view, HTML, PDF, PowerPoint, images and thumbnails never draw it or carry its text. The Koma AST has a `memo` node ([Syntax tree nodes](https://komalang.org/spec/semantics/#ast-nodes)). The resolved page lists its memos with their place and text, which only the editor's canvas and the agent tools read.
- Tidying keeps a memo's lines as written and puts one blank line before and after a closed memo, as for notes ([The standard form](https://komalang.org/spec/conformance/#standard-form)).
---
[Specification](https://komalang.org/spec/) · Chapter 4 / 7
# Text and inline markup
Inside an element, text is Markdown with LaTeX math, plus a few additions of Koma’s own.
## Markdown and LaTeX
### Text inside elements
Text inside an element is written in Markdown and LaTeX.
#### How to write
In running text you can use Markdown emphasis (`*…*`, `**…**`), underline (`__…__`), strike-through (`~~…~~`), highlight (`==…==`), code, links and footnotes; superscript `^{…}` and subscript `_{…}`; LaTeX math `$…$`; and attributes on a span, `[text]{.class}`. A `#` at the start of a line is a heading, `***` a horizontal rule, and lines of `$$` around a formula make displayed math.
#### Example
```koma
===
lang: en
===
[title: Marking up text]
[main:
Bring **one** book. *Swapping* is free.
==No booking needed==. Open 7 to 10 pm. Bottles of H_{2}O are welcome.
[New]{.chip} This month ~~10~~ 12 books arrived. The area is $\pi r^2$.
]
```
> Bold “one”, emphasised “Swapping”, highlighted “No booking needed”, H2O with a subscript 2, a rounded New tag, 10 struck through, and the formula pi r squared.
#### Details
- The inline notation is Markdown's emphasis, code, links and footnotes, LaTeX math, and Pandoc-style inline attributes. Raw HTML is kept and shown as the characters written. Emphasising one word is written with Markdown's `**`; the look is the theme's.
- Links are drawn with the theme's link colour and underline. Only links inside footnotes take the footnote text's look ([Footnotes](#footnote)).
- **Inline attributes**: the standard forms are `[text]{.class .another}`, `[text]{style="color: #234080"}`, and both together, `[text]{.class style="font-weight: normal"}`. The closing `]` and the attribute's `{` touch, and attributes are separated by spaces. Text and attributes are on the same line. Emphasis, highlight, code, math, links and footnotes inside the text are kept. The same brackets work on a span that holds formatting: `[**important** result]{style="color: #b42318"}` makes only “important” strong and colours the whole span; `[==important==]{style="font-weight: 700"}` adds weight to a highlight. `[text]{.underline}` is read as an existing class; a new underline is written `__text__`.
- `style` is written as on elements: CSS declarations in double quotes. The properties allowed are `font-family`, `font-size`, `font-style`, `font-weight`, `color` and `text-decoration-line`. Values are checked and ranked as for each declaration of [Elements](https://komalang.org/spec/elements/#element). Unsupported declarations and values are not applied, are reported as `bad-value`, and keep their source.
- Koma element tags, Markdown links and reference links, and footnotes are read first; inside code and LaTeX, inline attributes are not read. An empty text (nothing, or only spaces, between the brackets), a missing close, or an `#id` or another unsupported attribute keeps its source and is treated as text. An empty text is reported as `empty-span`: an answer blank is written with text inside, as `[answer]{.blank}` (its look set by the class) or `[\_\_\_\_]{.blank}`. Class names take the same characters as on elements.
- The look of a class is set by the theme's and the document's CSS. `.chip` is a rounded ground with bold text (in the official themes). A class with no definition is reported as `unknown-class`, and the text shown is kept.
- HTML and PDF draw the same way.
- **Superscript and subscript**: superscript in text is `^{superscript}`, subscript `_{subscript}`, as in `1^{st}` and `H_{2}O`. A pair complete on one line is read; an unclosed pair, an escaped one, a pair inside code or math, and `file_name` keep their source. Strike-through `~~…~~` and LaTeX `$x^{2}$` are read as strike-through and math. Superscripts and subscripts written with older classes are shown for compatibility and are subject to explicit migration.
- **Highlight**: `==text==`. A span complete on one line is read and drawn with HTML's `mark` ([Inline classes](https://komalang.org/spec/styles/#inline-classes)). Unclosed, escaped, and inside code or math, the marks stay as they are. `[text]{.mark}` is read as text with a class, and keeps the document's own class. Attribute delimiters with the brace in front are text of the body ([Brace-first attributes are text](#brace-first-attributes)).
- **How the notation relates to others**: shared with Pandoc are emphasis, links, code, footnotes, strike-through, highlight and `[text]{attributes}`. LaTeX follows [Code and math are isolated](https://komalang.org/spec/lexical/#isolation) and the rules for math. Superscript and subscript are Org mode's braced forms (`^{…}`, `_{…}`). A `;` at the start of a line is a Koma manuscript comment ([Page boundaries](https://komalang.org/spec/structure/#page-break)): kept when saving, left out of display and export.
- **Citations reserved**: `[@key]` is reserved for a way of citing yet to come. It is shown as written and reported as `citation-unsupported`. Citations are written as footnotes, `[^label]`. Nothing is reported inside code and math.
- **Horizontal rules**: `***`; `___` is read too. The formatter writes `***`. There are no Setext headings with `---` and `===`; the line before is never made a heading. A line of only `===` is text. A line of only `---` (indented or not) is not a horizontal rule: it is shown as written, reported as `dashes-not-rule` (warning), with one fix to `***`. A `---` in column 0 is [Page settings](https://komalang.org/spec/structure/#page-settings).
- **Emphasis, underline and strike-through**: `*x*` is emphasis, `**x**` strong importance, `__x__` underline, `~~x~~` strike-through. In every language, including Japanese, emphasis is italic and strong importance is bold.
- Old Koma `_…_`, `__…__` and `___…___` are read by the old rules in the command line's explicit migration and changed to `*…*`, `**…**` and `***…***`. Ordinary saving and tidying never migrate. Before applying, the text is read again to confirm the meaning is the same.
- `***x***` is both strong importance and emphasis. It may hold complete inline math, code, links and footnotes. Link text is read as ordinary Koma Markdown. The same triple marks inside, and other complex nesting, are not supported: the outer marks and the inner content are kept.
- So that a selected span can be formatted whatever the language and the neighbouring characters, `*`-family emphasis may touch characters, digits included, and punctuation without spaces. `1**word**2` makes `word` bold; `2*3*4` emphasises the middle `3`. Emphasis is never refused by guessing that digits around it make a formula. Multiplication is written as math (as `$2*3*4$`), and the literal symbol escaped (as `2\*3\*4`) or as code. Only complete delimiters are read, and the existing protection is kept: just inside spaces, escapes, code, math and link targets. Existing source is never rewritten automatically.
- Underline reads even when the marks touch the characters on both sides. A single mark as in `file_name`, and marks in code, math and link targets, are not underline.
- **Headings**: `#` is a heading (not a page). A heading's level is its depth in the document, not its size.
- The heading mark is a single `#`. A `#` in plain text (directly on a page) and a `#` inside an element are both headings within the page's body, `h3` in HTML. `h1` is only the document's title and `h2` only the page's title (the `title` element). The level does not change with whether the page has a title, or with nesting ([HTML elements and reading order](https://komalang.org/spec/semantics/#html-elements)).
- `##` to `######` are read as headings too (so pasted Markdown is not broken). In HTML each extra mark is one level deeper from `#`'s `h3`, down to `h6`; they look the same as `#`. They are reported as `deep-heading` (note), with one fix to `#`, This fix changes the level and so may change the meaning: it is applied only when chosen in the GUI or with `koma check --write --unsafe`. `koma check --write`, saving and tidying never change the marks.
- `h3` to `h6` are bold at the effective size of the text around them, with a small space below. A `#` in a figure caption takes the caption text's size. The space can be changed with the theme's `--koma-local-heading-gap`.
- There is no notation for a large heading in plain text, and no Setext headings or HTML tags. Large text is written with classes and the document's CSS, or with inline attributes.
- A heading in the flow of text is `#`; a heading standing on its own is a separate element or a child element. No element per heading is required.
- The guide, examples and the GUI write headings in the source with `#` only.
- The HTML elements are [HTML elements and reading order](https://komalang.org/spec/semantics/#html-elements).
- **Line breaks and spaces**: a line break inside a paragraph is a line break. Leading and trailing spaces left after the structural indentation is removed are kept even in ordinary paragraphs, and the extra spaces are shown. Inside elements there are no Markdown indented code blocks: four or more spaces still read as text. Code blocks are fences, which can name a language. When pasting Markdown with indented code, fence the code.
- **Math**: `$…$` and `$$ … $$` (by Pandoc's rules, so `$5 and $10` is not math). For displayed math, the recommended form puts the opening `$$` and the closing `$$` each on its own line (three lines: `$$`, the formula, `$$`), and tidying writes this form ([The standard form](https://komalang.org/spec/conformance/#standard-form)). A one-line `$$ formula $$` is read as the same math.
- **Comments**: a `;` at the start of a line inside an element (after the structural indentation) is a comment ([Page boundaries](https://komalang.org/spec/structure/#page-break)). Inside fences and raw bodies, and in the middle of a line, `;` is text.
## Definition lists
### Definition lists
A definition list sets out terms, each paired with its explanation.
#### How to write
Write a term on one line, and the explanation on the next line starting with `: ` (a colon and a space or tab), the same form as Pandoc and Markdown Extra.
#### Example
```koma
[title: Around the library]
[box x=8% y=30% w=70%:
Swap table
: Leave one book and take another.
Reading room
: Quiet until 9 pm.
]
```
> Bold terms Swap table and Reading room on the left, each explanation aligned to the right of its term.
#### Details
- In HTML, `dl`, `dt` and `dd`.
- A term may have several explanations (more `: ` lines). Continuation lines of an explanation are indented two or more spaces. Blank lines between items are optional (a term after blank lines continues the same list).
- A `: ` line is read as a definition only when it follows a one-line paragraph (one line after a blank line or after another block). After a paragraph of two or more lines, after a list, table or heading, and with no space after the `:` (`:1`), it is text. An element tag's colon, page and document settings, and code and math are read first and are never definitions. Terms and explanations take the inline notation (emphasis, math, links, `[…]{.chip}`).
- Look (changeable with the theme's CSS): by default the term is bold on the left and the explanation on the right, their tops aligned. The term column is as wide as the longest term, up to three tenths of the box. With the class `stack-terms` on the box, explanations are stacked, indented, under their terms. The space between items is that between list items, on a slide tightened in the same order when they do not fit. Between a term's second and later explanations, half of it.
- Export: HTML and PDF are as on screen.
- A line of only a colon is read as text, and a warning offers a fix that removes the line.
- The formatter keeps the form as written.
## Footnotes
### Footnotes
A footnote is a mark in the text whose note is gathered at the bottom of the page. References and side notes alike are written as footnotes.
#### How to write
Write a mark `[^label]` in the text, and its footnote from the start of a line as `[^label]: text` (as in Markdown). Written inside any element, it is a footnote of the page.
#### Example
```koma
[title: The busiest hour]
[main:
On weekdays, 7 pm is the busiest hour[^1].
[^1]: Central Library survey (fictional).
]
```
> A small superscript [1] after the sentence, and the footnote “[1] Central Library survey (fictional).” at the bottom of the page.
#### Details
- References are written only with footnotes. Bibliography and side notes alike are footnotes, gathered into the references at the bottom of the page. There is no other way to write them and no other slot. In the body or the subtitle, the mark sits where it is written.
- `[^label]` in text is a footnote mark. `[^label]: text` from the start of a line is that mark's footnote (one line).
- A page's footnotes are its references (`references`), drawn gathered in the page's footer band in the order their definitions are written, under the page's `[footer:]` when it has one ([The bottom band](https://komalang.org/spec/styles/#bottom-band)). Their position, width and alignment with the page number follow the layout. As the band grows with them, the body above it shrinks, so body text placed by the layout ends above them (body text with a position of its own stays as it is). The theme decides only the look ([Who decides size](https://komalang.org/spec/semantics/#size)).
- A mark with no footnote is drawn as written, `[^label]` (as in the footnote drawing rules). The same mark's footnote written twice is reported as `duplicate-footnote` (warning), and both are kept.
- Notes (`"""` blocks, [Elements](https://komalang.org/spec/elements/#element)) are not footnotes. Footnotes inside notes are not gathered.
- A link in a footnote is drawn, in every theme, in the footnote text's colour without underline, and works as a link (clickable on screen, a link in PDF and HTML). PowerPoint too uses the footnote text's colour without underline (the look of links in the body is unchanged).
### How footnotes are written
Footnotes are written as in GFM (GitHub Flavored Markdown).
#### How to write
Write `[^label]` in the text, and `[^label]: text` at the start of a line; continuation lines are indented. A label is a string without spaces. How they are drawn is the footnote drawing rules.
### Footnote labels
The string after `^` in `[^1]` or `[^AM1]` is shown as written, at the mark and in the definition. Nothing is numbered automatically. Footnotes resolve per page; the same label defined twice on a page is reported as `duplicate-footnote` and both are kept. An undefined mark is shown as `[^label]` with no further diagnostic. Marks in the body and subtitle are small superscripts; labels in the definitions at the bottom are at the normal height. Drawing, local editing, HTML, PDF and PowerPoint use the matching label and never rewrite the source. Speaker notes are not part of a page's footnote definitions.
## Older inline attributes
### Brace-first attributes are text
A brace written in front (`{.chip: text}`) is not an attribute but text of the body.
#### How to write
Attributes in text are written after the text, as `[text]{.class}` ([Text inside elements](#inline-markup)). A brace put in front, as in `{.chip: new}`, is drawn as written, as text.
#### Details
- Half-width (`{.chip: new}`) and full-width (`{.tag:新しい}`) alike get no diagnostic and no automatic fix, and tidying keeps the source.
---
[Specification](https://komalang.org/spec/) · Chapter 5 / 7
# Styles and themes
Attributes say what an element is and where it goes; its look comes from the theme, its classes and its style.
## Document CSS
A document's CSS is written in `css:` in the document settings (`===`). The value is read by its YAML shape, never guessed from its content.
```
===
title: Talk
css:
- styles/talk.css
- |
title { color: #294d73; }
page.dark { background: #17212d; color: white; }
===
```
- A literal block (`css: |`, `|-`, `|+`) is CSS written in the document.
- A one-line string ending in `.css` (in any case) is the path of a CSS file inside the document's folder. It may be quoted. It is relative, separated by `/`, with any leading `./` dropped. A URL, anything starting with `/`, and anything with `\`, an empty part or `..` is not a path.
- A sequence lists those two kinds, applied in the order written, joined as one CSS.
- Any other value (a folded `>`, a one-line string not ending in `.css`, a number, a map, an empty sequence, a sequence with a non-path string) is reported as `bad-value`, and none of it is applied.
CSS files are read under the same rules as images: only inside the document's folder, checked by their real path, never leaving the folder through `..` or links, UTF-8 and 256 KiB at most. A file that cannot be read is reported as `css-file-unavailable` (error), and only that file is left out. `url()` inside a file is relative to the document's folder. CSS from a URL is never read. `@import` is not read, in written CSS or in files, and is reported. Scoping, `page.class` and the checks are the same for written CSS and files.
Page settings have no `css:` (`setting-out-of-scope`); there is no per-page CSS. A page's look comes from the `class` in its page settings, put on the page's outer frame and selected by `page.class` in the document's CSS. No other selector of pages is added, except that a page's edge lines may be written as declarations in that page's `style:` ([Page-edge lines](#page-edges)). Line declarations on `page { … }` (`border` and the per-side `border-*`) apply to a line layer inside the page, not to its outer frame, and move nothing on the page.
`:::` followed by attributes opens a memo ([Memos](https://komalang.org/spec/elements/#memo)); otherwise it is a reserved mark with no use. A bare `:::` line in column 0, in the document's preamble or on a page, isolates its source up to the matching `:::` (or the next `+++` in column 0) and is reported as `misplaced-scoped-block`, pointing to the document's `css:`. A `::: name` line at the root is reserved for future declarations, reported as `unsupported-declaration`, and isolated the same way. An indented `:::` inside an element is Markdown text.
Tag, ID, class, compound and list selectors and `*` match only the document's Koma elements. The page itself is selected with `page { … }` and `page.class { … }`, written like an element. `page` is the name of a virtual parent, reserved as a tag name and never written in the source (a written `[page …]` is `unknown-tag`). `page` takes one class at most; an ID, two or more classes, combinators or pseudo-classes are reported and the block is not applied. The automatic page number is selected with the reserved name `page-number`, as `page-number { … }` (also inside `@layout name { … }`); it takes neither ID nor class, and if given one, the block is reported and not applied. `page-number` is reserved as a tag name and cannot be a custom tag. The page's three bands are selected the same way with the reserved names `page-header`, `page-body` and `page-footer` ([Layout grids](#layout-grid)): each alone in its rule, with neither ID nor class, also inside `@layout name { … }`; they hold no Markdown parts and cannot be custom tags. A grid written on `page` itself is reported as `legacy-page-grid` and not applied. `@slide { … }` and `@page-number { … }` are reported and not applied, like any unknown at-rule. Looks for one layout go inside `@layout name { … }` ([Looks for one layout](#layout-rules)). Unsupported combinators, attributes and pseudo-classes are reported, and no block is partly applied. No outside resource or executable code is loaded.
### Looks for one layout
`@layout name { … }` makes rules in the document's and the theme's CSS apply only to pages of one layout.
#### How to write
Write the layout's name after `@layout` ([Page layouts](https://komalang.org/spec/structure/#layouts), including a theme's named layouts), and ordinary rules inside `{ … }`. For example: `@layout cover { subtitle { font-size: 46px; font-weight: 400; } }`. `@layout cover { page { … } }` applies to the pages of that layout themselves. `padding` written on `page` decides the area of the flow directly on the page ([Placement](https://komalang.org/spec/semantics/#placement)).
#### Example
```koma
===
css: |
@layout cover { subtitle { color: #b42318; } }
===
---
layout: cover
---
[title: The book swap]
[subtitle: Only the cover's subtitle is red]
+++
[title: An ordinary page]
[subtitle: The ordinary page keeps its default colour]
```
> Page 1: A cover page. The subtitle under the title The book swap is drawn in red.
>
> Page 2: An ordinary page. Its subtitle keeps the default colour.
#### Details
- It works the same way for every tag (`title`, `subtitle`, `label`, custom tags, classes, IDs). No tag has an exception of its own.
- Only rules may go inside. There is one name, unquoted. Declarations written directly inside, nested `@` rules, and a missing name or more than one are reported, and the block is not applied.
- When a rule for all pages and a rule of the layout both match the same element, the layout's rule wins whatever the order written (it weighs one class more).
- The official themes use this to give the cover's subtitle the look of the cover subtitle’s look (lead size, not bold, body colour).
### Markdown parts in elements
The document's and the theme's CSS can select the parts Markdown makes inside Koma elements (paragraphs, list items, headings, pictures, table headers and cells) by their HTML names.
#### How to write
Write the part's name after a selector of Koma elements and a space (`box.tint p { … }`, `callout li { … }`). A part's name alone selects it inside any element (`h3 { margin-block-end: 0.3em; }`). `+` between two parts selects the one right after (`p + p { margin-block-start: 0.6em; }`).
#### Details
- Parts: `p`, `li`, `h3`, `img`, `th`, `td`. `caption`, `figcaption` and `table` are selected as before. The list names `ul`, `ol`, and `dl` apply only on either side of `+`, alone or in a part-only `:is()`. A bare `ul`, a bare `:is(ul)`, or an element followed by `:is(ul, li)` does not select list containers. Generated `page` and `page-number` have no Markdown parts. Report these forms as `part-selector-unmatched` and omit that rule alone.
- Forms: `[selector of Koma elements] part`, or `part + part` (each a name, or `:is()` listing part names only). A part takes no ID, class, pseudo-class or attribute. `>`, `~`, a part after a part, and a Koma element after a part are not applied.
- The part names are reserved and never name a tag.
- Only what an element's own text writes in Markdown is selected: not the footnotes Koma draws, nor a frame's own text (`label`, `title` and so on), which its tag selects.
- In specificity a part counts as one type selector. The document's CSS is outside the theme layer and always wins over the theme.
- Other HTML names inside elements (`strong`, `a`, `blockquote` …) are not selected; text is styled by text classes ([Text inside elements](https://komalang.org/spec/text/#inline-markup)).
- A Markdown name written in a form that selects nothing (`ul { … }`, `box > li { … }`, `strong { … }`) leaves out that rule alone and is reported as `part-selector-unmatched`, naming the forms that work. Report at the document CSS selector, or at the `css:` setting when it references the stylesheet. Other rules apply. Editing, presentation, HTML, PDF and images share rendering. PowerPoint copies the result’s sizes, colours and spacing.
`@keyframes` in a verified theme and in document CSS are applied to the editor, presenting and HTML with their names kept apart per page. Only document CSS is separated per page; the order of theme then document, specificity, `!important` and ordinary `var()` are kept. CSS that cannot be separated is not partly applied, and the reason is given. PDF, PNG and PowerPoint are still output in the base style without animation, and say so. Stilling other media such as video is not promised.
## Themes
### What a theme decides
A theme decides the look of the slides and the default placement of the layouts.
- Theme CSS uses Koma selectors such as `theorem#result.important` and `page { … }`. Declare shared custom properties on the page and use the public theme tokens listed in [Public variables](#public-variables).
#### How to write
Choose it with `theme:` in the document settings ([Choosing a theme](#theme-reference)). Positions and sizes written in the document take precedence over the theme's defaults.
#### Details
- **What is published**: The public styling surface comprises tag, ID and class selectors for elements, Markdown component selectors ([Markdown parts in elements](#markdown-parts)), ordinary CSS declarations, and the variables listed in [Public variables](#public-variables).
- **Official themes**: default, talk and report. A theme (look and layouts) is kept apart from templates for a document's structure.
- **Math face**: the document YAML of theme.koma may set `mathFont: fira`, `mathFont: stix2` or `mathFont: newcm` (New Computer Modern Math). Without it, Fira; an unknown value is reported. Within a theme, inline and display math use the same face. The official themes use newcm for default, and Fira for talk and report. `--math-font: fira|stix2|newcm` in an element's `style` draws only the math inside that element in a face other than the theme's. Math is drawn to suit the kind of face of the text it sits in; only words in `\text{…}` follow the surrounding weight. Surrounding bold or italic adds no formatting to math. In every theme, bold and italic written explicitly in TeX are kept. The math data, licences, size and checks are recorded in the math boundary.
- **Text faces**: the local Noto assets are used for the default sans and code, and for serif when named. Licences, coverage, weight matching and the boundary of output are recorded in text faces. Choosing an element's role is the format panel’s rules.
- **Colours** (common to the three official themes): each theme writes on `page` the primary colour `--koma-primary`, the text on it `--koma-on-primary`, the secondary role `--koma-secondary` and its text colour `--koma-on-secondary` ([Colour roles](#colour-roles), [Text on role colours](#on-role-colours)), the line `--koma-line`, the body colour, the tint background derived by [Soft tint](#soft-tint), the figure caption colour `--koma-caption-color` (the body colour), and the footnote colour `--koma-footnote-color` and muted colour `--koma-muted` (both ink-2). `label` and `box.citation`, footnotes, footers and muted text use the same weak text colour (ink-2); figure captions, table captions and table notes the body colour; `page-number` a lighter grey; and an ordinary page's `subtitle` the primary colour. ink-2, the page-number grey and the soft ground are made from the primary's hue with default's saturation and default's contrast on white (ink-2 about 6:1, the page number about 3.4:1, the soft ground about 1.09:1). Body text and ink-2 reach 4.5:1 or more on the ground and the soft ground, and text on the primary colour 4.5:1 or more.
- default: body `#16161d`, ink-2 `#5f626f`, page number `#888b98`, soft ground `#f4f5f9`, primary `#2d287f`.
- talk: body `#17212d` (16.3:1 on white), ink-2 `#576564` (6.1:1), page number `#7d8f8d` (3.4:1), soft ground `#eff6f6`, primary `#0f6b63` (white text 6.4:1).
- report: body `#17212d` (16.3:1), ink-2 `#5c646c` (6.0:1), page number `#858d95` (3.4:1), soft ground `#f3f5f8`, primary `#3b4754` (white text 9.5:1).
- One grey for weak text: label, `box.citation`, footnotes, footers and muted text (`.muted`) are all ink-2. Only the page number stays a lighter grey. The default of themes that are not built in (`slide.css`) is one colour too (`#595959`), and `--koma-muted` points to `--koma-footnote-color`.
- Figure captions, table captions and table notes take the body colour. Grey is left only to footnotes, footers, page numbers and labels. The three official themes set `--koma-caption-color` to the body colour, and table notes use `--koma-caption-color` (or else the surrounding text colour). HTML, PDF and PowerPoint agree.
- **Sizes follow the frame**: the body size is written in `--koma-font-size` (which the page kinds of [Values per kind of page](#page-kind-values) may change), figure captions are `figure { font-size: 0.7em }`, `box.citation` is `0.7em`, and tables write no size and inherit from the frame. So that a `font-size` on a box reaches the figure captions, sources and tables inside, none of these has a fixed px size.
- **Space between list items**: each theme writes on `page` a wide value `--koma-item-gap: 0.8em` and a narrow value `--koma-item-gap-min: 0.35em` (the names `--koma-list-item-gap` and `-min` are not read). Items normally take the wide value, and lists inside an item half of it. When a slide's frame does not fit, the gap narrows continuously to the narrow value before the text gets smaller. When a theme or document sets both to the same value, nothing narrows. Documents and posters take their kind's fixed value instead, 0.25em, which never narrows ([Values per kind of page](#page-kind-values)). Being in em, they follow the text size of the frame or box. The table of contents layout `outline` takes no space from line height; the body's wide value is default 1.05em, talk 0.67em, report 1.03em (the narrow value stays 0.35em, narrowing when it does not fit).
- **label**: the default weight is 400 (regular). A label is a small note above the title; in regular weight and the weak text colour, it does not compete with the (bold) title. Being regular, part of it can be bold, as in `**Study I** multi-qubit control`. No letter spacing is added. The three official themes keep 400 for the labels of ordinary pages and the cover, and make only a section opener's label a chapter heading, 700 in the primary colour ([Cover and section pages](#cover-and-section)).
- **Page number and footer**: the page number's default colour is the same grey as the label at the top left. A theme can set its colour with `page-number { … }` ([Page settings](https://komalang.org/spec/structure/#page-settings)). A page's `footer` defaults to the same weak text colour as footnotes (`--koma-footnote-color`). Both stand in the footer band ([The bottom band](#bottom-band)), which a theme selects as `page-footer { … }`; the header and the body are `page-header` and `page-body` ([Layout grids](#layout-grid)).
- **Default line breaking and typesetting** (a theme or the document's `css:` can change them with bare selectors such as `page`, `box`, `table` and `callout`; table captions are selected as `caption` and figure captions as `figcaption`, as in HTML, with no ID or class; the default rules have no specificity):
- Between paragraphs: in slide bodies and boxes, paragraph, list and definition-list boundaries use the same proportional gap and automatic fitting as list items, using `--koma-item-gap` and `--koma-item-gap-min`. Documents, posters, captions, table notes, footnotes, and presenter notes use 0.5em between paragraphs, wider than a document's or a poster's list items ([Values per kind of page](#page-kind-values)). Keep the first and last edges clear. Authors may set adjacent-part CSS or explicit `--koma-paragraph-gap`. Nested list spacing follows the editing view’s rules. Display math, code, tables, quotations, diagrams, figures and grids take the block gap above and below, which closes up with the item gap ([HTML elements and reading order](https://komalang.org/spec/semantics/#html-elements)); elements in a flow use the flow gap ([Columns and rows](https://komalang.org/spec/semantics/#split)). Editor blank lines and HTML, PDF, and PowerPoint spacing agree.
- Between caption text and the image or table edge, use 28 px by default, 12 px on articles, and 40 px on posters. Themes and documents can set `figcaption { margin-block-start: … }` and `caption { margin-block-end: … }`. Table notes sit at 75% of this gap below the table.
- Text is broken so that the last line is not left with one word or character (`text-wrap: pretty`). Titles and subtitles are broken into lines of even length (`balance`).
- When the document's language is Japanese (`lang: ja`), text breaks at phrase boundaries, table cells included (`word-break: auto-phrase`). But frames, elements and captions whose inner width is less than 8 characters of their text break anywhere (an extra line is better than a word cut in the middle).
- Where the browser has no `auto-phrase` (as in the macOS app's WebKit view), the drawn text of a Japanese page gets a `` at each phrase boundary from BudouX, the model Chromium's own phrase breaking uses, and those elements break only there (`word-break: keep-all; overflow-wrap: anywhere`, with no specificity). It is fetched on first need, kept for offline use, and never loaded where the browser breaks phrases itself; the pages are fitted again once it arrives. Math, code, preformatted text, drawings, editors and URLs get no breaks, nor does a place before a closing mark or after an opening one, and narrow blocks keep breaking anywhere. The source, tidying, the editor and copied text are unchanged.
- Tables break only words longer than the column, anywhere (`overflow-wrap: anywhere`, on the table elements).
- When the last line of a Japanese paragraph (paragraphs and list items of frames and elements in a `lang: ja` document) has two characters or fewer, the paragraph is drawn again narrower by 1 em at a time, up to 3 em, and the width that leaves at least three characters on the last line without adding a line is used. If none fits, the original width stays.
- In paragraphs with kana or kanji, a line never breaks after a hyphen inside a Latin word (such as `heavy-hex`) (when drawing, a U+2060 goes after the hyphen; the source and tidying are unchanged).
- Inline math stays on the line of the opening bracket right before it, and of the closing bracket or punctuation right after it (`(`, `)`, `、`, `。` and so on). Without an opening bracket, the one phrase right before it (a word and the kana after it, with any space or U+00A0 between; for example 約 in 「約 $1.57\Delta$」) stays on the math's line.
- A space between a number and a unit (`GHz`, `ns`, `dB`, `mK`, `%` and so on; the list is in one place in the code) is drawn as a non-breaking space. The source and tidying are unchanged. A U+00A0 written stays.
- Full-width brackets at the ends of lines on Japanese pages have their space trimmed in the three official themes (`text-spacing-trim: trim-both`, [Brackets at line ends](#bracket-spacing)).
- HTML, PDF, images and editing break lines the same way.
### The source of a theme
A theme's original is a `.koma` document, with the fonts and images it needs beside it.
#### How to write
Write the theme in `theme.koma` and put its fonts and images in the same folder. How to write a theme document is in the section on themes whose original is a `.koma` document.
#### Details
- A folder that uses `theme.css` and the like is treated as another format.
- No script is run.
- How far a document can pin the version of the theme it uses is recorded in the record of pinning. There is no mechanism for managing or sharing themes.
- A theme folder's `layouts/` is not read, in either format. Its files are not used for drawing or checking, cannot be reached from the theme's CSS or a theme document's `css:` (they are reported as unavailable), and are not put into new packages, frozen themes or sharing copies. In a theme frozen earlier, its bytes are kept for checking the freeze but not read or counted toward size limits, and the rest of the theme applies. `koma lint` and `koma check` report a `layouts/` folder in the document's theme folder (for a theme document, its own folder) as `theme-layouts-unused` (a note). The source and the files are not changed.
### Choosing a theme
A document points to its theme with `theme:` in the document settings.
#### How to write
A built-in theme by name (`theme: default`, `theme: talk`, `theme: report`), a folder beside the document by relative path (`theme: ./themes/my-theme`), a URL by its address. A document without `theme:` is drawn with the default theme, `default`.
#### Details
- The default theme is named `default`. The UI shows Default in English and `標準` in Japanese.
- The app (a new document, choosing a theme) and `koma new` write `default`.
- A theme at a relative path travels with the document.
- A theme at a URL is fetched and kept locally (it works offline).
### Checking a theme's CSS
A theme's CSS is checked when it is loaded, so that other people's themes can be used safely.
#### How to write
A theme's CSS is ordinary CSS. The selectors written are confined to the slides, and outside resources are limited to the theme's folder and fonts.
#### Details
- Selectors are confined to the slides; the app's own screen cannot be changed.
- Outside resources (`@import`, outside `url()`) are limited to the theme's folder and fonts.
- What the check refuses is left out alone, as a browser leaves out a rule it cannot read: a rule with a selector that is not a Koma selector, a nested rule, an at-rule a theme may not use, a declaration that loads from outside the theme's folder, or text the CSS parser cannot read. The rest of the theme applies: its other rules, its layouts and its tags.
- Each is reported where it is written, as `theme-css` (a warning): at its line in `theme.koma` when the theme document is checked; with its style sheet's name and line, at the `css:` line, for a sheet the theme names; and with the theme's file and line, at the `theme:` line, when a document is checked. `koma lint`, `koma check` with or without `--layout`, and the language server report it; the app lists it with the theme's problems, naming the file and line. An export is refused while one remains, as it is for a document's CSS.
### The theme layer
A theme's CSS is drawn in the CSS cascade layer `koma-theme`, so the document's CSS and elements' `style` always win over the theme.
#### How to write
Layers are never written by hand. The document's CSS (`css:`), page edge lines in page settings' `style:` ([Page-edge lines](#page-edges)) and elements' `style` ([Elements](https://komalang.org/spec/elements/#element)) sit outside the layer, so they win whatever the specificity of the theme's rules (the theme CSS cascade layer).
#### Details
- In the layer: Koma's built-in slide rules (the base shared by every theme), the CSS of theme documents (official themes, themes in the document's folder, `theme.koma`), rules made from theme data (`theme.json`), and the per-page rules made from the theme's `@keyframes`. Inside the layer, specificity and order written decide (base, theme, theme data).
- Between pieces of document CSS, and between document CSS and elements' `style`, the ordinary CSS cascade holds (`style` wins).
- `!important`: as CSS defines, `!important` inside the layer beats `!important` outside it. What built-in rules fix with `!important` (measuring table widths, the left-only line of a `bar` box) does not change even with `!important` in the document. `!important` in an element's `style` beats `!important` inside the layer too.
- Neither a theme's nor a document's CSS may write `@layer` (like other unknown at-rules, it is reported and not applied). Only Koma decides the layer's name and order.
- The editor, presenting and the presenter view, theme previews, export (PDF, PNG, PowerPoint, HTML, `koma export`), the try-it embeds and the VS Code preview draw alike. While a theme document is open and being edited, its `css:` goes in the layer too. HTML export keeps the layer.
### Public variables
The CSS variables a theme or a document may set are the public ones listed here; every other look is written as ordinary CSS.
#### How to write
Public variables go on `page` (and its `@layout`): `page { --koma-primary: #2d287f; --koma-item-gap: 0.8em; }`. Anything else is a selector and ordinary declarations: `box.tint { padding: 0.75em 1em; border-radius: 12px; }`, `figcaption { margin-block-start: 28px; }`, `th { background: #f4f5f9; }`.
#### Details
- Public variables can be set in theme and document CSS.
| Variable | Meaning | Related rule |
| --- | --- | --- |
| `--koma-primary`, `--koma-on-primary` | Primary colour and text over it. Koma chooses the text colour when omitted. | [What a theme decides](#theme), [Named styles](#style-classes) |
| `--koma-secondary`, `--koma-on-secondary` | Secondary colour and text over it. Koma chooses the text colour when omitted. | [What a theme decides](#theme) |
| `--koma-line` | Lines in `outline`, `bar`, tables, and divisions. | [What a theme decides](#theme), [Named styles](#style-classes) |
| `--koma-muted`, `--koma-footnote-color`, `--koma-caption-color` | Muted text, footnotes and footer, and figure captions. | [What a theme decides](#theme) |
| `--koma-chart-1` to `--koma-chart-6` | Chart series colours, independently of the primary and secondary roles. | CHT |
| `--koma-item-gap`, `--koma-item-gap-min` | Maximum and minimum list spacing used for fitting a slide; a document's or a poster's fixed list spacing ([Values per kind of page](#page-kind-values)). | [What a theme decides](#theme) |
| `--koma-font-size` | Body font size, which can vary by page kind. | [What a theme decides](#theme), [Values per kind of page](#page-kind-values) |
| `--koma-padding-block`, `--koma-padding-inline` | Default page-kind padding. Set page-specific padding with `page { padding }` ([Placement](https://komalang.org/spec/semantics/#placement)). | [Values per kind of page](#page-kind-values) |
| `--koma-gap` | Default split gap. | [Columns and rows](https://komalang.org/spec/semantics/#split) |
| `--koma-transition-duration` | Duration of a page transition, 400 ms by default. | [Motion durations](#motion-durations) |
| `--koma-step-duration` | Duration of an element's entrance effect, 250 ms by default. | [Motion durations](#motion-durations) |
| `--math-font` | Math face within an element, set in its `style`. | [What a theme decides](#theme) |
- Unlisted `--koma-*` and `--_koma-*` variables are internal. Their names and meanings can change.
- Former public variables are ignored. There is no aliasing or `legacy-css-variable` migration. Use the current primary and secondary role pairs, `.mark` for highlights, and `box.tint` or `callout.tint` for tint. Use the relevant CSS declarations for spacing, margins, table appearance, box padding and radius, and title typography. Keep the rules for `--koma-heading-rule-*` ([Cover and section pages](#cover-and-section)) and `--koma-ja-text-spacing-trim` ([Brackets at line ends](#bracket-spacing)).
- Public variables express colour relationships or feed calculations such as fitting and page-kind defaults. Use ordinary CSS declarations for a single component's appearance.
### Colour roles
Themes use `--koma-primary` and `--koma-secondary` as colour roles for built-in styles.
- Primary is the document's principal colour. Default uses `#2d287f`, Talk `#0f6b63`, and Report `#3b4754`. It appears in `[text]{.primary}` ([Role classes](#role-classes)), the ordinary page `subtitle`, section `label`, `fill` boxes, `.chip` backgrounds, the table `accent` class, shapes and lines using `.primary`, tint ([Soft tint](#soft-tint)), and chart series one.
- Secondary is `#edb909` in all three official themes. It colours the left line of `bar` and its 8% background, as well as highlight `==…==` or `.mark`. Highlights mix 50% secondary into the page background using `color-mix(in srgb, var(--koma-secondary, var(--koma-primary)) 50%, var(--koma-background, #fff))`. Secondary also applies to `.secondary` shapes and lines, chart series two, and the markers of single-series charts. If secondary is absent, use primary.
- With no explicit `--koma-chart-1` to `--koma-chart-6`, series one and two use the role colours. Series three through six alternate the two colours at lighter 35% and 60% mixes with the page background.
### Text on role colours
Text placed on a role colour uses `--koma-on-primary` or `--koma-on-secondary`. When omitted at the rule or element that sets the role colour, Koma chooses whichever of white (`#ffffff`) or the page text colour gives the higher WCAG contrast ratio. If the chosen colour still falls below 4.5:1, `role-contrast` reports a note without altering rendering.
### Soft tint
Soft tints (`.tint` and plain callouts) mix `--koma-primary` at 6% into the page background (`color-mix(in srgb, var(--koma-primary) 6%, var(--koma-background, #fff))`) as an opaque fill.
### Role classes
Official themes provide `.primary` for primary-coloured inline text (`[word]{.primary}`) and `.primary` / `.secondary` for shapes and lines. Inline text has no `.secondary`, and boxes/callouts attach no built-in look to `.primary` or `.secondary`.
### Motion durations
Two CSS variables set motion duration. The user's reduced-motion preference disables the effects.
#### How to write
Set the variables on `page` or its `@layout`. For example, `page { --koma-transition-duration: 400ms; --koma-step-duration: 250ms; }`.
#### Details
- `--koma-transition-duration` controls the page transition and defaults to `400ms`. Use the value in effect on the incoming page.
- `--koma-step-duration` controls an entrance effect and defaults to `250ms`. Use the value on the outermost element entering at that step ([Entrance effects](https://komalang.org/spec/elements/#entrance-effects)). Normal CSS inheritance lets the page set the default. Element `style` or document CSS can override an element and its descendants.
- Use CSS times in `ms` or `s`. `0s` is immediate. Negative or invalid values fall back to the default without a diagnostic.
- `fade` is linear. `push` and `rise` use `ease-out`. Koma fixes easing.
- Under `prefers-reduced-motion: reduce`, transitions and steps are immediate. The playback device's preference takes precedence for presentation and HTML. Themes and documents cannot override it.
- Default, Talk, and Report rely on the defaults.
### Flow columns
A theme or document may write the multi-column and fragmentation properties of CSS on Koma elements and `page`, and authored block margins between items in a flow are kept.
#### Example
```koma
===
css: |
box.sheet {
columns: 2;
column-gap: 36px;
column-rule: 1px solid #c3c9d0;
row-gap: 16px;
}
.span { column-span: all; }
box.item { break-inside: avoid; }
===
[box .sheet:
[box .span:
# Tidepool field sheet
South Cove · low tide at 14:20
]
[box .item .outline:
**1. High shore**
Count barnacles in a 20 cm square near the dry line.
]
[box .item .outline:
**2. Mid shore**
Note limpets and dog whelks under damp ledges.
]
[box .item .outline:
**3. Lower pools**
Record water temperature $T$ and shade cover before moving on.
]
[box .item .tint:
**Reminder**
Leave turned stones face down so organisms underneath stay shaded.
]
]
```
> Field sheet titled Tidepool field sheet spanning two columns, with four numbered cards balanced across the two columns separated by a thin rule.
#### Details
- On a container: `columns`, `column-count`, `column-width`, `column-gap`, `column-rule` and its `-width`, `-style` and `-color`, `column-fill`. On an item: `column-span`, `break-inside`, `break-before`, `break-after`.
- `gap` and `row-gap` written in theme or document CSS on an element set the space between what its flow holds, as `style="gap: …"` does ([Cards without positions](https://komalang.org/spec/semantics/#cards)); `gap` keeps its CSS meaning on the element too, so on a multi-column container it also sets the column gap.
- `margin-block-start` and `margin-block-end`, and the block sides of `margin-top`, `margin-bottom`, `margin-block` and `margin`, written on an element (not on a Markdown part or the page) add to the gap before and after it, in every flow, not only in columns. This is how a theme leaves answer space after a problem. A `margin` whose sides a variable may stand for is applied as written.
- Ruled lines are written as ordinary CSS, such as a `repeating-linear-gradient` background on the container behind items with a background of their own. There is no Koma-specific ruling property.
- Pseudo-elements and counters (`::before`, `counter-increment`) stay outside the public surface; numbers such as “Problem 1” and “(1)” are written in the source.
### Theme data
A theme's look is written in CSS alone; legacy theme data (`tokens`, `boxStyles` with look keys, `elements`) is no longer read or migrated.
#### How to write
In `theme.koma`'s `css:`, or `theme.css` for a folder theme. The display names of styles are written like `pageStyles`: `boxStyles: { quote: Quote }` (class name: display name).
#### Details
- `boxStyles` that only names classes (`quote: Quote`) is kept.
## Theme documents
A theme is edited as an ordinary `.koma` document, `theme.koma`. Opened in the editor, its frames can be edited on the canvas as samples of the layouts. Each sample page's `layout: name` setting stands for that layout, and the sample elements on it with a position and size define its frames ([Frames from sample elements](#theme-frames)). Custom tags are declared in the document YAML's `tags`, never implied by sample elements. Sample text is for previewing the theme and is never copied into documents that use it. Even when a frame of the same name as a tag is chosen by default, a tag's kind and its slot are different ideas, and the document's text, images and explicit coordinates are kept. Invalid, duplicated or unsupported names or coordinates keep their source and are reported. A theme may define the default placement of `cover`, `section`, `content` and `blank` too.
No YAML key is required to mark a document as a theme. It is opened and edited like any `.koma`, and its definitions are checked when it is chosen as a theme with `theme:` or in the app. By convention the theme's source is `theme.koma`; when a document meant as slides is chosen and lacks the layout definitions it needs, this is reported rather than guessed. A CSS-only theme needs no pages.
The `css:` in a theme document's document settings ([Document settings](https://komalang.org/spec/structure/#deck-settings): written CSS and CSS files in the theme's folder) is applied as the theme. Assets and CSS files are kept as paths relative to the theme document, and go through the same safe reading and scoping. A document selects a custom theme with a reference such as `theme: ./themes/editorial/theme.koma`. A theme folder can be pointed to as well, but two sources are never mixed. Elements on a layout page that are not frames become that layout's decoration ([Layout decoration](#theme-decoration)). Unsupported per-page CSS is reported, never mistaken as drawn.
Page styles are defined by `page.class` in the theme document's or the document's `css:`. A theme may give their display names in its document settings' `pageStyles` as class name: display name (`pageStyles: { dark: Dark background }`). Class names start with a lower-case letter followed by lower-case letters, digits and hyphens; display names are non-empty strings; anything else keeps its source and is reported. A class without a display name shows its class name. Display names of layouts are written the same way in `layoutNames`.
A theme `.koma` and a `.koma` template for documents, with content and pages, serve different purposes; making a document never changes the template. The command line can copy an official theme, or a local `theme.koma` with the images it needs, into a new folder for editing; the original theme and the document's reference are not changed, and the shared checks refuse missing files and unconfirmed fonts (editing copies records the boundary). The web menu and palette can make an editing copy too. A `theme.koma` being edited is copied with its unsaved text, and the document is never switched automatically. The theme version of a saved document can be pinned explicitly in the web app, the VS Code GUI and the command line; the limits are in the record of pinning. There is no dedicated way to create a new theme without a file name, and no GUI for managing themes. Existing `theme.css` and `theme.json` folders are not this `.koma` document format.
### Frames from sample elements
A theme's layout frames are defined by sample elements placed in the theme document.
#### How to write
On a layout page of `theme.koma` (a page whose settings have `layout:`), place elements with positions and sizes (`x`, `y`, `w`, `h`, in `%` or `px`). Each element is, as it stands, the definition of the frame of its name. `[title x=6% y=11% w=88% h=9%: sample]` is the `title` frame; `[box slot=left x=… : …]` is the `left` frame.
#### Details
- Only elements placed in frames by name (built-in tags with a default frame, custom tags declared in the document YAML, and elements with `slot=`) name a frame. A `box` without `slot`, flowing elements such as figures and tables, and unknown elements define no frame.
- The footer frame: on every layout, the footer stands with the footnotes in the footer band below the body ([The bottom band](#bottom-band)), at the frame's left edge and width; it grows upward with its content as the band does. An element whose document writes `y` or `h` is placed as written.
- When two elements define the same frame, the first is used and the second is reported as `theme-slot-duplicate`. A naming element with no position or size, a unit other than `%` or `px`, a size of 0 or less, or the same attribute written twice is not a frame definition, and is reported in the source panel as `theme-slot-no-geometry` (“Give the theme's frame a position and a size”). The source is not rewritten.
- Frames without a definition use the built-in default positions. Sample text is not copied into documents. Frames are ordered as in the sample, and new pages write frames in that order.
- Vertical order: on a layout whose theme CSS writes a grid on `page-body`, the sample's vertical position is the value the grid is made from, and the grid decides where the frame is drawn ([Layout grids](#layout-grid)). The sample frames remain for the horizontal position and width, for the position on layouts without a grid, and as the way to edit the sample on the canvas.
- Page edge lines: `page { border-bottom: … }` and `@layout name { page { … } }` in the theme's CSS draw a line at the edge of every page or of a layout's pages ([Page-edge lines](#page-edges)). The line is drawn inside the page and moves neither frames nor the bands. PowerPoint looks the same.
- The padding: `page { padding }` and `@layout name { page { padding-… } }` in the theme's CSS decide the room around the page's header, body and footer bands on that layout's pages, and so the flow's area, which fills the body ([Placement](https://komalang.org/spec/semantics/#placement), [Layout grids](#layout-grid)). They move no frame placed by its sample's `x` and `y`. The built-in themes (`default`, `talk`, `report`) align left and right with the body frame's sides (5%, 7%, 3.5%); on each layout with a grid they write its first frame's top as the top padding ([Layout grids](#layout-grid)). Elsewhere the top stays the page kind's default and the bottom is the page number's margin, with the footer band keeping the rest of the kind's bottom padding ([The bottom band](#bottom-band)), and the flow starts at the body's top left.
### Layout decoration
A layout's decorations are elements on a layout page of the theme document that name no frame.
#### How to write
On a layout page of `theme.koma`, place a `box`, `shape`, line, figure or the like with neither `slot` nor a frame name. There is no special notation. On every page using that layout, they are drawn at the written position and size, behind the page's edge lines ([Page-edge lines](#page-edges)) and its content.
#### Details
- They cannot be selected or moved from a document, and do not appear in the document's source panel. To change them, edit the theme. When the theme document itself is open, decorations are ordinary elements to edit. Speaker notes are never decorations.
- Whether covers and section openers have them depends on whether the theme places decorations on that layout's page.
- The canvas, page list, presenting, HTML, PDF and images draw them alike.
### Layout grids
Every page is a header, a body and a footer stacked inside the page's padding; a theme lays out a layout's frames with the CSS grid it writes on `page-body`, and the body's rows measure the body.
It replaces a grid written on `page` that measured the whole page (page bands).
#### How to write
In the theme's CSS, for each layout:
```
@layout content {
page-body { grid-template-rows: minmax(43px, auto) 11px minmax(97px, auto) minmax(65px, auto) 65px minmax(0, 1fr); }
label { grid-row: 1; }
title { grid-row: 3; }
subtitle { grid-row: 4; }
main { grid-row: 6; }
}
```
`page-header`, `page-body` and `page-footer` name the three bands of the page, as `page-number` names its number ([Looks for one layout](#layout-rules)). They take neither ID nor class and are allowed inside `@layout name { … }`.
#### Details
- Structure: the page (`page`) keeps its size, its padding and the origin of `x` and `y`. Inside its padding stand, one under the next, the header (`auto`; with nothing in it, 0 high), the body (`minmax(0, 1fr)`) and the footer (`auto`, up to its `max-height`, [The bottom band](#bottom-band)). The three bands are drawn on every page of every document type (slide, article, poster) and every layout; an empty one takes no room, so nothing switches on what the page holds.
- Drawn as: `` (the page) holds `.koma-page-header`, `.koma-page-body` and `.koma-page-footer` as its grid rows (Koma writes `display: grid; grid-template-rows: auto minmax(0, 1fr) auto` and the padding on the page itself). The page's decorations ([Layout decoration](#theme-decoration)) and its edge line ([Page-edge lines](#page-edges)) stay on their own layers over the whole page.
- Header: kept for the deck's running head, nothing written on a page; nothing is drawn in it yet, so it is 0 high. The deck's logo keeps its corner place over the page ([The document's logo](https://komalang.org/spec/structure/#logo)). `[label:]` is a slot of the body, not the header.
- Body: the frames of the layout (`label`, `title`, `subtitle`, `main`, cover fields, custom frames) are the body's direct children. The body is always a CSS grid, one `minmax(0, 1fr)` row and column unless the theme writes its own; authors never write its `display`. The page's flow ([Placement](https://komalang.org/spec/semantics/#placement)), what the page holds without `x` or `y`, is drawn in `.koma-page-flow`, a direct child of the body that fills the body's whole area and adds nothing to the height of its rows. Continuous text on articles and blank layouts therefore starts at the body's top and ends at the footer's top.
- Frames in the grid: the frames the theme gives a `grid-row` that the document writes neither `y` nor `h` for. A frame the document writes `y` or `h` for is placed as written, from the page's origin (out of the grid), and moves no other frame; the theme's `grid-row` does not apply to it.
- Placed elements: an element with `x` or `y` is placed from the page's top left corner, never the body's, whatever band its source belongs to ([Placement](https://komalang.org/spec/semantics/#placement)). The bands are not containing blocks; the page is.
- A frame is as tall as its row. A `minmax(least, auto)` row takes its least height even with little in it and grows with more; an `auto` row is 0 when its frame is not written.
- Declarations that apply in a theme's CSS: on `page-body`, `grid-template-rows`, `grid-template-columns`, `row-gap`, `column-gap` and `gap`; on `page-header`, `min-height` and `max-height`; on `page-footer`, `min-height`, `max-height`, `row-gap`, `column-gap` and `gap` ([The bottom band](#bottom-band)); on a frame, `grid-row`, `grid-column`, `align-self`, `justify-self`, `margin-block-start`, `margin-block-end` (and `margin-top`, `margin-bottom`), `min-height`, `max-height`. `page-header` and `page-footer` also take looks: `color`, `background`, `border`, `padding`, `font-size`, `font-weight`, `font-style`, `font-family`, `line-height`, `letter-spacing`, `text-align` and `opacity`, with their longhands, so a theme can draw a rule line over the footer. Custom properties apply to every band. Anything else on a band, such as `transform` and `translate`, which move only the drawing, or a look on `page-body`, is said where it is written and left out; the rest of the rule applies. Looks of the body stay on `page`, its decorations and its frames.
- A `%` in `grid-template-rows` is of the body's height, as in CSS for the grid container; a `%` margin is of the width. The official themes write rows in px of a 1080 px page (scaled with the page) and cut them to a 64th of a pixel as the samples' positions are. A row that only skipped the page's top margin or reserved the footer is not written: the padding and the footer are their own. Each layout with a grid writes its first frame's top as its top padding (`@layout content { page { padding-top: … } }`) and, when its last frame does not end at the body's bottom, the room under it as the footer band's `min-height`, so frames stand where their samples are while the footer is short.
- Horizontal position and width come from the sample frame (`x`, `w` of [Frames from sample elements](#theme-frames)), measured from the page's left edge as before; Koma subtracts the page's left padding when it places the frame in the body.
- Content pages: label, title and subtitle from the body's top, then `main` in the last `minmax(0, 1fr)` row. A two-line title pushes the subtitle and the main frame's top down; the main frame's bottom is the body's bottom. The title grows to three lines and is then fitted. An unwritten label or subtitle keeps its least height, so pages of one layout start their main frame at one place when the title is one line and the header is the same.
- Section openers: rows `1fr auto auto fixed`, all in the body. The title keeps its bottom and grows upward with more lines, the label right above it; the subtitle stands in the last row.
- Covers: title and subtitle from the body's top; authors, affiliations and date from the body's bottom in `auto` rows, so an unwritten one takes no room and the gap before it does not remain either.
- Migration: a `display`, `grid-template-rows`, `grid-template-columns`, `row-gap` or other grid declaration written on `page` is reported as `legacy-page-grid` (warning) at its rule and left out; the rest of the rule applies. `koma format --write` on a `.koma` document or `theme.koma` writes each such grid in its own CSS for the body, so its frames stay where they were drawn: a leading fixed row that holds no frame becomes the layout's top padding, a closing fixed row that holds no frame becomes the footer band's `min-height`, a closing row that holds frames ends at the body's bottom, a `%` of the page is written as that share of the page's height (`var(--page-height)`), and the frames' `grid-row` numbers follow their rows. The official themes are written this way. A grid in a CSS file the document names is reported but not rewritten. `legacy-page-grid` is removed in 0.2.0.
- Stacking frames (`stacks:`) are retired without compatibility fallback or migration notes.
- Canvas, page list, presenting, HTML, PDF, images and PowerPoint draw the same. Moving a grid frame on the canvas writes `x` and `y` from the page's origin, which takes it out of the grid.
### The bottom band
The footer band holds the footer, the footnotes and the page number; as it grows, the body above it shrinks, and the two never overlap.
It replaces a footer band in the last row of the layout's grid that left the body's bottom in place (page bands).
#### How to write
As before (`[footer: …]`, `[^1]`). The theme may cap the band with `page-footer { max-height: … }`, keep room for it with `min-height`, and draw it with looks such as `border-top` ([Layout grids](#layout-grid)).
#### Details
- In the band, the footer and the page's footnotes stand in one column, one under the next (`row-gap`, 0.5em by default), aligned to the band's foot; the page number stands to their right on the line of the last one, the page number's margin (`--koma-counter-margin`, 3% of the page's height) from the page's right edge. The band reaches right to that margin, past the page's right padding, where the page number has always stood. The column's left edge and width are the footer frame's ([Frames from sample elements](#theme-frames)); footnotes with no footer start where the default footer frame does, 5% from the page's left edge, and reach the page number.
- Drawn as: `.koma-page-footer` holds `.koma-footer-group` (the `[footer:]` element and `.slot[data-slot="references"]`) and `.page-counter`. A page with neither footer, footnotes nor page number has an empty band, 0 high.
- Room: the band is at least its `min-height` tall, its content aligned to its foot. Where the page's CSS writes no bottom padding, the page's bottom padding is the page number's margin and the band's `min-height` is the rest of the page kind's bottom padding, so the page number stays at its corner and the body ends where the page kind's padding does while the footer is short. A page rule that writes its bottom padding sets that margin itself, and the band then keeps no room of its own.
- Growth: the band takes the height of its content up to its `max-height` (a `%` is of the page's height inside its padding; one third when the theme writes none). The body takes what is left, so the main frame's bottom moves up by what the band gains, and frames in the body are fitted in their new size. Past its `max-height` the band's text is made smaller (to half), and what still does not fit is reported as `overflow`.
- Order: the header and the footer are measured first, then the body, so fitting never runs in a loop.
- The same band serves every layout and document type, with or without a grid in the body; there is no separate placement for pages without a footer or without a grid. A footer the document writes `y` or `h` for is placed as written from the page's origin; its footnotes stay in the band.
## Style classes
### Named styles
Style classes name appearances for boxes, callouts ([Callouts](https://komalang.org/spec/elements/#callout)), and shapes. The theme defines their CSS.
#### How to write
Write a class in the tag, as in `[box .tint: …]` or `[callout .card: …]`. Themes support the following choices in this order. Each background supports text contrast of at least 4.5:1.
| Name | Class | Appearance |
| --- | --- | --- |
| None | — | No fill or outline |
| Outline | `outline` | Rounded corners with a 2 px `--koma-line` border, 1.5 pt in PowerPoint |
| Card | `card` | White background, shadow and rounded corners |
| Tint | `tint` | Pale role-colour background and rounded corners |
| Bar | `bar` | Left line with a pale background derived from it |
| Fill | `fill` | Rounded `--koma-primary` fill and `--koma-on-primary` text |
#### Example
```koma
[title: Six styles]
[main:
[col:
[box:
None
]
]
[col:
[box .outline style="flex: 1":
Outline
]
]
[col:
[box .card style="flex: 1":
Card
]
]
[col:
[box .tint style="flex: 1":
Soft
]
]
[col:
[box .bar style="flex: 1":
Bar
]
]
[col:
[box .fill style="flex: 1":
Fill
]
]
]
```
> Six boxes side by side: None, Outline, Card, Soft, Bar and Fill.
#### Details
- Explicit element fields take precedence. Apply `border-color`, `border-width`, and `border-style` to all sides of Outline or the left side of Bar. Outline defaults to the theme line or a 22% text-colour mix with the background. Default's line and primary are `#d9dbe5` and `#2d287f`, Talk's are `#d8dadf` and `#0f6b63`, and Report's are `#d8dce2` and `#3b4754`. Their primary text is white. Authored `background-color` overrides the style background. Fill defaults to white text, falling back to `#111827` if white lacks 4.5:1 contrast. Authored text colour wins.
- Visible fill, border or shadow earns padding on a box or callout whether produced by a class or authored style. An unstyled box uses zero padding for alignment with surrounding content. For visible surfaces the defaults are `0.75em` vertically and `1em` horizontally, relative to the box's font size. Use ordinary CSS padding and radius to override them. All official themes use the default padding. Outline and Bar draw their lines inside padding so their appearance does not shift text.
- Explicit `padding` and side-specific CSS override the applicable defaults ([Elements](https://komalang.org/spec/elements/#element)). Top and bottom defaults are equal. Avoid adding a final paragraph, list, or nested element's trailing gap inside the box. Flow from the top, with callouts vertically centred ([Callouts](https://komalang.org/spec/elements/#callout)). The default radius is 12 px and Report uses 6 px. Padding fits within the box width.
- Tables use four combinable classes, `grid`, `striped`, `accent`, and `row-heads`, shown together in the three official theme examples. Theme completion offers the five visible styles, these table classes, text classes such as `tag`, `sup`, `sub`, `mark` and `underline`, and named theme styles. Source completion identifies theme looks and also offers document CSS classes. Custom classes always remain in source.
- Shapes accept all six choices. Tint uses the shape's pale colour, Fill its colour and white text, Outline a thick line, Bar a left line and pale fill, and Card white with shadow. The style preserves the shape outline. Figures support Card and Outline only.
- A theme may add a heading band with CSS on a styled box's first heading. The built-in themes leave it unspecified.
- Use an element's CSS `list-style-type` for a custom marker or numbering. Quoted marker strings such as `"✔ "` and CSS values such as `decimal` apply to immediate list children. Nested lists keep their own values. Editor, presentation and export agree. Invalid unquoted markers and unknown names report `bad-value` without applying. A theme can provide a default.
- A folder theme can declare additional names in `theme.json` under `boxStyles` and define their CSS in `theme.css`. Show these classes after built-in styles.
### Inline classes
The official themes have the text classes `.sup`, `.sub` and `.mark`.
#### How to write
In text, write `[1]{.sup}` and the like; superscript is usually `^{…}`, subscript `_{…}` and highlight `==…==` ([Text inside elements](https://komalang.org/spec/text/#inline-markup)). The names follow HTML's element names; they are written alongside `.chip` ([Text inside elements](https://komalang.org/spec/text/#inline-markup)) and can be redrawn with the document's CSS. The official themes (default, talk, report) have them, so `unknown-class` is not reported.
#### Details
- `.sup`: `vertical-align: super`, text at 0.75em, `line-height: 0` (the line does not get taller).
- `.sub`: `vertical-align: sub`, text at 0.75em, `line-height: 0`.
- A highlight is drawn as a band of the `--koma-mark` colour over the lower 40% of each line. Its colour and height ratio (`--koma-mark-height`, `40%` by default) can be changed with the document's CSS. Text colour, weight and line spacing are inherited, and no space is added. Each wrapped line is drawn the same way. Body text and the default band have a contrast of 4.5:1 or more. The compatibility class `.mark` can be set independently of the document's CSS.
- Text with both `.sup` and `.sub` gets `.sub`, written later in the theme's CSS.
- Superscripts and subscripts in math are written `$x^2$`. `.sup` and `.sub` are for characters in text (`1^{st}`, `H_{2}O`, note marks).
## Page kinds and edges
### Values per kind of page
A theme can hold `--koma-*` values for each kind of page ([Kinds of page](https://komalang.org/spec/structure/#page-kind)), and pages take a default layout by their kind. The values are chosen by the kind, not the size.
#### How to write
In the theme's CSS, write the `--koma-*` values for text size, padding and spacing for each kind: for example, smaller body text and paper-style margins for documents, and sizes read from afar for posters. A theme of your own can write per-kind values by the same contract ([What a theme decides](#theme)).
#### Details
- A theme with no values for a kind uses its slide values. The built-in themes (Default, Talk, Report) hold values for all three kinds.
- The same theme name is used for every kind. Changing the kind keeps the theme; only the theme's values for the kind change.
- A poster is read from one to two metres: printed on A0, its body text is at least 24 pt (48 px, 36 pt, in the built-in themes) and its title about three times that. Themes multiply their title sizes by `--koma-title-scale` (1 for slides and documents, 1.75 for posters).
- The default layout: when neither the page nor the document writes `layout`, slides take `content`, as before; documents and posters take `blank` (no frames; what the page holds flows from the top inside the page's padding, [Placement](https://komalang.org/spec/semantics/#placement)). A page that uses frames such as `[title:]` writes `layout:`. An added page takes the layout of the page before it.
- Vertical spacing on documents and posters is set as on paper: it follows the text's size and leading and how blocks relate, and it is fixed by the kind's values, never closed up or opened out to fill a box. From tightest to widest: a paragraph or a list right under a local heading (`--koma-local-heading-gap`, 0.125em in the built-in values); items of a list and the pairs of a definition list (`--koma-item-gap`, 0.25em, half that between the items of a nested list, [Definition lists](https://komalang.org/spec/text/#definition-list)); paragraphs, and a paragraph and a list (`--koma-paragraph-gap`, 0.5em); the space around a display block (a table, figure, display math, code, quotation, diagram or grid), after a heading too (`--koma-block-gap`, 12 px on documents and 40 px on posters); and the space above a local heading after a block (1.35em). Each em is the text's own, so the spacing follows the text size of a box. A theme can set these values for the kind ([What a theme decides](#theme)); a document's `css:` and an element's `style` override them. Slides keep their own spacing, which fitting closes up ([HTML elements and reading order](https://komalang.org/spec/semantics/#html-elements)).
### Page-edge lines
Page edge lines draw a line such as a band along the bottom of the page without a background image (`linear-gradient` and the like cannot be exported to PowerPoint).
#### How to write
A page takes `border`, the per-side `border-top`, `border-right`, `border-bottom` and `border-left`, and their `-width`, `-color` and `-style` (also `border-width`, `border-color` and `border-style`). `page { border-bottom: 8px solid #2d287f; }` in the document's or theme's CSS applies to every page, `page.class { … }` to pages of that class, `@layout content { page { … } }` to pages of that layout ([Looks for one layout](#layout-rules)), and `style:` in page settings (`---`) to that page only (`style: "border-bottom: 8px solid #2d287f"`).
#### Example
```koma
---
style: "border-bottom: 16px solid #2d287f"
---
[title: A page with an edge line]
[main: The band at the bottom is a line written in the page settings' style.]
```
> A thick dark navy band runs along the bottom edge of the page.
#### Details
- A page's `style:` takes only the line declarations above. Other declarations (such as `color`) have no effect, keep their source as written, and are reported as `bad-value` (warning). A page's other looks are decided by the document's CSS and the page's `class` ([Page settings](https://komalang.org/spec/structure/#page-settings)). `style:` in document settings (`===`) is `setting-out-of-scope`.
- Layering: by the ordinary CSS cascade, every page in the document's and theme's CSS, then the layout (one class heavier), then the page's own `style:` (strongest). Each declaration layers on its own, so a layout can change only the colour.
- Drawing: the line is drawn inside the page, along its edge, below what is on the page. The page's size, padding, the flow's area, and the positions of frames and elements do not change with the line (the line may overlap content). HTML, PDF and images are as the browser draws.
## Official themes
### Text faces
Text faces: the default sans and mono are bundled and used first, and faces named by a document or theme are taken from the computer.
#### How to write
Write a face's name in `font-family` in the document's or theme's CSS.
#### Details
- The default sans and mono (Noto Sans CJK JP, Noto Sans Mono CJK JP) are bundled with both `koma` and KomaDocs and used first in default drawing, so every computer shows the same look.
- The serif faces are bundled only with KomaDocs, not with `koma`. A document naming the serif face under `koma` is drawn with it if the computer has it, and otherwise gets the warning below.
- Faces named by a document or theme are taken from the computer.
- When a named face is not on the computer, it is not replaced silently: a warning is given (not a failure). Only the first name in each text's list of faces (the one the writer chose) counts; later fallback names and generic families such as `serif`, `sans-serif`, `monospace` and `system-ui` do not. The warning names the face and, when known, the face used instead.
- `koma check --layout`: a `font-unavailable` warning per page.
- `koma export`: a `font-unavailable` warning, once per face, in the `--json` findings and on standard error. The output is made, and the exit code is that of a warning.
- How it is told: once drawing has loaded the faces, a sample string is compared on a canvas with three generic families (monospace, serif, sans-serif); a name that changes none of their widths is “not there”. A face the page declares is judged by its loading state. `document.fonts.check()` answers “there” even for names with no face, so it is not used.
### Font weights
The bundled faces have a face per weight, and a weight the face lacks is drawn with the nearest one.
#### How to write
Write the weight in `font-weight`. sans has faces at 400, 500 and 700; serif and mono at 400 and 700.
#### Details
- Bundled faces: sans (Noto Sans CJK JP) has three, Regular 400, Medium 500 and Bold 700; serif and mono have two, Regular 400 and Bold 700. Medium is Noto CJK's pinned static face, subset and bundled by the same steps as the others (text faces). Variable fonts are out of scope.
- Each weight has its own `@font-face`, and the browser loads only the faces used. A document that does not use Medium gets nothing more.
- A face counts as missing only for a reason: no face matched, a face ended in error, the font set refused, or the face was still not in after 60 s. A face still loading after 15 s is slow, not missing, and is waited for. A failure is not remembered, so the next view or output asks again. Each fallback names its face and one of four reasons (no face matched, a face in error, refused, or timed out) in the page's `data-text-font-failure` and the web inspector's console.
- A weight the face lacks is drawn with the nearest face by CSS weight matching. The Medium face covers 500 to 600, so `font-weight: 600` in sans is drawn with Medium (500). In serif and mono, 600 is Bold (700). Built-in looks (page numbers, authors) write their weight as 700.
- `koma check --layout`: writing a weight a bundled face lacks gives the warning `font-weight-unavailable` (as `"Noto Serif CJK JP" has no 600; drawn at 700`), once per face and weight per page. Weight added by the browser's `bolder` for `strong` inside bold text does not count.
- HTML and PDF embed only the faces used (Medium only when Medium is used).
### Line height of titles
The line spacing of titles and subtitles depends on the document's language (`lang`, [Document settings](https://komalang.org/spec/structure/#deck-settings)).
#### How to write
Nothing needs to be written. To change it, write `title { line-height: … }` and the like in the document's or theme's CSS (no `:lang` is needed).
#### Details
- In a `lang: ja` document, titles (`title`) are 1.25 and subtitles (`subtitle`) 1.4. In `en`, other languages, and documents without `lang`, titles are 1.15 and subtitles 1.3. A page whose `lang` differs from the document's follows the page's language.
- Covers, section openers and ordinary pages use the same values; only the text size changes with the layout. The built-in CSS sets `--koma-title-line-height` and `--koma-subtitle-line-height` by the page's language, and titles and subtitles are drawn with them. The three official themes write no line spacing for titles and subtitles.
- Precedence: `line-height` in an element's `style` > `line-height` written in the document's or theme's CSS > the default by language.
- Titles that mix Japanese and Latin text are drawn with one line spacing per element too. The gap between title and subtitle, body line spacing and letter spacing do not change.
- A title that does not fit its frame shrinks as the rules for fitting text to its frame says, keeping its line spacing. The canvas, presenting, HTML, PDF, images and PowerPoint use the same line spacing.
### Brackets at line ends
The space of full-width brackets at line ends follows CSS Text 4's `text-spacing-trim`, and the official themes trim it on Japanese pages.
#### How to write
Write `text-spacing-trim` with a standard value (`normal`, `space-all`, `space-first`, `trim-start`, `trim-both`, `trim-all`, `auto`) in a theme's CSS, the document's `css:` or an element's `style` ([Elements](https://komalang.org/spec/elements/#element)).
#### Details
- Other values are `bad-value` in an element's `style`. The ordinary CSS cascade and inheritance apply.
- The three official themes (default, talk, report) use `trim-both` on Japanese pages (`lang: ja`; by [Page settings](https://komalang.org/spec/structure/#page-settings), a page without a language is read as Japanese too). The theme writes `--koma-ja-text-spacing-trim: trim-both` on `page`, and the built-in CSS puts that value as `text-spacing-trim` on Japanese pages only (a rule without specificity). Japanese pages of themes that do not write the variable, and pages that are not Japanese, are `normal`. A value written in the document's CSS (`page { text-spacing-trim: normal }`) or an element's `style` wins.
- When the browser knows the value, the browser typesets it. For values it does not know, Koma fills in only part of the standard, where the value applies, and only these two:
- When a paragraph's first character is an opening bracket `(`, `「`, `『`, `【` or `〔`, the half space before it is trimmed (`trim-start`, `trim-both`, `trim-all`).
- When a paragraph's last character is a closing bracket `)`, `」`, `』`, `】` or `〕`, the half space after it is trimmed (`trim-both`, `trim-all`).
- A paragraph is one run of text of a paragraph, heading, table cell, definition-list term or explanation, or a frame such as a title. Footnotes and task items have a number or box in front, so only their ends count. Line ends wrapped inside a paragraph, after a line break (`
`), and between brackets side by side are left to the browser. The behaviour of `space-first`, `normal` and `auto` is not filled in.
- How it is filled in: when drawing, only those two characters are put in marked `span`s, and the trimming CSS (a −0.5 em outer margin on the `span`) is written only inside `@supports not (text-spacing-trim: )` for each value. Where the browser can typeset the value it has no effect, so nothing is trimmed twice. There is no switching per renderer and no measuring on every keystroke. The value is read from a variable holding the same value as `text-spacing-trim` (`--koma-text-spacing-trim`, which Koma adds to each declaration), so even unknown values cascade the same way. The source and tidying are unchanged.
- When the Chromium Koma draws with knows `trim-both` (`CSS.supports('text-spacing-trim', 'trim-both')` is true), these filling `span`s and their CSS are removed.
- HTML, PDF, images and the canvas agree.
### Cover and section pages
The official themes' covers and section openers have no colour bands, no full-width hairlines and no short rule above the subtitle, and use the primary colour only for a section opener's label.
#### How to write
Choose the cover or section opener layout (`layout: cover`, `layout: section`); nothing else is needed. Sizes are px of 1920 × 1080, written in the theme's sample frames ([Frames from sample elements](#theme-frames)).
#### Details
- Section opener frames: a section opener's `label`, `title` and `subtitle` stand in the rows `1fr auto auto fixed` of the theme CSS's grid ([Layout grids](#layout-grid)), and do not use the three-line rule below, which is for covers only. The title keeps its bottom edge and grows upward by its lines, and the label stands right above the title's first line (with the sample frames' gap). With a one-line title it is as in the sample; with two or three lines the label stays with the title, and the title does not shrink. The subtitle's frame does not move.
- Title and subtitle frames (for section openers, as above): a cover's `title` frame is three lines of that layout's title size and line spacing (plus the built-in 0.15em space below the title, rounded up to px). The title sits at the frame's bottom (`align-content: end`, [Page layouts](https://komalang.org/spec/structure/#layouts)). The `subtitle` frame is two lines of that layout's subtitle size and line spacing, aligned to the top. Between the bottom of the title frame and the top of the subtitle frame: 28 px for default, 2.65% of the page height for report (about 28.6 px at 1080 px). So the boundary between title and subtitle stays put whether the title has one line or three. A title of more than three lines shrinks as the rules for fitting text to its frame says.
- The line spacing used is that of Japanese documents ([Line height of titles](#title-line-height): title 1.25, subtitle 1.4; default's cover subtitle is 36 px × 1.4 × 2 = 100.8, so 101). In other languages the line spacing is tighter, leaving space above the title frame and below the subtitle frame.
- default: the left margin is 96.
- Cover: the top line has `label` on the left (the same colour and weight 400 as body pages' labels, only the size 26 px). The top right is left free for the document's logo, with no theme element. `title` is 68 px, its frame at y=266 and 266 high (68 × 1.25 × 3 + 10.2, rounded up), its bottom at y=532. `subtitle` is at y=560 and 101 high (36 px, weight 400, the weak text colour ink-2). Below, aligned left: `authors` at y=862 (36 px, 700), `affiliations` at y=922 (28 px, ink-2), `date` at y=966 (28 px, ink-2). The bottom right is left free for the page number.
- Section opener: `title` is 78 px, its frame at y=416 and 120 high, its bottom at y=536. `label` (30 px, 700, primary colour) is right above the title frame at y=372, 40 high. `subtitle` is at y=560, 140 high.
- Ordinary pages and the table of contents (outside the cover and section rules; frame values only): an ordinary page (`content`) has `label` at y=4%, 4% high; `title` at y=9%, 9% high; `subtitle` at y=18%, 6% high; `main` at y=30%, 60% high. The table of contents (`outline`) has `label` at y=4%, 4% high; `title` at y=9%, 9% high; `main` at y=26%, 64% high. All are 5% from the left and 90% wide. There are gaps below the label (8%) and above the title (9%), and below the subtitle (24%) and above the body (30%), so nothing overlaps at 16:9 or 4:3.
- Spacing: the frames of covers, section openers and content pages stand in the rows of the theme CSS's grid ([Layout grids](#layout-grid)). The coordinates above are their places when the title is one line and every field is written.
- On a cover, `authors`, `affiliations` and `date` go from the bottom, and an unwritten one takes no room (the fields above it move down). The gaps between them are written with `margin-block-start`.
- On a content page, a two-line title moves the subtitle and the start of the body down. The body's bottom edge does not move; only a growing footer band moves it up ([The bottom band](#bottom-band)).
- A one-line title sits right above the subtitle, leaving space above. Second and third lines grow upward.
- Without a subtitle, its place is simply empty; the title and the lines below do not move.
- Without `date` or `affiliations`, that line is simply empty; the other lines do not move.
- Report (the same parts and rules as Default, each in its theme's places): no colour bands, full-width lines or rules. On the cover, `label`, `affiliations` and `date`, and on covers and section openers `subtitle`, are ink-2 at weight 400 (the label at the same weight as body pages' labels, [What a theme decides](#theme)). `authors` is 700. A section opener's `label` is 700 in the primary colour, standing right above the title's first line ([Layout grids](#layout-grid)). Title and subtitle frames follow the rules above.
- report: aligned left with the same frame roles and order as default. Left and right margins are 4%, and frames widen to the outer margin. Body text is 30 px. The ratios of each element's text, unitless line spacing, and spacing proportional to text size are shared with default.
- Talk has no default frames for `label` and `subtitle` on the cover, section openers, body pages and table of contents. The cover centres the title, with authors, affiliations and date packed below it. A section opener has only the title; body and table-of-contents pages give the body plenty of room below the title. The source and explicit coordinates are kept, and a tag without a position is treated as having no frame defined.
- The rule mechanism (the theme's choice): the built-in CSS draws a short rule in the primary colour before the subtitle of covers and section openers only when the theme writes `--koma-heading-rule-width`, `--koma-heading-rule-height` and `--koma-heading-rule-gap` on `page` (and `--koma-heading-rule-margin-inline: auto` to centre it). The three official themes do not. In a theme that does, HTML, PDF and images draw the same picture.
---
[Specification](https://komalang.org/spec/) · Chapter 6 / 7
# Semantics
What a document means once it is read: where each element is placed, how large it is, and what is reported.
## Placement and size
### Placement
Placement is where on the page an element is drawn: in a slot, at a free position, or in the flow.
#### How to write
A slot element (such as `[title: …]`) goes to its place in the layout. An element with `x` or `y` goes to that position in its parent. Any other element, and text written directly on a page, joins the flow where it stands.
#### Example
```koma
Text written directly on the page joins the flow as a box.
[box .tint x=55% y=60% w=35%:
A box with a position goes there.
]
```
> A paragraph of bare text flowing from the top left, and a soft box placed at a position at the lower right.
#### Details
- Slots: the position the layout decides ([Page layouts](https://komalang.org/spec/structure/#layouts)). Writing `x y w h` overrides it with those values.
- An element with `x` or `y`: a free position in its parent.
- Neither: the element joins the flow where it stands. With only `w` or `h`, that is its size in the flow.
- **The flow directly on a page**: an element placed directly on a page without `x` or `y` (`[col:]`, `[row:]`, `[figure:]`, `[box:]` and so on) has the page (`page`) as its parent and flows in the page's area. `page` is a stand-in parent never written in the source. On every layout, the page's area is its body band: inside the page's padding (`padding`), below its header band and above its footer band ([Layout grids](https://komalang.org/spec/styles/#layout-grid), [The bottom band](https://komalang.org/spec/styles/#bottom-band)), unaffected by frames such as the body frame. The padding is set by the CSS `page { padding: … }`, and per layout by `@layout content { page { padding-top: … } }` ([Looks for one layout](https://komalang.org/spec/styles/#layout-rules)). Sides not written use the page kind's `--koma-padding-block` (top) and `--koma-padding-inline` (left and right); a bottom not written is the page number's margin, and the footer band keeps the rest of the kind's `--koma-padding-block`, so the area ends where it did while the footer is short. `%` is of the page's height for top and bottom, and of its width for left and right. When the page has a footer or footnotes, the area ends above them, at the footer band's top ([Footnotes](https://komalang.org/spec/text/#footnote)). `[col:]` and `[row:]` split this area ([Columns and rows](#split)). It is not an implicit body, and the theme's `main` rules do not apply. `x` and `y` are positions on the whole page (a full-bleed image can be placed too).
- **Overlap with frames**: only when the page's area overlaps the rectangle of a frame tag written on that page (`title`, `main` and so on) is it drawn as it is, with `flow-over-slots` (warning) reported for each flowing element, advising to write it inside `[main:]` to put it in the body frame. The overlap is decided from the page's padding and the frames' rectangles, the same way in `koma check` and the app. Only sharing area overlaps; touching edges do not. When the padding starts below the headings, a page of headings alone is not reported. `[main:]` and bare text on the same page are reported, since the body frame overlaps the area. Elements with `x` or `y` are not reported.
- **Unquoted text**: text directly on a page that is in no element is read as a `[box:]` with no placement written (an element in the flow directly on the page). It is a box written without brackets or `[box:]`: its drawing and export (HTML, PDF, PowerPoint) are the same as for `[box: …]` holding the same text. It is not an implicit body, and the theme's `main` rules do not apply.
- A `box` with no style has no border or background; it is just a rectangular area. Reading bare text as a box does not draw a frame around it.
- Runs: text continuing between elements is one box. Paragraphs separated by blank lines, and comments (`;`) between them, go in the same box. An element between them (including a freely placed box) splits the box there, and the parts join the flow in the order written. A line of only spaces draws nothing.
- Decided by syntax alone: document and page settings (including the document's CSS, `css:`), reserved `:::` blocks, comments, notes, code and math fences, and text inside elements keep their own meaning. A footnote definition `[^id]: …` becomes a footnote of the page, and a run of only footnote definitions makes no box.
- Lines starting with `[` in column 0: lines [When brackets are an element](https://komalang.org/spec/elements/#element-recognition) reads as text (`[1] Smith 2020.`, `[NOTE] check this`, `[docs](url)`, `[[wiki]]`, `[0, 1)` and the like) go into the box as ordinary text. Half-made element lines — those reported as `missing-colon` (`[title Koma]`, `[box x=10%]`, a block whose opening line has no `:`) and as `unclosed-element` (a half-typed `[ti`, or `[main` before its `]` is written) — are not put in a box and not drawn, and the diagnostic is given. Lines directly on the page after an element without a close are its content (its `]` is still missing), and no box is made up to the end of the page. This is a syntax rule by a line's first character, so that half-typed source does not make the drawing flicker.
- Reports: like other flowing elements, `flow-over-slots` is reported only when the page's area overlaps a frame written on that page.
- Document and page settings, comments and notes are not text for display. The content and placement rules of explicit elements such as body are kept.
### Who decides size
An element's outer rectangle comes from the position and size written in the document, or else from the layout's default, and its content flows inside it.
#### How to write
To decide position and size, write `x`, `y`, `w`, `h` on the element.
#### Details
- A theme document may define a layout's default rectangles, but never overrides positions and sizes written in the document. When the content does not fit, the text is shrunk (RND's fit) or the overflow is reported.
- Shrinking (the rules for fitting text to its frame seen from the language): on a slide, an element that does not fit first narrows its stretchable gaps together and continuously: the space between items and paragraphs (lists, tables of contents, definition lists) from the theme's wide value (`--koma-item-gap`) to its narrow value (`--koma-item-gap-min`), and the block gap around display blocks towards 0.35em ([HTML elements and reading order](#html-elements)). A document's or a poster's gaps are its kind's and never narrow ([Values per kind of page](https://komalang.org/spec/styles/#page-kind-values)). If it still does not fit, or on a document or a poster, all its text sizes (body, headings, lead, code, captions, footnotes) are reduced together by the same ratio, the largest ratio that fits, down to half. The rectangle's position and size do not change. A page's subtitle (`subtitle`) and label (`label`) are never shrunk: they keep their size, and overflow is reported when they do not fit ([Page layouts](https://komalang.org/spec/structure/#layouts)). Shrinking is decided for each slot and each element placed on the page; a size written in the document is used as it is when nothing overflows. A shrunk element is reported by `koma check --layout` as `text-shrunk`, with how many px of width or height would fit it at its own size (output specification).
- Overflow: an element's content sticking out below or beside its rectangle, or a placement outside the page. Glyphs drawn slightly beyond their line's height (as Japanese faces do) are not overflow. A figure with only a width written is as high as its picture and caption, so the element holding it, not the figure, takes the overflow. When it does not fit even at half size, `koma check --layout` and `koma export` report the overflow.
## Splitting an area
### Columns and rows
Columns and rows are elements that split their parent's area across or down.
#### How to write
Write `[col:]` as many times as the columns you want across, and `[row:]` as many times as the rows down. To change the ratio, write `weight` (`[col weight=2: left]` and `[col: right]` give 2:1).
#### Example
```koma
[title: Two columns, 2:1]
[main:
[col .ruled weight=2:
The left column is twice as wide as the right.
]
[col:
The right column
]
]
```
> The body split into a wide left column and a narrow right column, with a vertical line between them.
#### Details
- The area split is in the parent: inside `[main:]` the body frame, inside a positioned `[box:]` that box, directly on a page the page's area (inside its padding, [Placement](#placement)).
- In one parent, a run of `[col:]` with no text or other element between them is one split across, and a run of `[row:]` one split down. Unquoted text directly on a page is a `[box:]` ([Placement](#placement)), so between splits it separates the runs like an explicit `[box:]`, and flows outside the splits at its natural height. Half-made element lines (`missing-colon`, `unclosed-element`) and the unclosed content after them are not drawn and make no box. Source order is never changed. A single `[col:]` is a split too (one area filling the parent). `[row:]` may go inside `[col:]`, and `[col:]` inside `[row:]`.
- Size: `weight` is a positive finite number (unitless, 1 by default). What is left of the split's axis after the gaps is shared in the ratio of the siblings' `weight` (`2` and `1`, like `0.2` and `0.1`, are 2:1, and both use all that is left). The ratio does not change when content overflows (overflow is reported). Zero, negative and non-numeric values are reported as `bad-weight`. Only the editing view draws them as 1; `koma check` and `koma export` do not pass, and no file is written.
- Height of a split in the flow: a split across (a run of `[col:]`) is as high as its tallest column's content, and does not stretch to the frame's bottom. But inside an element whose file writes a height (`h`), inside an area of a split down that shares height, and in the flow directly on a page (when the split across is that flow's only item), the split across fills what is left of that height ([Cards without positions](#cards); a split with a column holding only one picture does not fill in a row's area or directly on a page, since the picture keeps its aspect ratio) (overflow is reported if it does not fit). The columns side by side all take that height. Following elements come right below. Freely placed children do not count towards the content's height. When the content does not fit its parent, text shrinks or overflow is reported ([Who decides size](#size)), and columns do not shrink — except that a run with a column holding only one figure or picture shrinks to the height that fits its parent, the figure shrinking with its column.
- Column content: a column lays out its content from the top. When a column holds exactly one box with a visible ground, line or shadow (a style class, or a fill, line or shadow in `style`, or a callout) and nothing else, that box stretches to the column's height (content from the top; a callout centred vertically, [Callouts](https://komalang.org/spec/elements/#callout)). With several boxes, or text or figures beside the box, nothing stretches. When the column itself has a ground or line, that surface fills the column's height. When a column holds only one figure (`[figure:]`) with no width written and no height or a `%` height, or one picture-only paragraph (the column's height comes from its content, so a `%` height has no effect), the figure is drawn at the column's full width, fitted to the height if that is short (keeping its aspect ratio). A figure beside other things is drawn at its own size.
- Gaps: the gap between a split's areas is `gap` in the `style` of the element holding the split (`style="gap: 24px"`). It is a look, so it is not written as an attribute ([Elements](https://komalang.org/spec/elements/#element)). Two values are the row gap, then the column gap. Without it, the theme's default (`--koma-gap`). The gaps of that element's flow do not change. In an element without a split, `gap` is the gap of its direct flow ([Cards without positions](#cards)).
- Dividing lines: when any `[col:]` of a run has the class `ruled`, a vertical line is drawn between each pair of adjacent columns; in a run of `[row:]`, horizontal lines. The line has the theme's line colour (`--koma-line`, or else the text colour mixed lightly into the ground), is 2px wide, sits in the middle of the gap (half the gap on each side), and is as long as the split (for a split across, the height decided by the height rules above). PowerPoint draws a line at the same place, in the same colour and width.
- Vertical alignment: `[col:]` and `[main:]` put what they hold at the top, middle or bottom of their frame with `align-content` in `style` (`start`, `center`, `end`; the same with `safe`). Without it, from the top. Column height follows the height rules above (columns side by side take the tallest one's height), so in two columns of a figure and text, `center` on the text column puts the text at the middle of the figure's height. The theme's and document's CSS can set a default per layout, as `@layout content { main { align-content: center; } }` (no new notation is added). When a frame holds a split, or only one stretched box or figure (a vertical flex), the same value works the same way (marked with `data-align` after drawing). In an aligned frame, the space below the last paragraph or element is 0, so the visible content sits at the middle or bottom. The single HTML file is written with the same positions.
- The first heading in a column has no space above it. The space between a heading and its text stays the theme's heading gap.
- Height of a split down: inside a parent of set height (the body, an element with `h`, an area of a split down that shares height), when a split down (a run of `[row:]`) is the only thing in that parent's flow, the rows share the parent's height in the ratio of `weight`. A split down beside other things has its content's height, like a split across. A split down in a parent whose height is not set is reported as `split-unresolved`: the editing view draws its content flowing down as it is, and `koma check` and `koma export` do not pass.
- Flow gap (the theme's `--koma-flow-gap`, `1em` by default): in the body frame, inside elements, in columns and in the flow directly on a page, when either of two things following each other down is an element (a box, callout, figure, table, a run of `[col:]` or `[row:]`, a `[group:]`) or a Markdown table, the gap between them is this one value. It is never less than an element's inner padding (`--koma-style-pad-block`). With `gap` written in the `style` of an element without a split, the gap of its direct flow is that value, and the inner padding is not a minimum ([Cards without positions](#cards)). Gaps between paragraphs, headings and lists stay the theme's text spacing.
- Freely placed elements (`x` or `y`) do not join a split. A `[col:]` or `[row:]` with `x` or `y` is a free element, not an area. Even inside a split, it is placed in the parent's content rectangle ([Elements](https://komalang.org/spec/elements/#element)).
- Examples: `[col weight=2: left]` / `[col: right]` is two columns, 2:1. `[col:` / `[row: top]` / `[row: bottom]` / `]` / `[col: right]` is two columns, the left one split into top and bottom (a `[col:` whose content runs over several lines closes with a `]` at the end).
- Figures side by side: when each `[col:]` of a run across holds exactly one `[figure:]`, their picture areas line up. The area's height is that of the tallest picture with each figure fitted to its column's width, but no more than what the column leaves above its longest caption. Pictures sit at the bottom of the area keeping their aspect ratio, and captions start below it, so their first lines line up across. A caption (the content of `[figure …:`) may have several lines and inline notation; its alignment follows the box's `text-align`. If any figure has `align-content` written, that run is not aligned (it is placed as [Elements](https://komalang.org/spec/elements/#element) says). PDF, HTML and PowerPoint are as drawn. There is no way to line up figures in a `[row:]` without wrapping each in a `[col:]`.
### A column is one flex
A column is one vertical flex that lays out what it holds from the top, the same whatever it holds.
#### How to write
What a column holds goes from the top in the order written. To make something as tall as its column, write it in its `style`: `[box .tint style="flex: 1": …]`.
#### Details
- A column's height is [Columns and rows](#split)'s: in a parent with a height of its own, columns fill what is left; elsewhere they are as tall as the tallest column's content. What a column holds never changes this.
- A column is a CSS vertical flex. It stretches and shrinks nothing itself; `flex: 1` fills the rest of the column, and `height: 100%` works as in CSS, where the column's height is set.
- A figure or a paragraph of pictures with no size fits the rest of a column with a set height ([Elements](https://komalang.org/spec/elements/#element)), and otherwise keeps its own size, up to the column's width. Figures side by side are not lined up by a rule of their own.
### Cards without positions
Cards placed without positions line up their gaps and heights through `gap` in the parent's `style` and the rule that splits fill what is left of a parent of set height.
#### How to write
Write `gap` in the `style` of the element that holds the cards (`[main style="gap: 24px": …]`). To place them across, use `[col:]`.
#### Example
```koma
[title: Three rooms]
[main style="gap: 24px":
[col:
[box .card style="flex: 1":
Reading room
]
]
[col:
[box .card style="flex: 1":
Swap table
]
]
[col:
[box .card style="flex: 1":
Lounge
]
]
]
```
> Three cards, Reading room, Swap table and Lounge, side by side with equal gaps.
#### Details
- Per-element flow gap: `gap` in the `style` of an element without a split is the gap between the elements of its direct flow (in place of the theme's flow gap, `--koma-flow-gap`). When written, the element's inner padding is not a minimum (more `padding` on a card does not change the gap between cards). In an element with a split, it is the gap between areas ([Columns and rows](#split)). PowerPoint and HTML keep the gap as drawn.
- A split across in a parent of set height fills what is left: besides an element with `h`, in an area of a split down that shares height and in the flow directly on a page (when the split across is that flow's only item), the split across fills what is left of the parent's height. Columns side by side take that height, and a column's only box with a surface stretches to the column's height ([Columns and rows](#split)).
- Koma has no run that wraps to fit the number of children.
- A split across with a column holding only one picture does not fill what is left in a row's area sharing height or in the flow directly on a page; the picture is drawn at the column's width ([Columns and rows](#split)). A picture keeps its aspect ratio, so it is not stretched. Inside an element with `h`, it does fill what is left.
## The core tree and the syntax tree
### The core tree
The core tree is the internal tree made by reading a `.koma` file; it is not a published text language.
#### How to write
Nothing is written by hand. There is no text form for reading or writing the core tree; the `.koma` file is the only original.
#### Details
- What it must do (requirements): keep the source (writing back from the GUI touches only the written range, [Writing back from the app](https://komalang.org/spec/conformance/#write-back)); keep meaning (role, content, reading order, footnotes, links) through placement; know where in the source each element came from and whether it can be edited. Drawing and output are made from this tree (the layer boundaries are the design of the layers).
- Unknown names and attributes are kept, not removed, and reported.
- Its current form (not a requirement; names, the number of kinds and the mapping to Pandoc may change): the parser scans a `.koma` file into the Koma AST (a unist-compliant syntax tree), and from it a read-only display model (Document) is computed. A box is the general node `koma`; pages and notes are told apart by `role`. Attribute names (such as `layout`) are internal names, separate from the text written (the terms are in `docs/glossary.md`). The text nodes (`p`, `h`, `ul`, `table`, `fn` and so on) are the vocabulary of the current drawing. A function that writes the tree as `[head attributes… children…]` is kept only for tests and debugging, and its output is never read back.
The implementation is `src/core/lang/ast/tree.ts` (types) and `src/core/lang/parser.ts` (`parseKoma(source)` builds it; `parseWithDiagnostics(source)` also returns diagnostics). Node kinds, their fields and positions are covered by conformance (see Conformance) and, with the kinds of `sourceLine`, change only under the language's compatibility policy. `data` and its content (such as the scanner's records of lines, the Internal column of [Syntax tree nodes](#ast-nodes)'s table) and the internals of the implementation that builds the tree are not. Each change to the promised shape also takes the next AST version ([The AST version](#ast-version)).
### Syntax tree nodes
Each node of the Koma AST holds set fields for its kind (`type`).
#### How to write
Nothing is written by hand: `parseKoma(source)` builds the tree. A tool that reads the tree reads the fields in the table below and the kinds of line.
#### Details
- Every node has a `type` and its source range `position`. A node that holds source lines keeps, in `data`, the scanner's record of each line (so the semantic reading can rebuild lines from the tree alone). `data` is internal and not promised: its values and shape may change between versions, so tools that read the tree read the Fields and the line kinds, never `data`.
| `type` | Parent | Fields | Internal (not promised) | Meaning |
| --- | --- | --- | --- | --- |
| `root` | yes | `children` | `data.openFence` (the mark of a fence left open at the end, else `null`) | The whole document. Its direct children are the document settings and blank lines and comments before the first page |
| `page` | yes | `children`, `body` (from after the delimiter and complete settings to the next page), `boundary` (the `+++` line; absent on the implicit first page) | none | One page. Pages divide the source without gaps (the line break just before the next page belongs to this page) |
| `settings` | yes | `scope` (`document` or `page`), `body` (inside the delimiters), `children` (`sourceLine`) | none | A closed YAML settings block. Values are interpreted separately |
| `notes` | yes | `body`, `closed`, `children` (`sourceLine`) | none | Notes (`"""`). Elements and delimiters inside are isolated as content. Unspoken `[[` blocks are part of the body ([Elements](https://komalang.org/spec/elements/#element)) |
| `memo` | yes | `attributes` (`tagToken`, each an attribute assignment of the opening `:::` line), `body`, `closed`, `children` (`sourceLine`) | none | A memo (`::: key=value` … `:::`) on a page. Its text is isolated as content and never output ([Memos](https://komalang.org/spec/elements/#memo)) |
| `element` | yes | `tagName` (the name, else `null`), `children`, `opening` and `closing` (a multi-line element's opening and closing lines; `closing` has the bracket's position `bracket` and whether it is on the body's last line, `inline`) | `data.line` and `data.close` (the scanner's records of the opening and closing lines) | A bracketed element |
| `elementTag` | yes | `children` (`tagToken`) | none | An element's tag |
| `tagToken` | no (`value`) | `kind` (`selector`, `attributeAssignment`, `bareWord`; `selector` is a tag name with any joined shorthands or a standalone ID or class shorthand; `bareWord` is a bare word outside the tag's grammar, kept as written, [Elements](https://komalang.org/spec/elements/#element)), `value` (the word as written), and for attribute assignments `separator` (the position of `=`) and `valueKind` (the kind of the value as written), and for a list `items` ([Value kinds in the tree](#value-kinds-tree)) | none | A word of the tag. Duplicates and invalid values are kept. What a value means (units, a colour or a reference) is not in it |
| `sourceLine` | no (`value`) | `kind` (the kind of line, in the table below), `value`, and when needed `finding`, `fence` (`code`, `math`), `settingValueAt` | `data.line` (the scanner's record of the line) | One source line |
| `raw` | no (`value`) | `value` | none | The source of an element's body |
A `sourceLine`'s `kind` is one of these. Element lines (a one-line element, an opening line, a closing line) never become a `sourceLine`; they are the `element` and its `opening` and `closing`.
| `kind` | Meaning |
| --- | --- |
| `setting` | A `key: value` line inside settings delimiters. `settingValueAt` is where its value starts ([Page settings](https://komalang.org/spec/structure/#page-settings), [Settings YAML](https://komalang.org/spec/structure/#settings-yaml)) |
| `setting-other` | A line inside settings delimiters that the subset does not read (nesting, a list and so on) |
| `front` | A delimiter around settings: `===` for the document's, `---` for a page's ([Document settings](https://komalang.org/spec/structure/#deck-settings), [Page settings](https://komalang.org/spec/structure/#page-settings)) |
| `blank` | A blank line before a page's content (at the start of the file, after a page delimiter, inside settings) |
| `page` | A page delimiter `+++` ([Page boundaries](https://komalang.org/spec/structure/#page-break)) |
| `attribute-line` | A line of an element tag that continues after its opening line ([Tag and content](https://komalang.org/spec/elements/#tag-and-content)) |
| `comment` | A comment line ([Page boundaries](https://komalang.org/spec/structure/#page-break)) |
| `blocked` | A line isolated with its block and reported: settings out of place or unclosed, an unused `:::` block and so on ([Document settings](https://komalang.org/spec/structure/#deck-settings), [Page settings](https://komalang.org/spec/structure/#page-settings)) |
| `notes` | A notes delimiter `"""` and the lines inside |
| `memo` | A memo's `:::` lines and the lines inside ([Memos](https://komalang.org/spec/elements/#memo)) |
| `fenced` | A line inside a code fence or `$$`, and the fence lines. `fence` is `code` or `math` ([Code and math are isolated](https://komalang.org/spec/lexical/#isolation)) |
| `literal` | A line of the body of a math, code or diagram element, kept as written |
| `text` | A line of text. A bracket line that stays text says why in `finding` ([When brackets are an element](https://komalang.org/spec/elements/#element-recognition)) |
- Ranges: `position.start` and `position.end` are half-open. Lines and columns count from 1, `offset` from 0, in UTF-16 code units. CRLF is two units and one line; a lone CR is one line too. A leading byte order mark in the input is included in positions.
- Never dropped: the written order and duplicates of tag names and attributes; quoting; unknown settings; bare text; comments; unclosed YAML, fences and elements. Unreadable parts keep their source and diagnostics.
- Unquoted text directly on a page stays as the page's `sourceLine` children. The semantic reading reads each run as a `[box:]` without position ([Placement](#placement)); the tree has no implicit box node, because the syntax tree shows only what is written, and where one box ends is a semantic decision made from the kinds of lines. In the semantic tree (`Node`) that box is a container with `generated: 'unplaced-text'` and no brackets in the source.
- The tree and diagnostics round-trip through JSON.
### unist
The Koma AST follows unist.
#### How to write
Nothing is written by hand; unist tools (such as `unist-util-visit`) walk the tree as it is.
#### Details
- Each node type is built on `@types/unist`'s `Node`, `Parent` and `Literal`, and the type checker ensures it. `Point` and `Position` are unist's, and `offset` is always present. As unist intends, `data` holds only line information for rebuilding the tree, never canonical values of the language (internal and not promised, [Syntax tree nodes](#ast-nodes)).
- unist tools (`unist-util-visit`, `unist-builder`, `unist-util-remove-position`) can walk it, build it and strip positions. Positions are computed by an index of its own (`positionIndex`), which answers as `vfile-location` does.
### Value kinds in the tree
An attribute assignment in the syntax tree (a `tagToken` of kind `attributeAssignment`) carries the kind of its value as written, and the items of a list.
#### Details
- `valueKind`: `word`, `number`, `percentage`, `dimension`, `hash`, `quotedString`, `valueList` or `invalid` (an unquoted value of no kind, or a string or list that cannot be read). `value` is the word as written.
- A list has `items` (each with `valueKind`, `value` and `position`, and a list item has its own `items`; an expression item's `valueKind` is `expression`).
- What an attribute means (whether it takes a unit, a colour or a reference) is not in it: the semantic stage (the diagnostics in language-semantics.md) decides that.
### The AST version
The promised shape of the Koma AST has a version, the AST version, and any change to that shape takes the next one.
#### How to write
Nothing is written by hand. `koma parse --json` names the version as `astVersion` and the library exports it as `AST_VERSION`; a tool checks the number before it reads the tree.
#### Details
- The promised shape is what [Syntax tree nodes](#ast-nodes) to [Value kinds in the tree](#value-kinds-tree) list: the node kinds, their fields, the kinds of `sourceLine`, of values and of list items, and the positions. A change to any of them, even an added field or kind, takes the next whole number. `data`, the readable output and the parser's internals change without it.
- Version `n` has its JSON Schema at `https://komalang.org/schemas/koma-parse-v.schema.json`, with every node closed, so that a tool can tell a version it does not know from a broken tree. A published version's schema never changes; it stays in the package and on the site beside later ones.
- The AST version is separate from the language version: a release that changes what notation means may keep the tree's shape, and the other way round.
- The current version is 1.
## HTML and reading order
### HTML elements and reading order
The rules for HTML elements and reading order aim, step by step rather than by rebuilding, at output that can be explained as how slides ought to be built in HTML.
#### How to write
You never write HTML. The document's title becomes `h1`, a page's title `h2` and `#` in the body `h3`, and the DOM follows the order of the source (or an explicit order of meaning).
#### Details
- The language's core holds syntax, attributes, content, parent and child, and the mapping to the source; it holds no HTML elements. A shared resolution of meaning decides roles and ownership — the document's title, a page's title, subtitle, label, footer and so on — from explicit roles, slot names and templates, never from coordinates or id strings. HTML drawing maps the decided roles to elements.
- The outer shell of every source element is always `div.koma`. id, class, data-role, the source range, placement, background, border and padding are on the shell. The same identifiers and `.koma` are never repeated inside.
- The document's title is the document's `h1`; a page's simple title text is an `h2` inside the shell. One phrasing block (with emphasis, links, code, line breaks and inline math) becomes the heading. A title holding several paragraphs, a list, a table or child elements keeps all its content as flow in source order, and gives the warning `complex-title-content`. No first paragraph is extracted, no heading hidden, saving is not refused, and nothing is fixed automatically.
- Simple text of label, subtitle and the like is an inner `p`; body and box are natural flow elements. Separate elements are not wrapped in `hgroup`.
- Reading order and meaning are kept apart from placement. The DOM follows the source order (or an explicit order of meaning). Nesting depth does not become heading level. Placement and the theme decide position and look, and never switch the elements of meaning.
- HTML export uses the same HTML rules as drawing. Containers such as `hgroup` never break each element's id, its mapping to the source (`data-from`, `data-to`), or the basis of coordinates. Tests check the DOM structure, reading order, visual regressions and the mapping to the source.
- Heading levels: the document's title is `h1`, a page's title `h2`. Headings in the body, in plain text or inside elements, are `h3` for `#`, `h4` for `##`, and one level deeper for each further mark, down to `h6` ([Text inside elements](https://komalang.org/spec/text/#inline-markup)). Body headings never make `h1` or `h2`. Levels do not change with whether there is a `[title:]` or with nesting depth. A `#` in a figure caption is an `h3` inside `figcaption`. The levels read aloud in HTML and PDF are these; PPTX copies the drawn look (bold at the size of the body text).
- `h3` to `h6` are bold at the effective size of the text around them, with a small space below, adjustable with `--koma-local-heading-gap` and not added to paragraph spacing. Figure titles follow the effective size of the caption text.
- Vertical spacing in slide bodies and boxes follows three rules, all closed up together when fitting. (1) A local heading keeps its small space below (`--koma-local-heading-gap`) and has 1.35em above it after a paragraph, list or display block. (2) Paragraphs have no space above, so a paragraph after a heading keeps the heading's space; consecutive paragraphs are set apart by the space between list items (`--koma-item-gap`). (3) Every other block has the same space above and below, the larger where two meet: a list or definition list the space between items, a display block (display math, code, table, quotation, diagram, figure, grid) the block gap, from the theme's `--koma-block-gap` towards `--koma-block-gap-min` (0.35em). Only one side of each pair carries the space, so nothing adds up in a column. The first block has no space above it. Element flows keep their flow gap ([Columns and rows](#split)). Captions, table notes, footnotes, list items and the parts of a grid or figure keep fixed spacing. Documents and posters keep their kind's fixed spacing, never closed up ([Values per kind of page](https://komalang.org/spec/styles/#page-kind-values)): a paragraph or a list under a heading at the heading's gap, items at the item gap, paragraphs and a paragraph and a list at the paragraph gap, a display block at the block gap, and a heading 1.35em after a block, which gives up its own margin. The editor draws the same spacing.
### CSS motion and stepped elements
An authored CSS animation or transition on a stepped element plays in presentation and HTML. PowerPoint retains the entrance effect and reports omission of the CSS motion with `step-css-motion-not-exported`.
#### How to write
Use the existing CSS syntax. For example, apply `box.reveal { animation: slide-in 300ms; }` to `[box.reveal step=1: …]`.
#### Details
- The note applies to an element with a valid `step` when authored theme or document CSS sets nonzero `transition-duration` or an `animation-name` other than `none`. The built-in entrance effect itself ([Entrance effects](https://komalang.org/spec/elements/#entrance-effects)) is outside that check.
- Presentation, HTML, and embeds play the authored CSS motion, including when it coincides with an entrance effect. See the [document CSS rules](https://komalang.org/spec/).
- Give one informational `step-css-motion-not-exported` finding per affected element in Problems and `koma check`. Advise using `step-effect` to obtain a PowerPoint entrance. There is no automatic fix for mapping arbitrary CSS motion to the three effects. A note alone does not fail `koma check`.
- Suppress `animation-static` on the same element. PDF and PNG still use their normal static output.
## Diagnostics
Diagnostics never rewrite the source. For most errors the source is isolated and the rest is drawn; whether export works is given by the Export column (✓ exports, ✗ is refused by `koma export` and the app's export). Severity follows what happens to what was written. An error refuses export or leaves written content out of the output. A warning means the output is made but may differ from the author's intent. A note only informs. `koma lint` and `koma check` exit with 0 when there are only notes, and 1 when there is a warning or an error.
Every diagnostic says how to fix it as well as what happened: what to write or change on which part of which element, with the attribute's name and the value's form when known (`x=40%`, `step=2`). The app says it in English and Japanese; the command line gives a short English fix at the end of each text line and as `advice` in each `--json` diagnostic. Diagnostics marked "one fix" have that fix written by `koma check --write`, and their advice says so. A fix also marked "may change the meaning" can change what is drawn, the structure or what is read, even where the page looks the same: `koma check --write` leaves it, and it is made when chosen one by one in the GUI or with `koma check --write --unsafe`, which the advice names.
| Code | Severity | Export | Meaning | Fix |
| --- | --- | --- | --- | --- |
| `missing-colon` | Error | ✓ | An element-shaped line ([When brackets are an element](https://komalang.org/spec/elements/#element-recognition) (a)–(c)) has no `:`. It is not an element, goes in no bare-text box, and is not drawn. A multi-line form is held back with its content and children ([Tag and content](https://komalang.org/spec/elements/#tag-and-content), [Placement](#placement)) | Write `:` at the end of the tag (after the name, when a known tag name is followed by a word); one fix, may change the meaning. To keep it as text, start the line with `\` |
| `bare-word` | Warning | ✓ | A word without `=` in a tag. Its source is kept, but it does nothing ([Elements](https://komalang.org/spec/elements/#element)) | Write it as `key=value` or remove it (`rtl` too; no fix offered) |
| `group-attribute` | Warning | ✓ | An attribute other than `#id` and classes in a group's tag. Kept, but has no effect ([Groups](https://komalang.org/spec/elements/#group)) | Remove it, or write it on an element inside |
| `empty-group` | Warning | ✓ | A group with nothing inside. Kept, and draws nothing ([Groups](https://komalang.org/spec/elements/#group)) | Remove it, or put elements in it |
| `reserved-setting` | Warning | ✓ | The setting key `koma` is reserved for the future and sets nothing ([Document settings](https://komalang.org/spec/structure/#deck-settings)) | Remove the line |
| `unsupported-declaration` | Error | ✓ | A `::: name` at the root is an unsupported declaration; its source is kept up to the matching `:::` and not applied ([Document settings](https://komalang.org/spec/structure/#deck-settings)) | Write CSS in the document settings' `css:` |
| `citation-unsupported` | Warning | ✓ | Citations `[@key]` are not supported and are shown as written ([Text inside elements](https://komalang.org/spec/text/#inline-markup)) | Use a footnote `[^label]` |
| `empty-span` | Warning | ✓ | `[]{.class}` or `[ ]{.class}`: brackets with no text, or only spaces, are not a span and are shown as written ([Text inside elements](https://komalang.org/spec/text/#inline-markup)) | Write text inside, as `[answer]{.blank}` or `[\_\_\_\_]{.blank}` for an answer blank |
| `empty-definition` | Warning | ✓ | A line with only a colon is drawn as text with no description ([Definition lists](https://komalang.org/spec/text/#definition-list)) | Remove the line (one fix, may change the meaning) |
| `unknown-class` | Warning | ✓ | The class in `[text]{.class}` is written in neither the theme's CSS nor the document's `css:`. The text is drawn as is ([Text inside elements](https://komalang.org/spec/text/#inline-markup)) | Use `.chip`, or write the class in the document's `css:` |
| `theme-slot-no-geometry` | Warning | ✓ | A sample in a theme document that names a frame has no valid position and size, so it defines no frame ([Frames from sample elements](https://komalang.org/spec/styles/#theme-frames)) | Write `x`, `y`, `w`, `h` in `%` or `px` |
| `theme-slot-duplicate` | Warning | ✓ | A second sample in a theme document defines the same frame; the first is used ([Frames from sample elements](https://komalang.org/spec/styles/#theme-frames)) | Remove the second, or rename the frame |
| `theme-layouts-unused` | Note | ✓ | The document’s theme folder (for a theme document, its own folder) holds a `layouts/` folder; Koma does not read it ([The source of a theme](https://komalang.org/spec/styles/#theme-source)) | Nothing has to change; define layouts in `theme.koma` |
| `type-not-set` | Note | ✓ | The `size` is paper and there is no `type`; the document is drawn as slides ([Kinds of page](https://komalang.org/spec/structure/#page-kind)) | Write `type: article` for a document, `type: poster` for a poster, or `type: slide` to keep slides on paper |
| `type-unused-feature` | Note | ✓ | A document or a poster holds something only slides use (speaker notes, `step`, `skip`, `duration`, `total-duration`); the source keeps it and it is not used ([Kinds of page](https://komalang.org/spec/structure/#page-kind)) | Nothing has to change |
| `delimiter-text-reserved` | Warning | ✓ | Text after `===`, `---` or `+++`. It is a reserved area and means nothing ([Page boundaries](https://komalang.org/spec/structure/#page-break)) | Remove the text after the delimiter |
| `unclosed-settings` | Error | ✗ | `===` or `---` settings do not close; isolated up to the next `+++`. For a page's `---`, adds "a page break is `+++`" ([Page settings](https://komalang.org/spec/structure/#page-settings)) | Add the closing line |
| `bad-yaml` | Error | ✗ | The settings YAML cannot be read; none of the block is applied ([Settings YAML](https://komalang.org/spec/structure/#settings-yaml)). Suggests quoting a value with `:`, and for a page's `---` adds "a page break is `+++`" ([Page settings](https://komalang.org/spec/structure/#page-settings)) | One `key: value` per line, indented with spaces |
| `duplicate-setting` | Error | ✗ | The same setting key twice | Remove one |
| `unknown-setting` | Warning | ✓ | An unknown setting key; its source is kept | Fix the spelling or remove it |
| `bad-setting-line` | Warning | ✓ | A line that cannot stand in a settings block | Write it as `key: value` |
| `setting-out-of-scope` | Warning | ✓ | A document-only setting (`title`, `size`) on a page. On the first page, adds that document settings go in `===` ([Page settings](https://komalang.org/spec/structure/#page-settings)) | Move it to the document settings |
| `setting-not-applied` | Warning | ✓ | A written setting takes no effect (such as `logo-alt` with no image in effect) | Write the setting it pairs with, or remove it |
| `misplaced-settings` | Error | ✓ | A `---` in column 0 after a page's content. That one line is not shown and later lines are not isolated; adds "a page break is `+++`". A second settings block in the preamble is isolated ([Page settings](https://komalang.org/spec/structure/#page-settings)) | `***` for a horizontal rule, `+++` for a page break (two fixes) |
| `tab-indent` | Warning | ✓ | A line inside an element indented with a tab. Read with the tab as two spaces it would be an element at that depth, but as written it is drawn as text ([The standard form](https://komalang.org/spec/conformance/#standard-form)) | Turn the tab into two spaces (one fix, may change the meaning) |
| `root-outside-math` | Warning | ✓ | `√` before a digit, letter or bracket outside math. Only the sign is drawn, without the bar over the radicand ([Text inside elements](https://komalang.org/spec/text/#inline-markup)) | Write `$\sqrt{…}$` (one fix, may change the meaning) |
| `dashes-not-rule` | Warning | ✓ | A line of only `---` inside an element or bare text. It is not a rule and is shown as written ([Text inside elements](https://komalang.org/spec/text/#inline-markup)) | For a horizontal rule write `***` (one fix, may change the meaning) |
| `misplaced-scoped-block` | Error | ✗ | `:::` is a reserved mark with no use. In the document's preamble or on a page, it is isolated up to the matching `:::` ([Document settings](https://komalang.org/spec/structure/#deck-settings)) | Write CSS in the document settings' `css:`, and select pages with the page `class` and `page.class` |
| `css-file-unavailable` | Error | ✗ | The CSS file `css:` points to is not in the document's folder, cannot be read, is not UTF-8, or is too large. Only that file is left out ([Document settings](https://komalang.org/spec/structure/#deck-settings)) | Fix the path, or put the file in the document's folder |
| `unclosed-notes` | Error | ✗ | Notes `"""` do not close; isolated up to the next page break | Add the closing `"""` |
| `unknown-note-attribute` | Warning | ✓ | An unrecognised attribute on the notes' opening line, including the retired `speak` ([Elements](https://komalang.org/spec/elements/#element)) | Remove the attribute |
| `unclosed-memo` | Error | ✗ | A memo's `:::` does not close; isolated up to the next page break ([Memos](https://komalang.org/spec/elements/#memo)) | Add the closing `:::` |
| `unknown-memo-attribute` | Warning | ✓ | An unrecognised attribute on a memo's opening line ([Memos](https://komalang.org/spec/elements/#memo)) | Remove the attribute |
| `notes-time` | Note | ✓ | The page has no `duration:` and the first line of its notes (blank and `;` lines aside) has the form `0:59 + 0:04 = 1:03`. Notes are not read as time ([Planned speaking time](https://komalang.org/spec/structure/#planned-time)) | Move it to the page's `duration:` (one fix, may change the meaning: the value right of `=`, else the sum; notes with nothing else are removed with it) |
| `flow-over-slots` | Warning | ✓ | The page's area where elements written directly on the page without `x` and `y` flow (inside the page's padding) overlaps the rectangle of a frame written on the page (`title`, `main` and so on). Drawn as is ([Placement](#placement)) | To put it in the body frame, write it inside `[main:]` |
| `unknown-tag` | Error | ✓ | A tag neither built in nor in the theme. That element is not drawn ([When brackets are an element](https://komalang.org/spec/elements/#element-recognition)) | Fix the tag name or define it in the theme. To keep it as text, start the line with `\` (`\[Note: …]`) |
| `unclosed-element` | Error | ✓ | An element has no closing `]`. Its tag line stays in the source but is not drawn, and directly on a page the bare text up to the end of the page makes no box ([Placement](#placement)) | Add a `]` at the same depth |
| `stray-close-line` | Note | ✓ | A line of only `]` with no matching opening | Remove it, or write `\]` |
| `deep-heading` | Note | ✓ | A heading written with `##` to `######`. It is read as a heading one level deeper per mark, and looks the same as `#` ([Text inside elements](https://komalang.org/spec/text/#inline-markup), [HTML elements and reading order](#html-elements)) | Write it with one `#` (one fix, may change the meaning) |
| `name-without-colon` | Note | ✓ | A bracketed line with only a name, and a known one (a built-in tag name, a theme's tag or frame name: `[title]`, `[box]`). Without `:`, it is drawn as text. Unknown names (`[AM1]`, `[NOTE]`) are not reported ([When brackets are an element](https://komalang.org/spec/elements/#element-recognition)) | For an element, write `:` (`[title:]`); to keep it as text, `\[` also works |
| `unclosed-fence` | Warning | ✓ | A code or math fence does not close | Add the closing mark |
| `duplicate-slot` | Warning | ✓ | The same slot twice on a page. Both are drawn, overlapping when they have no position ([Kinds of name](https://komalang.org/spec/elements/#names)) | Write positions, or keep one |
| `slot-not-in-layout` | Warning | ✓ | A slot the layout does not have | Choose a layout with that frame, or use another element |
| `unknown-layout` | Warning | ✓ | An unknown layout name; drawn with `content`'s placement ([Page layouts](https://komalang.org/spec/structure/#layouts)) | Use `cover`, `section`, `content`, `blank`, or a layout the theme defines |
| `custom-layout-unresolved` | Warning | ✓ | A theme layout cannot be resolved | Write the layout's frame elements directly on the page, not inside other elements or between bare text |
| `complex-title-content` | Warning | ✓ | `title` holds paragraphs, a list, a table or child elements ([HTML elements and reading order](#html-elements)) | Make the title one paragraph, and move lists, tables and elements to `[main:]` |
| `duplicate-attribute` | Warning | ✓ | The same attribute twice; the first takes effect ([Elements](https://komalang.org/spec/elements/#element)) | Keep one |
| `presentation-attribute` | Warning | ✓ | A look written as an attribute (`gap=`, `opacity=`, `color=`, `fill=`, `stroke=` and the like). Looks go in classes or `style`, so it has no effect; the source is kept ([Elements](https://komalang.org/spec/elements/#element)) | Move it to `style` (one fix when `style` can read the value; may change the meaning) |
| `unknown-attribute` | Warning | ✓ | An attribute with no prefix that the language does not have (`[box foo=1: …]`). It has no effect; the source is kept as written. A look's name is `presentation-attribute`, and attributes starting with `data-` are not reported ([Elements](https://komalang.org/spec/elements/#element)) | Check the spelling. For your own attribute, add `data-` (`data-foo=1`) |
| `line-label-content` | Warning | ✓ | A line's body holds a block other than one paragraph (a list, a table, a heading, a second paragraph, or a child element) | Keep the line label as one paragraph of text, math, or line breaks, and move other blocks into a box |
| `label-at-unused` | Note | ✓ | `label-at` or `label-side` on a line that has no label text; it has no effect and the source is kept | Write label text in the line's body, or remove `label-at` / `label-side` (one fix) |
| `line-no-height` | Warning | ✓ | `h` on a line. A line runs from end to end and has no height, so it has no effect ([Elements](https://komalang.org/spec/elements/#element)) | Remove `h` (one fix); move the ends with `x1`, `y1`, `x2`, `y2` |
| `invalid-unquoted-scalar` | Warning | ✓ | An unquoted value that is none of a word, a number, a percentage, a dimension or a value starting with `#` (`src=assets/a.svg`, `alt=日本語`, `f=drive(t)`). The source is kept and it reads as a string ([The kinds of a value](https://komalang.org/spec/lexical/#value-kinds)) | Put the value in double quotes (one fix; `koma format --write` writes it too) |
| `image-body` | Error | ✓ | Text written in the body of an image (`[image:]`). An image has no body, so the source is kept and not drawn ([Figures and images](https://komalang.org/spec/elements/#figure)) | For a caption, wrap it in a figure and write the text after the image (`[figure:` … `]`; one fix, which may change the meaning) |
| `figure-attribute-ignored` | Warning | ✓ | `src`, `alt` or `crop` on the tag of a figure that holds an `[image:]`, or an `#id`, class, place, size, `style`, `step` and the like on the `[image:]` inside a figure. A figure takes its picture from the `[image:]` and its place and look from the figure, so these have no effect; the source is kept ([Figures and images](https://komalang.org/spec/elements/#figure)) | Remove it, or move it where it counts (the picture to the `[image:]`, placing to the figure) |
| `figure-child-unsupported` | Warning | ✓ | An element in a figure that is not one a figure shows (an image, chart, diagram, math or code). The source is kept and it is drawn in the same row as what is shown ([Figures and images](https://komalang.org/spec/elements/#figure)) | Move it out of the figure. A table has its own caption, so it is not wrapped in a figure |
| `legacy-page-grid` | Warning | ✓ | The theme's or the document's CSS writes a grid on `page` (`display`, `grid-template-rows` and the like). The layout's grid is the page body's now, so those declarations are left out and the rest of the rule applies ([Layout grids](https://komalang.org/spec/styles/#layout-grid)) | Write the grid on `page-body`; `koma format --write` rewrites it so the frames stay where they were |
| `part-selector-unmatched` | Warning | ✓ | The theme's or the document's CSS names an HTML name Markdown draws (`ul`, `li`, `strong` and the like) in a form that selects nothing (`ul { … }`, `box > li { … }`). That rule alone is not applied ([Markdown parts in elements](https://komalang.org/spec/styles/#markdown-parts)) | Write a part inside an element (`box li { … }`), a part alone (`li { … }`), or parts joined by `+` (`p + ul { … }`). Style text with text classes ([Text inside elements](https://komalang.org/spec/text/#inline-markup)) |
| `role-contrast` | Note | ✓ | The automatic text colour chosen on a role colour does not reach a 4.5:1 contrast ratio. | Adjust the role colour or specify a text colour that reaches at least 4.5:1. |
| `radius-on-ellipse` | Warning | ✓ | `radius` on an ellipse shape. An ellipse has no corners, so it has no effect; the source is kept ([Shapes](https://komalang.org/spec/elements/#shape)) | Remove `radius` (one fix) |
| `shape-border-radius` | Warning | ✓ | `border-radius` in a shape's `style`. A shape's corners are its `radius` alone, so it has no effect ([Shapes](https://komalang.org/spec/elements/#shape)) | On a rectangle, move it to `radius` (one fix; it may change the meaning); on an ellipse, remove it (one fix) |
| `unknown-target` | Warning | ✓ | The `#id` in a line's `from` or `to` is not on the same page (missing, or on another page). The line is not drawn; the source is kept | Write the `#id` of an element on the same page, or give the end as coordinates |
| `line-end-overridden` | Warning | ✓ | `from` and `x1`, `y1` (or `to` and `x2`, `y2`) on the same end of a line. The connected end wins and the coordinates have no effect | Remove the coordinates |
| `line-points-overridden` | Warning | ✓ | A line with `points` also has `x1`, `y1`, `x2`, `y2`, `from`, `to` (with sides and positions) or `route`. `points` wins and the rest have no effect | Remove all but `points` |
| `missing-unit` | Warning | ✓ | A length without a unit | Write `%` or `px` (`x=40%` and the like) |
| `bad-unit` | Warning | ✓ | A unit that is not accepted | Use `%` or `px` (`w=40%` and the like) |
| `bad-value` | Warning | ✓ | A value of the wrong type or range (`step`, `style`, `marker` empty or with a line break, escapes in quotes and the like). A list that cannot be read (a trailing comma, an empty item, a parenthesis left open), a list with another number of items than its attribute takes (`crop` 4, `domain` and `range` 2, `points` two or more lists of two numbers), an expression in a list whose attribute takes none, or an unquoted value starting with `{` ([Lists of values](https://komalang.org/spec/lexical/#lists)). A curve's `f` cannot be read or uses an unknown name (named), `range` is not two different values, or a `functions:` definition cannot be read or is recursive ([Curves from a formula](https://komalang.org/spec/elements/#curve)) | Fix the value. The command line gives each attribute's form (`step=2`, `rotate=15`, `dir=rtl`, `crop=(0, 0, 10%, 0)`, `paginate: true` and so on) |
| `text-marker` | Warning | ✓ | Text in a callout's `marker=` (not one emoji or symbol, as `marker=Note`). Kept, and 💡 is drawn ([Callouts](https://komalang.org/spec/elements/#callout)) | Write one emoji or symbol, or `none`. Write a text heading as a definition list (a term on one line, its description on the next starting with `: `; [Definition lists](https://komalang.org/spec/text/#definition-list)) |
| `zero-size` | Warning | ✓ | `w=0` or `h=0` | Write a size or remove the attribute |
| `bad-size` | Warning | ✓ | The document's `size` cannot be read | Write `16:9`, `4:3`, a paper size such as `A4 landscape`, or two lengths such as `1280 x 720` |
| `bad-weight` | Error | ✗ | `weight` is not a positive number ([Columns and rows](#split)) | Use a positive number (`weight=2` and the like) |
| `split-unresolved` | Error | ✗ | `[row:]` inside a parent without a decided height | Give the parent a height (`h`, or a frame with a height) |
| `step-effect-unused` | Note | ✓ | The element shares its parent's step or neither it nor any descendant has a step. | Set the effect on the parent or use a separate step. |
| `step-css-motion-not-exported` | Note | ✓ | Authored CSS motion on a stepped element is omitted from PowerPoint. | Use `step-effect` for the entrance effect in PowerPoint. |
| `unsupported-rotation` | Warning | ✓ | `rotate` on an element that cannot rotate | Remove `rotate`, or rotate an element directly on the page without nested elements |
| `missing-logo-alt` | Warning | ✓ | The logo image has no alternative text ([The document's logo](https://komalang.org/spec/structure/#logo)) | Write `logo-alt` (`logo-alt: ""` for decoration) |
| `duplicate-footnote` | Warning | ✓ | The same footnote defined twice on a page ([Footnotes](https://komalang.org/spec/text/#footnote)) | Remove one |
| `duplicate-id` | Warning | ✓ | The same `#id` twice | Rename one `#id` |
| `font-unavailable` | Warning | ✓ | A face the document names is not on the computer; another face is drawn ([Text faces](https://komalang.org/spec/styles/#text-faces)) | Install the face, or use a face koma ships (sans, mono) |
| `chart-not-number` | Warning | ✓ | A cell of a chart's value columns is not a number (`1,234`, `12%`, `3 s`); it is drawn as a missing point, the first such cell's row and column said | Write the number without separators or units |
| `chart-data-conflict` | Warning | ✓ | A chart's data is written in more than one of its body's CSV, `src` and `f`; the source is kept and only the frame is drawn | Keep one |
| `chart-no-data` | Warning | ✓ | A chart has no data, or a header row alone | Write a header row and rows of values |
| `csv-uneven` | Warning | ✓ | Rows of a CSV/TSV have different numbers of columns; missing cells are left empty | Give every row as many items as the first |
| `animation-static` | Warning | ✓ | Animation was left out of still output (PDF, PNG, PowerPoint) | Nothing to do (a notice). Export HTML or present to keep the motion |
---
[Specification](https://komalang.org/spec/) · Chapter 7 / 7
# Conformance
Conformance covers syntax and meaning, checked by a conformance suite. How a page is drawn is described, not tested pixel by pixel.
## What conformance promises
Conformance promises syntax and meaning. Rendering is described in prose, and pixel-equal output is not promised.
- Syntax: the same source produces the same Koma AST with the same positions. The promised shape is the node kinds (`type`) and fields in [Syntax tree nodes](https://komalang.org/spec/semantics/#ast-nodes)'s table, the kinds of `sourceLine` (`type`), and the positions (`position`) of [unist](https://komalang.org/spec/semantics/#unist). `data` (the Internal column of [Syntax tree nodes](https://komalang.org/spec/semantics/#ast-nodes)'s table; `data.openFence`, `data.line` and `data.close` are the scanner's records) and the internals of the implementation that builds the tree are not promised.
- When the tree's shape is promised: a version promises the tree's shape and positions only when all three hold: the kinds of `sourceLine` are listed in [Syntax tree nodes](https://komalang.org/spec/semantics/#ast-nodes), a test compares the spec's tables with the types in `src/core/lang/ast/tree.ts`, and `data` and the other internals are marked as outside the promise. A version where they do not all hold promises only meaning and diagnostics, and the tree's shape moves to the next version. All three hold now. That depends on the unit test that compares the tables with the types and with trees read from the bundled examples ([Syntax tree nodes](https://komalang.org/spec/semantics/#ast-nodes)) staying green.
- Diagnostics: the same source produces diagnostics with the same codes, severities and ranges (see the list of diagnostics in Semantics).
- Meaning: the same source produces the same placement and sizes ([Placement](https://komalang.org/spec/semantics/#placement), [Who decides size](https://komalang.org/spec/semantics/#size), [Columns and rows](https://komalang.org/spec/semantics/#split)).
- The conformance suite: a set of `.koma` inputs, each with its expected syntax tree, diagnostics and placement in numbers, cut from the unit tests that name a spec ID and use no DOM, and filed by rule ID.
- Rendering: how HTML, PDF and PowerPoint look ([HTML elements and reading order](https://komalang.org/spec/semantics/#html-elements) and the official themes' looks) is informative prose, outside the conformance suite.
- Writers: tools that tidy or edit also keep the standard form ([The standard form](#standard-form)) and the source they did not change ([Saving without change](#round-trip), [Rewriting only what changed](#minimal-rewrite), [Writing back from the app](#write-back)).
- Versions: how the language's version changes follows the compatibility policy below.
## Writers
### The standard form
The standard form is the set way of writing `.koma` that only explicit tidying writes.
#### How to write
Tidy with `koma format --write`, `koma check --write`, or the app's Tidy. Saving and reading never tidy. `koma check` reports source not in the standard form as `not-formatted`. For example, tidying turns `[box.card x=10%: content]` into three lines: `[box .card x=10%:`, ` content`, `]`.
#### Details
- Tidying is one API (`formatKoma`), run only on an explicit action. Existing documents are never rewritten in bulk.
- **Tags and structural lines**: an element's tag ends with `:` ([Tag and content](https://komalang.org/spec/elements/#tag-and-content)). A line without `:` is text or a held-back element shape, so tidying never adds `:` and leaves the line as written (that would change its meaning; the user adds it with the `missing-colon` fix). The words of a tag are separated by one space, attributes are reordered in the order of [Order of attributes](https://komalang.org/spec/elements/#attribute-order), the `:` is attached to the tag's last word, and one space comes before the content. Attribute values lose the quotes of a value of a kind, gain quotes on unquoted text of no kind, and lists are written `(a, b)` ([The kinds of a value](https://komalang.org/spec/lexical/#value-kinds), [Lists of values](https://komalang.org/spec/lexical/#lists)). Trailing spaces on bracketed structural lines are removed. `===`, `---` and `+++` are made three characters, while the reserved characters after them and the inside of YAML (including the value of `css:`) stay as written. Only bracketed structural lines are indented, two spaces per depth.
- **Multi-line elements**: a multi-line opening that ends with `:` keeps it, and one without it never gets it. A multi-line element's body is aligned, from the line after the opening, to the structural indentation of depth × two spaces, the same as its child elements. Attributes split over several lines are left alone.
- A closing `]` of a multi-line element at the end of a body line is moved to a closing line of its own, keeping the body's spaces and meaning. When the meaning cannot be kept, the line stays as it was.
- Body text following a multi-line element's opening line moves to the next line, keeping the meaning and the body's spaces, with the structural spaces of its depth. When the meaning cannot be kept, the line stays as it was.
- **One-line elements**: an element whose tag has no `key=value` attribute and whose content is a single run of ordinary text stays on one line (`[title: …]`, `[box.tint: a word]`, `[callout: a word]`; a tag with only an `#id` or classes counts as having no attributes). An element with content whose tag has even one `key=value` attribute is not kept on one line, even when its content is one line: the opening line ends with `:`, the content goes on the next line indented one level, and `]` stands on its own line at the original indentation (three lines: `[table src="…":`, the text, `]`). An empty one-line element puts `]` right after the `:`, with no space (`[image src="…":]`, `[title:]`); reading accepts `: ]` with the same meaning. An empty element written over several lines, such as body, stays as it is. Content with Markdown structure such as emphasis, links, images or math is expanded into separate opening, content and closing lines. Only the structural indentation a line lacks is added; extra is never removed. A one-line element is written with the syntactic one space after the colon and the body exactly as read; spaces in the body are not collapsed.
- **Comments** ([Page boundaries](https://komalang.org/spec/structure/#page-break)): a `;` without a following space gets one, making `; comment`. A `;` line with nothing after it, a line that already has a space (or tab), and a line of several `;` such as `;;` stay as written. Indentation, as in the body, only gets the missing structural spaces. Comments inside notes are not tidied. Keep note opener attributes, inline speech directions, and the whitespace around them ([Elements](https://komalang.org/spec/elements/#element)) as written.
- **Blank lines**: one blank line goes right before each page break and settings opening line that standard reading recognises. None is added at the start of the file, and none inside closing markers or protected areas.
- One blank line goes before and after a `+++` page break. When the page's `---` settings follow the `+++` directly, the same applies: `+++`, a blank line, then the settings. One blank line also goes right after the closing `===` or `---`. Closed notes ([Elements](https://komalang.org/spec/elements/#element)) get one blank line before the opening `"""` line and after the closing `"""` line, and closed memos ([Memos](https://komalang.org/spec/elements/#memo)) the same around their `:::` lines; none is added at the start or end inside notes, or at the start or end of the file, and unclosed notes keep their surroundings as written. No blank line is added where it would change how the body reads. Existing extra blank lines are not removed. No close or blank line is guessed into an unfinished or invalid YAML block or at the end. An unclosed `---` right after a `+++` is left as written.
- **What is kept**: every character other than safe opening boundaries, the body's structural indentation and the normalisation of the emphasis recognised by [Text inside elements](https://komalang.org/spec/text/#inline-markup); root comments, unknown information, notes and blank lines; Markdown hard breaks; code, math and relative indentation apart from structural indentation and the line split of displayed math; line ends and the byte order mark. A candidate that would change the meaning, such as a new element arising from the body, is not applied. On a page with an unclosed element, structural lines are protected, and from the unclosed opening on, the source is not changed either, since matching with later closing brackets could change. Unclosed or misplaced YAML or CSS and notes stay isolated and reported; tidying never completes them, guesses, or turns them into body text.
- **Tabs**: elements are indented two spaces per depth. A line indented with a tab is not read as an element but drawn as text. A line that would be an element at that depth if the tab were read as two spaces is reported as `tab-indent` (warning), with one fix that turns the tab into spaces. Tabs inside the body, fences, `[code:]`, `[math:]`, `[diagram:]`, settings, CSS and notes are not reported. Tidying leaves the line as written.
- **Displayed math**: written with the opening `$$` and the closing `$$` each on its own line. A line holding only `$$ formula $$` (also as a one-line element's content or an opening line's content) becomes three lines: `$$`, the formula, `$$`. The formula's characters are unchanged, and all three lines take the original line's indentation (or, if it is short, the structural indentation of its depth, by the rule above). The document's line ends are used. Math already in three lines, `$…$` in text, an unclosed `$$`, and a line not read as math (starting `$$ formula` with its close on a later line) stay as written.
- **Selections**: tidying a selection first widens the lines it touches to the whole elements that hold them.
- **Invariants**: before and after tidying, the tree read (apart from source positions, the order of a tag's attributes and how the same value is spelled: quoted or not), the reports (apart from `invalid-unquoted-scalar`, which is only about spelling) and the drawing are the same, and tidying again changes nothing.
- `not-formatted` in `koma check` is measured against this form.
### Saving without change
A file read and saved without changes is byte for byte the same as the original.
#### How to write
Nothing is needed from the writer: the source, with its line ends, byte order mark, spaces and comments, stays as it is.
### Rewriting only what changed
Koma rewrites only the range of characters a change is about.
#### How to write
Nothing is needed from the writer. The formatting of everything else (blank lines, indentation, how attributes are written) is unchanged.
### Writing back from the app
App writeback changes only the source ranges touched by explicit operations. Preserve comments, whitespace, abbreviated forms and unknown attributes. Move geometry updates only the written axes. Refuse an insertion at the end of an unclosed code or math block and explain how to close it.
## Versions and compatibility
Compatibility policy: during 0.x, a minor version (0.1 to 0.2) may change what notation means, and a patch version (0.1.0 to 0.1.1) never does. Each change comes with a one-off migration script and release notes, and older notation is not read for compatibility. When the notation is settled the version becomes 1.0.0, and meanings no longer change. The first release is 0.1.0; until then the development version number stays.
---
# Reference
The syntax tree of the Koma language and the `.komadoc` package, generated from the specification in the Koma repository.
Version 0.0.0, in development. The first published version will be 0.1.0.
The rules of the language — grammar, semantics and every diagnostic — are in the [specification](https://komalang.org/spec/).
- [Koma AST](https://komalang.org/reference/ast/)The syntax tree a .koma file is read into: its node types and their fields.
- [.komadoc](https://komalang.org/reference/komadoc/)The .komadoc document package: its files, manifest and versions.
---
[Reference](https://komalang.org/reference/)
Version 0.0.0, in development. The first published version will be 0.1.0.
# KAST: Koma abstract syntax tree
The parser builds this syntax tree from `.koma` source for linting, formatting, and semantic interpretation. The source remains authoritative. Each tree represents one revision of that source, as defined in the parser and AST boundary. The tree belongs to the language side. Rendering and export compute their presentation models separately from it.
The implementation is `src/core/lang/ast/tree.ts` (types) and `src/core/lang/parser.ts` (`parseKoma(source)` builds it; `parseWithDiagnostics(source)` also returns diagnostics). Node kinds, their fields and positions are covered by conformance (see Conformance) and, with the kinds of `sourceLine`, change only under the language's compatibility policy. `data` and its content (such as the scanner's records of lines, the Internal column of [Syntax tree nodes](https://komalang.org/spec/semantics/#ast-nodes)'s table) and the internals of the implementation that builds the tree are not. Each change to the promised shape also takes the next AST version ([The AST version](https://komalang.org/spec/semantics/#ast-version)).
- Each node of the Koma AST holds set fields for its kind (`type`). **How to write** Nothing is written by hand: `parseKoma(source)` builds the tree. A tool that reads the tree reads the fields in the table below and the kinds of line. **Details**
- Every node has a `type` and its source range `position`. A node that holds source lines keeps, in `data`, the scanner's record of each line (so the semantic reading can rebuild lines from the tree alone). `data` is internal and not promised: its values and shape may change between versions, so tools that read the tree read the Fields and the line kinds, never `data`.
| `type` | Parent | Fields | Internal (not promised) | Meaning |
| --- | --- | --- | --- | --- |
| `root` | yes | `children` | `data.openFence` (the mark of a fence left open at the end, else `null`) | The whole document. Its direct children are the document settings and blank lines and comments before the first page |
| `page` | yes | `children`, `body` (from after the delimiter and complete settings to the next page), `boundary` (the `+++` line; absent on the implicit first page) | none | One page. Pages divide the source without gaps (the line break just before the next page belongs to this page) |
| `settings` | yes | `scope` (`document` or `page`), `body` (inside the delimiters), `children` (`sourceLine`) | none | A closed YAML settings block. Values are interpreted separately |
| `notes` | yes | `body`, `closed`, `children` (`sourceLine`) | none | Notes (`"""`). Elements and delimiters inside are isolated as content. Unspoken `[[` blocks are part of the body ([Elements](https://komalang.org/spec/elements/#element)) |
| `memo` | yes | `attributes` (`tagToken`, each an attribute assignment of the opening `:::` line), `body`, `closed`, `children` (`sourceLine`) | none | A memo (`::: key=value` … `:::`) on a page. Its text is isolated as content and never output ([Memos](https://komalang.org/spec/elements/#memo)) |
| `element` | yes | `tagName` (the name, else `null`), `children`, `opening` and `closing` (a multi-line element's opening and closing lines; `closing` has the bracket's position `bracket` and whether it is on the body's last line, `inline`) | `data.line` and `data.close` (the scanner's records of the opening and closing lines) | A bracketed element |
| `elementTag` | yes | `children` (`tagToken`) | none | An element's tag |
| `tagToken` | no (`value`) | `kind` (`selector`, `attributeAssignment`, `bareWord`; `selector` is a tag name with any joined shorthands or a standalone ID or class shorthand; `bareWord` is a bare word outside the tag's grammar, kept as written, [Elements](https://komalang.org/spec/elements/#element)), `value` (the word as written), and for attribute assignments `separator` (the position of `=`) and `valueKind` (the kind of the value as written), and for a list `items` ([Value kinds in the tree](https://komalang.org/spec/semantics/#value-kinds-tree)) | none | A word of the tag. Duplicates and invalid values are kept. What a value means (units, a colour or a reference) is not in it |
| `sourceLine` | no (`value`) | `kind` (the kind of line, in the table below), `value`, and when needed `finding`, `fence` (`code`, `math`), `settingValueAt` | `data.line` (the scanner's record of the line) | One source line |
| `raw` | no (`value`) | `value` | none | The source of an element's body |
A `sourceLine`'s `kind` is one of these. Element lines (a one-line element, an opening line, a closing line) never become a `sourceLine`; they are the `element` and its `opening` and `closing`.
| `kind` | Meaning |
| --- | --- |
| `setting` | A `key: value` line inside settings delimiters. `settingValueAt` is where its value starts ([Page settings](https://komalang.org/spec/structure/#page-settings), [Settings YAML](https://komalang.org/spec/structure/#settings-yaml)) |
| `setting-other` | A line inside settings delimiters that the subset does not read (nesting, a list and so on) |
| `front` | A delimiter around settings: `===` for the document's, `---` for a page's ([Document settings](https://komalang.org/spec/structure/#deck-settings), [Page settings](https://komalang.org/spec/structure/#page-settings)) |
| `blank` | A blank line before a page's content (at the start of the file, after a page delimiter, inside settings) |
| `page` | A page delimiter `+++` ([Page boundaries](https://komalang.org/spec/structure/#page-break)) |
| `attribute-line` | A line of an element tag that continues after its opening line ([Tag and content](https://komalang.org/spec/elements/#tag-and-content)) |
| `comment` | A comment line ([Page boundaries](https://komalang.org/spec/structure/#page-break)) |
| `blocked` | A line isolated with its block and reported: settings out of place or unclosed, an unused `:::` block and so on ([Document settings](https://komalang.org/spec/structure/#deck-settings), [Page settings](https://komalang.org/spec/structure/#page-settings)) |
| `notes` | A notes delimiter `"""` and the lines inside |
| `memo` | A memo's `:::` lines and the lines inside ([Memos](https://komalang.org/spec/elements/#memo)) |
| `fenced` | A line inside a code fence or `$$`, and the fence lines. `fence` is `code` or `math` ([Code and math are isolated](https://komalang.org/spec/lexical/#isolation)) |
| `literal` | A line of the body of a math, code or diagram element, kept as written |
| `text` | A line of text. A bracket line that stays text says why in `finding` ([When brackets are an element](https://komalang.org/spec/elements/#element-recognition)) |
- Ranges: `position.start` and `position.end` are half-open. Lines and columns count from 1, `offset` from 0, in UTF-16 code units. CRLF is two units and one line; a lone CR is one line too. A leading byte order mark in the input is included in positions.
- Never dropped: the written order and duplicates of tag names and attributes; quoting; unknown settings; bare text; comments; unclosed YAML, fences and elements. Unreadable parts keep their source and diagnostics.
- Unquoted text directly on a page stays as the page's `sourceLine` children. The semantic reading reads each run as a `[box:]` without position ([Placement](https://komalang.org/spec/semantics/#placement)); the tree has no implicit box node, because the syntax tree shows only what is written, and where one box ends is a semantic decision made from the kinds of lines. In the semantic tree (`Node`) that box is a container with `generated: 'unplaced-text'` and no brackets in the source.
- The tree and diagnostics round-trip through JSON.
- Test: Unit tests cover each node type, field, range, and JSON round trip. Compare the two tables with `tree.ts`. Fail if a node, field, internal value, or line type occurs in only one source, or an internal value appears in a public field list. The bundled examples must produce only listed node and line types.
Principle: The syntax tree keeps source positions and the structure written there. Semantic interpretation is a separate step.
- The Koma AST follows unist. **How to write** Nothing is written by hand; unist tools (such as `unist-util-visit`) walk the tree as it is. **Details**
- Each node type is built on `@types/unist`'s `Node`, `Parent` and `Literal`, and the type checker ensures it. `Point` and `Position` are unist's, and `offset` is always present. As unist intends, `data` holds only line information for rebuilding the tree, never canonical values of the language (internal and not promised, [Syntax tree nodes](https://komalang.org/spec/semantics/#ast-nodes)).
- unist tools (`unist-util-visit`, `unist-builder`, `unist-util-remove-position`) can walk it, build it and strip positions. Positions are computed by an index of its own (`positionIndex`), which answers as `vfile-location` does.
- App: Use type and test dependencies without adding runtime dependencies.
- Test: Unit tests compare unist traversal with the internal walk, verify that removing positions retains the other fields, and compare every position of arbitrary strings with `vfile-location`.
- Principle: Reuse the unist node and position conventions.
- The promised shape of the Koma AST has a version, the AST version, and any change to that shape takes the next one. **How to write** Nothing is written by hand. `koma parse --json` names the version as `astVersion` and the library exports it as `AST_VERSION`; a tool checks the number before it reads the tree. **Details**
- The promised shape is what [Syntax tree nodes](https://komalang.org/spec/semantics/#ast-nodes) to [Value kinds in the tree](https://komalang.org/spec/semantics/#value-kinds-tree) list: the node kinds, their fields, the kinds of `sourceLine`, of values and of list items, and the positions. A change to any of them, even an added field or kind, takes the next whole number. `data`, the readable output and the parser's internals change without it.
- Version `n` has its JSON Schema at `https://komalang.org/schemas/koma-parse-v.schema.json`, with every node closed, so that a tool can tell a version it does not know from a broken tree. A published version's schema never changes; it stays in the package and on the site beside later ones.
- The AST version is separate from the language version: a release that changes what notation means may keep the tree's shape, and the other way round.
- The current version is 1.
- Test: Unit tests fix the shape of version 1's schema, compare the node fields and kinds `packages/koma/index.d.ts` declares with the schema's, compare `koma parse --json` with the library's tree less `data`, and pin the output for a small source, positions and all.
Principle: 3 (make conditions visible). The tree's shape changes only with a number a reader can see and check, and a closed schema at that number's address says exactly what the number means; an open schema would let a change pass unseen.
---
[Reference](https://komalang.org/reference/)
Version 0.0.0, in development. The first published version will be 0.1.0.
# Koma document package
A `.koma` file is the readable text source. A `.komadoc` file is a Koma document package that carries the source and its referenced assets. The format may be called KomaDoc in prose. KomaDocs is the application and service. The package is a Koma-specific format based on TextPack, the compressed form of TextBundle v2. It follows the [TextBundle specification](https://textbundle.org/spec/) for `type` and derived formats. General Markdown editing and rendering compatibility is outside the format's contract.
## Structure
A ZIP archive holds one TextBundle directory containing `info.json`, `text.koma`, and `assets/`. A newly created directory is named `Content.textbundle/`. In `info.json`, `version` is the integer 2, `type` identifies Koma source, and Koma-specific metadata lives under its identifier. The prototype identifier `com.github.amachino.koma` carries no guarantee of macOS UTI registration. The outer derived UTI declares `org.textbundle.compressed` as its parent when adopted by the native app. Preserve other applications' metadata on resave.
## Source and dependencies
Collect referenced images, tables, logos, and custom themes with their assets. A pinned theme keeps every file covered by its integrity hash. Following TextBundle, local asset references in the packaged source resolve under `assets/`. Preserve the original `.koma` and assets in place. When a packaged copy requires rewritten references, edit only their source ranges and preserve quoting, comments, and line endings. Report unsafe transformations and missing or unauthorised assets, and withhold the package rather than saving an incomplete copy as complete. Fetching external URLs requires explicit action.
### Embedded themes
- A shared copy, created by Export as .komadoc or `koma pack`, always contains the theme that defines the document's appearance. Include even a built-in theme as a pinned snapshot in `assets/themes/koma-snapshot-/`, and point `theme:` at the snapshot. Embed the default theme when the source omits `theme:`. Updates to KomaDocs and `koma` leave the package's theme basis intact.
- Fonts stay outside the package. KomaDocs and `koma` both include the default fonts. Rendering may still vary at the pixel level.
- The `@font-face` checks reject themes that use custom fonts and explain the reason.
- Test: Unit tests cover embedding built-in and default themes as snapshots. E2E checks that `koma export` can render a package using its bundled theme alone.
- After KomaDocs saves a package in place, uses Save As to create a package, or overwrites it after a conflict, the app shows the same document as reopening the package. It reads the written package through the reopening path and adopts the stored source and pinned theme. The `theme:` value, theme label, and rendered pages match before and after reopening.
- Rewriting a reference to the pinned theme is part of saving and adds no Undo or Redo entry. Edits made before the rewrite remain undoable. A successful save clears the unsaved state, and another unchanged save writes the same package.
- A source edit made during saving takes precedence. Leave the live source intact and embed the same pinned theme on the next save.
- Copies made for sharing, download, or resolution through Save to Another File leave the open document intact.
- Test: Unit tests cover source, theme, unsaved state, and history after saving. E2E checks that saving a built-in theme to `.komadoc`, reopening, and saving again preserves the theme label, `theme:`, and page images.
### Editable themes
A package can carry one editable theme in addition to pinned snapshots. The source sets `theme:` to `./assets/themes//theme.koma`. The name is at most 64 characters, uses lowercase ASCII letters, digits, and hyphens, and begins with a letter or digit. Names beginning with `koma-snapshot` or `koma-legacy` are reserved. Validate an editable theme by matching its referenced asset set exactly to the packaged files. Reading and writing reject missing assets, unused bundled assets, assets outside the theme directory, and path collisions. The font check still applies. Preserve the theme file's BOM and line endings and the raw bytes of unmodified assets.
Edit Theme duplicates an official theme or a pinned snapshot into this format and changes `theme:` as a single undoable edit. Preserve the official and source themes. If the document already has an editable theme, open its source without duplicating it. The source pane shows the theme in place of the document. The hidden document editor retains source, unsaved changes, history, and cursor. Undo acts on the active editor.
A complete theme edit with available assets and no custom fonts updates the theme in the package draft and redraws the document. Unused assets are omitted from the save set and return if used again. Explain incomplete edits and keep the last applied theme until the edit is repaired or undone. Returning to the document requires a complete theme. Saving writes the last applied theme and uses the existing explicit save path, including comparing the baseline bytes, offering conflict choices, and retaining the draft until success. Opening another document, or choosing Reload in a conflict, ends theme editing. Unapplied text is discarded on reload. The document returns with the last applied theme.
### Package cover
- A package may carry a cover: a picture of its first page at `Content.textbundle/preview.png`, following the TextBundle and Keynote convention of a preview beside the content. The cover is a PNG at most 640 pixels wide, 1280 pixels tall and 256 KiB. It is never content: no reference names it, opening, rendering and exporting never need it, and a package without one opens exactly as before.
- On opening, the cover entry passes the same archive checks as every other entry: path traversal, links, duplicate names, case and Unicode collisions, and corrupt archive structure still refuse the whole package. A cover that is not a PNG with an `IHDR` header first and `IEND` last, is larger than its bounds, or fails to unpack is ignored: the package opens without it and nothing shows it. An oversized entry is never unpacked.
- Saving in place, Save As, the conflict choices and the package download write a fresh cover inside the same package write, drawn from the first page by the app's page renderer and reduced to fit the bounds. Export as .komadoc does the same for the sharing copy. The cover is drawn before the save takes its snapshot. When drawing fails, takes longer than three seconds or gives an unusable picture, the save writes the package's previous valid cover, or none, and continues. Drawing the cover adds no Undo entry and changes neither the source nor the assets.
- `koma pack` keeps a valid cover of a package it repacks and adds none to a `.koma` source, so packing needs no browser. `koma pack --cover` draws the first page with the installed browser `koma export` uses and writes it when it is usable; without a browser, or when drawing fails, it writes the package without a new cover and says so on stderr. Source edits by `koma format --write` and `koma check --write` keep the package's entries, including its cover.
- In the macOS app, opening or saving a package gives its cover to the recent document snapshot, and the chooser shows it in place of the source preview. The snapshot keeps a cover only as base64 of a PNG within 256 KiB, so listing still reads only the app's own folder.
- Test: Unit tests cover the bounds check, a save and reopen round trip with the cover, a package without one opening identically, oversized, non-PNG, corrupt, traversing and duplicate cover entries, the source and Undo history after a save, a failed or late drawing keeping the previous cover, `koma pack` keeping a cover and drawing one with `--cover`, and the recent snapshot receiving it.
## Opening, editing, and saving
Inspect the ZIP contents, identifier, and version before opening. The TextBundle directory holds only `info.json`, `text.koma`, `assets/` and the optional cover. Reject path traversal, links, duplicate names, case and Unicode collisions, corrupt entries, and excessive unpacked data. Keep the package in memory without extracting it to disk. Keep the source, assets, and unknown metadata together. Saving generates a complete replacement package. Use normal conflict protection when the destination changes externally. On failure, retain the original package and recovery draft. The retired `.koma.zip` format is outside this contract.
## Implementation
The CLI can create a portable package with `koma pack`. KomaDocs reads and writes document packages. The package and save tests cover preserving assets and metadata, detecting external changes, and retaining recovery drafts.
---
# The `koma` command
One command for `.koma` files: it finds problems, tidies a file into the standard form, exports it to HTML, PDF, PowerPoint or pictures, and prints the syntax tree for programs. How to install it is on [Start](https://komalang.org/start/#cli).
## Check and tidy
```
# find problems and untidy text; changes nothing
koma check talk.koma
# apply the safe fixes, then tidy
koma check --write talk.koma
# only the problems
koma lint talk.koma
# only tidy into the standard form
koma format --write talk.koma
```
Without `--write` nothing is rewritten. A command exits with 1 when it finds something worse than a note. Every problem it can report is listed in the [diagnostics](https://komalang.org/spec/semantics/#diagnostics) of the specification; the standard form is in [Conformance](https://komalang.org/spec/conformance/#standard-form).
## Export and pack
```
# draw the document: the ending of -o picks HTML, PDF or PowerPoint
koma export talk.koma -o talk.pdf
# a PNG per page into a folder; --pages picks some
koma export talk.koma --to png -o pages --pages 1,3-4
# the document, its pictures and its theme in one .komadoc, without drawing
koma pack talk.koma -o talk.komadoc
# also render a first-page cover thumbnail at Content.textbundle/preview.png
koma pack --cover talk.koma -o talk.komadoc
```
`export` draws with Google Chrome, Chromium or Microsoft Edge already on your computer; it never downloads one. Name it with `--browser ` if it is not found. Nothing is written over without `--force`, the input is never changed, and nothing is fetched from the network. `koma` carries its default theme; a document on another theme exports from a `.komadoc`, which always carries the theme it was made with.
`koma pack` needs no browser and keeps an existing valid cover when repacking a `.komadoc`. Pass `--cover` to draw the first page into the optional `Content.textbundle/preview.png` cover (at most 640 × 1280 px and 256 KiB; see the [`.komadoc` reference](https://komalang.org/reference/komadoc/#package-cover)); if no browser is available, it still writes the package without a new cover and reports so on stderr.
## Start, import and theme
```
# a new document with a cover and a content page
koma new talk.koma --size 16:9
# Markdown into Koma source; the flavour is read from the file unless --from names it
koma import notes.md -o notes.koma
# an editable copy of a built-in theme, then the document's theme pinned beside it
koma theme copy talk -o themes/my-talk
koma theme freeze talk.koma
```
## For AI agents
```
# a local, read-only MCP server over the files you name
koma mcp talk.koma
```
## For editors
```
# a Language Server over standard input and output
koma lsp
```
In Visual Studio Code, the Koma extension adds syntax highlighting (including quiet speaker cues), diagnostics, canonical formatting, and a live side-by-side preview. Other editors that speak the Language Server Protocol, such as Zed, Neovim, Helix and Cursor, start `koma lsp` for `.koma` files. It shows the problems `koma lint` finds, tidies into the standard form as `koma format` does, and offers the outline, completion of element names and settings, and hover. It reads only what the editor sends and the theme and style sheets beside the file, and writes nothing.
## For programs
The commands take `--json`. `koma parse` prints the syntax tree — readable by default, as JSON with `--json` — and the same package can be used as a library:
```
import { parse, lint, format } from '@komalang/koma'
```
The tree follows unist, as mdast does, so unist tools can walk it. Its node kinds, fields and positions are part of the language’s [conformance](https://komalang.org/spec/conformance/), and are listed in the [reference](https://komalang.org/reference/ast/). `--json` names the version of the tree’s shape as `astVersion`, and the types come with the package.
JSON Schemas describe what programs read and write, so editors can complete and check it: [`koma parse --json`](https://komalang.org/schemas/koma-parse-v1.schema.json) (AST version 1), a theme’s [`theme.json`](https://komalang.org/schemas/koma-theme.schema.json) and a `.komadoc` package’s [`info.json`](https://komalang.org/schemas/komadoc-info.schema.json). The package carries the same files in `@komalang/koma/schemas/`.