# Markdown dialect (`@texuli/deck/markdown`) The deck Markdown dialect: a plain-text way to write a deck that reads into the same validated deck model v2 as JSON (ADR-009). The syntax takes inspiration from reveal.js Markdown (`---` slides, `--` vertical stacks, `Note:`, `` and `` comments), but it is its own closed dialect: reveal.js documents are not a compatibility target, some reveal.js attributes are mapped and the rest are reported and dropped, and there is no HTML at all. > **Status:** in development; `@texuli/deck` is on npm from `0.4.0`. ```ts import { deckToMarkdown, parseDeckMarkdown } from '@texuli/deck/markdown'; const result = parseDeckMarkdown(text); if (result.ok) { const markdown = deckToMarkdown(result.deck); // canonical form } else { for (const issue of result.issues) { console.log(`${issue.source?.line}:${issue.source?.column} ${issue.code} ${issue.message}`); } } ``` The reader is an owned linear parser: one pass over the lines, every loop advances, and every bound in `DECK_MARKDOWN_LIMITS` stops hostile input with a diagnostic. ## Reading and writing - `parseDeckMarkdown(text, options?)` returns a `DeckMarkdownResult`: the same fields as `parseDeck` (`ok`, `deck`, `issues`, `steps`, `truncated`) plus the `draft` (the deck object before model validation, for editors) and the `sourceMap` (JSON path such as `$.slides[2].props.title` → line and column). `ParseDeckMarkdownOptions` are the `parseDeck` options, so the host hooks (`validateBlock`, `validateComponent`, `knownComponents`) and `maxIssues` work here too. It never throws. - Every issue has a `source` line and column (1-based; columns count UTF-16 units). The dialect's own issues are located while reading; model issues (JSON paths) are mapped back through the source map to the nearest recorded position. - `readDeckDraft(text)` reads without validating and returns a `DeckDraft` (`draft`, the issue sink and the map). - `deckToMarkdown(deck)` writes canonical Markdown; `writeDeckMarkdown(deck)` returns a `DeckMarkdownWriteResult` with the `markdown` and `md-unrepresentable` warnings. See [Round trip](#round-trip). - `deriveSlideId(slide, index, used)` is the id rule the reader and writer share (below). ## A complete document ```markdown --- title: Quarterly review description: Fictional numbers for a demo deck. author: Ada Example locale: en theme: nord transition: slide --- # Quarterly review What shipped and what is next *Ada Example · Example Conf · 2026* Note: Welcome everyone and set the agenda. --- ## Priorities - Ship smaller changes - Measure every release -- ## Ship smaller changes Every merged change ships the same day. --- **87%** of releases shipped on the day they merged *Source: a fictional team, twelve months* ``` ## Frontmatter An optional block between `---` lines at the top (at most 64 lines). It is not YAML: a closed key set (`FRONTMATTER_KEYS`), one scalar per line, no lists, maps, anchors, tags or multi-line values. Values are bare, or quoted with `"…"` (escapes `\"` and `\\`) or `'…'` (`''` for a quote). `#` lines are comments. Kebab-case spellings (`font-pair`, `slide-numbers`, `code-theme`, `auto-slide`, `theme-mode`, `theme-seed`, `outline-title`, `design-system`) are accepted on input; the writer uses camelCase. | Key | Goes to | Type | | --- | --- | --- | | `title` | `meta.title` | string (a missing title is derived from the first slide, with `md-title-missing`) | | `description`, `author`, `date`, `locale`, `dir` | `meta.*` | string | | `theme` | `style.theme` | catalog theme id | | `themeMode` | `style.theme.mode` | `light`, `dark`, `high-contrast`, `system` (needs `theme` or `themeSeed`) | | `themeSeed` | `style.theme` as `{ kind: 'seed' }` | whole number (excludes `theme`) | | `fontPair`, `aspect`, `density`, `radius`, `motion`, `transition`, `logo`, `footer`, `progress`, `codeTheme` | `style.*` | string | | `background` | `style.background` | a preset id, a palette token or `#rgb`/`#rrggbb` | | `slideNumbers`, `math` | `style.*` | `true` or `false` | | `start` | `navigation.start` | slide id | | `loop` | `navigation.loop` | `true` or `false` | | `autoSlide` | `navigation.autoSlideMs` | whole number of milliseconds | | `outlineTitle` | `outline.title` | string (needs at least one section) | | `designSystem` | `designSystem` as `{ ref }` | an exact `id@x.y.z` or `texuli:` (from `0.10.0`); an inline design system is not written (`md-unrepresentable`) | ## Slides, stacks and sections - A line of three or more dashes (`---`) starts a new horizontal slide; a line of exactly `--` starts a vertical slide stacked under the previous one. Separators inside code and math fences do not count. Empty slides are dropped. A `--` with no slide before it is `md-stack-start`. - A horizontal slide followed by `--` slides becomes an outline section with `stack: true`. Its id is `stack-` unless the first (horizontal) slide sets `section=`, and `section-title="…"` on that slide names it. - `section=` on a horizontal slide opens a named section that collects the following horizontal slides until the next `section=` or a `section-end` flag. `section-title` without `section` is `md-attr-conflict`. - **Slide ids** come from `id=` on the slide; otherwise they are derived from the slide title (the `title` attribute, the layout's title prop, or a free slide's first heading) as a lowercase ASCII slug of at most 48 characters, made unique with `-2`, `-3`…; a slide with no title becomes `slide-`. ## Slide attributes `` at the top level of a slide sets slide fields. It must open and close on one line. Values are bare tokens or quoted (`"…"` or `'…'`, no escapes); at most 32 attributes per comment, 512 characters per value; a bare name is a flag. ```markdown ``` | Attribute | Sets | | --- | --- | | `id` | The slide id. | | `layout` | A catalog layout id, `free` (default), `component` or `custom`. | | `master` | A free slide's master (`title`, `section`, `content`, `two-column`, `media-left`, `media-right`, `quote`, `closing`); a conflict on other kinds. | | `title` | The slide title. | | `theme` | A catalog theme id for this slide. | | `transition` | `none`, `fade`, `fade-up`, `slide`, `zoom`, `morph`. | | `auto-animate` | Flag: the `morph` transition. | | `hidden` | Flag (or `true`/`false`). | | `steps` | Step labels separated by `\|`: `steps="Problem\|Fix\|Result"`. | | `background` | A background preset id. | | `background-color` | A palette token (`background`, `surface`, `primary`, `accent`, `muted`, `inverse`) or `#rgb`/`#rrggbb`. | | `background-gradient` | A gradient preset name with an optional angle: `"dusk, 135deg"`. | | `background-pattern` | `dots` or `grid`. | | `background-image`, `background-video` | A media source (an image or video background). | | `background-full`, `background-alt`, `background-poster`, `background-fit`, `background-position`, `background-overlay`, `tone` | Image and video background options (`fit`: `cover`, `contain`; `position`: `center`, `top`, `bottom`, `left`, `right`; `overlay`: 0 to 0.9; `tone`: `dark`, `light`). | | `section`, `section-title`, `section-end` | Outline sections (above). | A slide has one background: setting two kinds is `md-attr-conflict`, and the media options without an image or video are too. **reveal.js aliases** are mapped: `data-background-color`, `-image`, `-video`, `-size` (to `background-fit`), `-position`, `-gradient` (preset names only), `data-transition` (`convex` and `concave` play as `slide`; `-in`/`-out` suffixes are dropped, with a warning), `data-auto-animate`, `data-visibility="hidden"`, and `data-background-opacity` (turned into an overlay). The classes `has-dark-background`, `has-light-background`, `slide-bg-overlay--dark` and `slide-bg-overlay--light` set the media tone and overlay. `data-background-video-loop` and `-muted` are accepted and implied (background video always loops, muted). Other `data-*` attributes (`data-transition-speed`, `data-autoslide`, `data-state`, `data-timing`…) are `md-attr-unsupported` warnings and dropped; anything else is `md-attr-unknown`. ## Free-slide content A slide without a `layout` (or with `layout=free`) turns each Markdown block into a content block, in order: | Markdown | Block | | --- | --- | | `# Heading` to `###### Heading` | `{ type: 'heading', level, text }` (plain text: inline Markdown shows literally, `md-heading-inline`) | | A paragraph | `{ type: 'text', markdown }`; inline Markdown stays as the string `@texuli/blocks` paints | | `- item` or `1. item` | `{ type: 'list', items, ordered? }` (indented continuation lines and nested lists stay in the item text) | | `> quote` with a last line `— Name` (or `--`, `-`) | `{ type: 'quote', quote, cite? }` | | A pipe table | `{ type: 'table', columns: [{ id: 'c1', label }], rows }` (empty cells are `null`) | | `![alt](src "caption")` alone on a line | `{ type: 'image', src, alt, caption? }` | | `***` or `___` | `{ type: 'divider' }` | | A code fence | `{ type: 'code', code, lang?, highlights?, filename?, caption?, lineNumbers? }` | | `$$ … $$` | `{ type: 'math', tex }` | | `::: component ` | A component item | | `::: block ` | Any block, as JSON | ```markdown ## Release checklist 1. Open a small pull request 2. Wait for the checks > Make the next step obvious, then make it small. > > — Marco Example | Stage | Owner | | --- | --- | | Review | Ada | | Release | Marco | ![A placeholder diagram](https://example.com/media/diagram.webp "The pipeline") *** ::: block callout { "tone": "info", "title": "Tip", "body": "Every block type can be written as JSON." } ::: ``` `::: block ` takes one JSON object (its `type` is filled from the argument and must match it). Use it for any `@texuli/blocks` block without a Markdown form; the host's block validator checks the body. ## Element attributes and fragments `` sets attributes on the element before it: at the end of the element's line, or on the next line. Code fences, `:::` directives and regions take the same attributes in a brace list, `{#id key=value flag}`, where `#slug` is the `id`. | Attribute | Meaning | | --- | --- | | `fragment` | Reveal the element on its own step; `fragment=` picks the effect. | | `class="fragment "` | The same, reveal.js style; any other class is `md-class-refused`. | | `step=` (or `data-fragment-index`) | An explicit step number (0 to 1,000). | | `reveal=` | The earlier block reveal vocabulary (`fade`, `fade-up`, `grow`, `highlight`, `strike`). | | `tone=` | `neutral`, `accent`, `info`, `success`, `warning`, `danger`. | | `id=` | The block id. | Effects are the model's eight (`in`, `fade-up`, `out`, `in-then-out`, `grow`, `shrink`, `highlight`, `strike`). reveal.js names map onto them (`mapEffect`): `fade-in` and `fade` → `in`, `fade-out` → `out`, `fade-in-then-out` → `in-then-out`, `highlight-red`/`-blue`/`-green` → `highlight` with the `danger`/`info`/`success` tone. Approximate mappings warn with `md-effect-approximated`: `highlight-current-*` → `highlight`, `fade-down`, `fade-left`, `fade-right` and `fade-in-then-semi-out` → `fade-up`, `semi-fade-out` → `out`, `zoom-in` → `grow`, `current-visible` → `in-then-out`. **Numbering follows document order.** A fragment without `step` takes the next number; an explicit `step` is kept. Marked list items reveal one after another from the first marked item; when their effects differ, the whole list steps from its first fragment with `md-fragment-approximated`. A fragment where the layout reveals nothing is dropped with `md-fragment-not-steppable`. ```markdown ## Plan First this paragraph. - Then this item - And this one This one is highlighted last. ``` Allowed extras depend on the target: `width`, `height` (whole pixels, 1 to 4,096) and `decorative` on images; `filename`, `caption` and `numbers` on code fences; `height` on component fences; `avatar` on team members; `overlay` on a full-bleed image. ## Code fences ````markdown ```ts [1-2|4] {filename="total.ts" numbers} export function total(items: number[]) { return items.reduce((a, b) => a + b, 0); } console.log(total([1, 2, 3])); ``` ```` The info string is a lowercase language id, optional highlight steps in brackets (line ranges such as `1-2,4` separated by `|`, at most 16; each range is one step), and an optional brace list. A reveal.js `[n: …]` line offset is dropped with `md-code-offset-unsupported`; unread text after the language is `md-code-info`. Fences open with three or more backticks or tildes. ## Math ```markdown $$ E = mc^2 $$ $$ \int_0^1 x^2 \, dx = \frac{1}{3} $$ ``` `$$ … $$` on one line or a `$$` block becomes `{ type: 'math', tex }`. The TeX is checked against the owned [math](math.md) subset while reading; unsupported commands are `md-tex-unsupported` and oversize formulas `md-tex-limit` (the formula then shows as source text). Inline `$…$` inside a paragraph stays in the text string as written; rendering it is a follow-up in `@texuli/blocks`. ## Layouts and regions `` maps the slide's Markdown onto the layout's props. Content the layout has no field for is `md-layout-extra`; a missing required part is `md-layout-missing`. `:::` regions hold Markdown, close with a bare `:::`, and may hold a JSON fence but not another region (`md-directive-depth`). | Layout | Markdown | | --- | --- | | `title-hero` | A heading → `title`; a paragraph → `subtitle`; an `*italic*` paragraph → `meta`. | | `section-divider` | An `*italic*` paragraph → `eyebrow`; a heading → `title`. | | `two-column-split` | `#`/`##` → `title`; `::: left` and `::: right` regions, each with a `###` heading → `heading` and a paragraph → `body`. | | `three-column-cards` | `#`/`##` → `title`; three `::: card {icon=}` regions, each with `###` → `heading` and a paragraph → `body`. | | `image-left`, `image-right` | `#`/`##` → `title`; an image line → `image`; `###` → `heading`; a paragraph → `body`. | | `image-centered` | `#`/`##` → `title`; an image line → `image`; `*italic*` → `caption`. | | `image-full-bleed` | An image line (`overlay=` on its element comment) → `image`; `*italic*` → `caption`; `*Credit: …*` → `credit`. | | `quote` | `> quote` with a `— Name` last line → `quote` and `cite`. | | `code-with-callout` | `#`/`##` → `title`; a code fence with a language → `code` (its `[…]` steps → `highlights`); `###` → `heading`; a list → `bullets`. | | `big-stat` | A `**number** label` paragraph; `*Source: …*` → `source`; a paragraph → `context`. | | `comparison-table` | `#`/`##` → `title`; a pipe table: the header after the first cell → `columns`, each row's first cell → `label`, `Yes`/`No` → `true`/`false`, empty → `null`. | | `process-steps` | `#`/`##` → `title`; a numbered list of `**Title** body` items. | | `timeline` | `#`/`##` → `title`; a bullet list of `**time** text` items. | | `team-avatars` | `#`/`##` → `title`; a bullet list of `**Name** — Role` items, `avatar=av-001` on each item's element comment. | | `closing-cta` | A heading → `title`; a `[Label](href)` paragraph → `cta`; `*italic*` → `footnote`; a paragraph → `text`. | | `video-centered` | `#`/`##` → `title`; a `::: video {src=… label="…" width=… height=… autoplay loop muted}` region → `video`; `*italic*` → `caption`. | | `video-left`, `video-right` | `#`/`##` → `title`; a `::: video {…}` region; `###` → `heading`; a paragraph → `body`. | | `chart` | `#`/`##` → `title`; a `::: chart {height=md table}` fence whose JSON body is the chart `spec` (put step fields inside the JSON). | Any catalog layout may instead take its props as one JSON object in a `::: props` fence. ```markdown ## Before and after ::: left ### Before Releases waited for a weekly window. ::: ::: right {fragment} ### After Every merged change ships the same day. ::: ``` ```markdown > Make the next step obvious, then make it small. > > — Marco Example ``` ```markdown # Questions? Thank you for listening. [Read the guide](https://example.com/guide) *All names and numbers are fictional.* ``` ## Component, custom and JSON fences `:::` fences whose body is JSON: `component`, `block`, `custom`, `props`, `slide` and `chart`. The body is one strict JSON object (RFC 8259, no duplicate or prototype keys, finite numbers), read by the owned bounded reader `readJson` (`JsonReadOptions`, `JsonReadResult`) within the `jsonBody`, `jsonDepth` and document-wide `jsonNodes` bounds. Every value's position is recorded, so a model issue inside component props points at its exact line and column. ```markdown ::: component chart { "title": "Signups per week" } ::: --- ## Live poll ::: component poll {height=md} { "question": "Ship on Fridays?" } ::: --- ::: custom roadmap-board { "quarter": "Q3" } ::: --- ::: slide { "layout": "quote", "props": { "quote": "Small steps." } } ::: ``` - `::: component ` on a free slide is a component item; on a `layout=component` slide it is the whole slide. An empty body is `{}`. Props are validated later by the host registry at its trust tier. - `::: custom ` on a `layout=custom` slide, with optional JSON `data`. - `::: slide` is the whole slide as JSON (notes still come from `Note:`). - A document cannot choose its trust tier: a `tier` attribute is `md-tier-ignored`. ## Notes A line starting with `Note:` or `Notes:` (any case of the first letter) starts the speaker notes; everything after it, to the end of the slide, is the notes text. The writer escapes notes lines that would read as separators or fence openers with a leading `\`. ## Refused: HTML, iframes, classes, styles and handlers There is no HTML sink anywhere in the dialect: - A line that starts with an HTML tag is `md-html-refused` and renders nothing; an `