mdlive — a branded page from Markdown
Never hand-write the HTML, a Quarto project or a <script src> to a CDN: an
AI-written page fails in silence (a library missing offline, a chart with no
data, a Spanish number printed 30,000, words that do not read on their
ground). mdlive takes those decisions once, and a page that would reach its
reader broken stops the build, naming the fix.
PDF, Word, slides → mdbrand. A page for a screen → mdlive. One source can
build both: mdbrand: {brand: x} in the front matter is read by both tools.
Commands
mdlive build report.md # report.html beside it: one file, offline
mdlive build report.md -o out/page.html
mdlive build report.md --brand none # no brand bundle
mdlive serve report.md --browser vivaldi # live: rebuilt and reloaded on save
mdlive doctor # what is missing and how to install it
Exit status 0 is a page written; anything else is an error on stderr, with
the fix named. mdlive <cmd> --help is the full manual.
The source
Plain Markdown with an optional front matter:
---
title: Informe de facturación
subtitle: Octubre 2026
author: Carlos Prados
lang: es
mdbrand: {brand: amplia} # or mdlive: {brand: amplia}; mdlive's wins
---
## Resumen
Texto, listas, tablas Markdown, imágenes relativas al fichero, código.
langsets the page's language (hyphenation, and number and date formats on charts). Set it:esfor Spanish.toc: true,toc-depth, andnumber-sections: true(or mdbrand'snumbersections: true) at the top level. Keys insidemdbrand:other thanbrand(style, reference, confidential…) are mdbrand's and ignored.date: an ISO date (2026-11-29) is printed inlang("29 de noviembre de 2026"); free text ("29 de noviembre de 2026 (rev. 3)") is printed as written.: Captionunder a table captions it;::: {.keep}and other mdbrand page controls are accepted and do nothing on a page.- Pictures are found beside the source; keep them in the source's folder.
- The brand's logo goes above the title, in both themes: an SVG keeps its colours where they read on dark and has the others lightened; a PNG or JPG sits on a light plate in the dark theme.
- The brand:
--brand> front matter >~/.config/mdlive/config.yaml(brand:), else mdbrand's configuration. Bundles are mdbrand's own, found in--brands-dir,MDLIVE_BRANDS_DIR, mdlive's or mdbrand'sbrands_dir.
Running serve from an agent
serve never exits on its own. Run it in the background, without opening a
browser on the user's desktop unless asked, and read the URL from its output:
mdlive serve report.md --no-open # prints the http://127.0.0.1:PORT/ URL
It listens on localhost only. --listen 0.0.0.0:PORT exposes it to the
network: only when the user asks for that.
The browser check
Every build and every serve rebuild opens the finished page in headless
Chrome, in the dark theme and the light one, at 390 px (a phone) and 1280 px,
and stops on:
| Finding | What to do |
|---|---|
| a block that drew nothing, or axes with no marks; a table that did not become sortable (mdlive's defect: report it) | the chart's data has rows, and the fields it plots are columns of it |
| text under 4.5:1 (3:1 if large) on its ground | a colour written in raw HTML: take it out; if it names code or mdlive, report it |
| the page wider than the screen | a width written in raw HTML: take it out; a long URL: shorten it or put it in a code block |
a request off the page (https://…) | download the file beside the source and link it |
| an error or exception in the browser console | the chart spec it names, or raw <script>: take it out |
| a face that failed to load | mdlive doctor, or clear ~/.cache/mdlive/fonts |
Each finding names the theme, the heading it is under and a sample of the text. Never work round one by changing the check: fix the page. Without Chrome the build warns that the page was not checked; install it.
Tables scroll sideways in their own box on a phone, and so does a chart wider than the screen; the page itself never does.
Tables and data
Every table on the page sorts by any column (click a header: ascending,
descending, back to the source's order), and one of more than ten rows gets a
search box. Numbers sort as numbers in the page's lang (1.234,5 in
Spanish); a last row whose first cell is bold (**Total**) stays last, and is
hidden while a search is on. Nothing to write for it.
Data comes from files, with mdbrand's syntax, so one source makes both the
PDF and the page. Files in data/ beside the source (YAML, JSON, CSV, TSV),
or the roots in mdlive: {data: …} (else mdbrand: {data: …}):
La flota tiene {{data.flota[GW-05].nodos}} nodos en su pasarela mayor.
```table
source: flota # data/flota.yaml; or rows: [id, id] to pick and order
where: {region: Norte} # equality only
columns: {id: Pasarela, nodos: Nodos, consumo: {label: Consumo, unit: W, decimals: 1}}
sort: -nodos # one field; - descends
total: [nodos, consumo] # an exact Total row
caption: Pasarelas por nodos
```

- Never type a table whose rows are in a data file; never copy a number from
one into prose:
{{data.file.key}},{{data.file[id].field}}. - A link to a data file alone on its line is the whole file as a table.
- A key, id or column that is not there stops the build listing the real ones.
- A chart reads the same rows with
"data": {"name": "flota"}.
Charts: Vega-Lite
Interactive charts (tooltips, zoom, a selection in one view filtering another), drawn in the reader's browser from libraries inside the page. The syntax is mdbrand's, so the same source makes the PDF figure:
```vegalite caption="Ventas mensuales por región"
{
"data": {"url": "data/ventas.csv"},
"mark": {"type": "line", "point": true},
"encoding": {
"x": {"field": "mes", "type": "temporal", "title": "Mes"},
"y": {"field": "importe", "type": "quantitative", "title": "Importe"},
"color": {"field": "region", "type": "nominal"},
"tooltip": [{"field": "region"}, {"field": "importe"}]
},
"params": [{"name": "zoom", "select": "interval", "bind": "scales"}]
}
```

- Fences:
vegalite,vega-lite,vega,vl;caption="…". Side files:.vl.json,.vl.yaml, linked as a picture. - Data is inlined at build time.
data.urlis a local CSV, TSV or JSON, relative to the source (a fence) or to the spec file (a link). Separator,;or tab is detected; with;,1250,5reads as a number. A BOM is stripped. These stop the build, naming the chart and its heading: a remote URL (download it intodata/), a missing file, Latin-1 (save as CSV UTF-8), a row with a different number of fields, a file with no rows. - Every field the chart plots must be a column of its data: a typo stops
the build with the nearest column ("did you mean"), unless a
transformmakes the field. A plotted column mixing numbers and text (12,n/d) stops too, since Vega would drop the text in silence. - Leave
widthout of a single view: it fills the column. Composed views (vconcat,hconcat,facet,repeat,layer) need awidthper child. - Interactivity is Vega-Lite's own:
tooltipinencoding; zoom and pan with"params": [{"name": "z", "select": "interval", "bind": "scales"}]; a brush that filters another view with{"name": "brush", "select": "interval"}plus"transform": [{"filter": {"param": "brush"}}]in the other. - Every chart answers the pointer: bars, lines, areas and points show
the fields of their
encodingwithout atooltip; lines and areas get transparent points so every value is a target. Writetooltipto choose the fields or theirformat. Arectmark (a heatmap) needs its own"tooltip": true: rect is left out because a selection brush is one. - Numbers and dates in the page's
lang:1.250,5,febrero,1 ene 2026fores; tables for es, ca, de, fr, it, nl, da, pt, and numbers for gl and eu. A chart with dates in a language with no month names (gl, eu…) stops the build: write the axis labels yourself (labelExpr, or a nominal field). - The brand fills what the spec leaves unset: series colours
(
figures.palette, else primary and link, then hues turned from the primary, each held to 3:1 on the theme's ground and 30° apart), axis and label colours, the body face, 12–13 px labels, a transparent ground. Anyconfigorcolorin the spec wins. Each chart is drawn again in the other theme's colours when the reader switches.
Diagrams: D2
Architecture, flows, sequences and state, rendered at build time into the page, once per theme. Same syntax as mdbrand:
```d2 caption="Flujo de una orden"
direction: down
api: API { auth: Autenticación; pedidos: Pedidos }
cola: Cola {shape: queue}
api.pedidos -> cola: publica
```

- Needs
d2on the PATH (mdlive doctor).@importresolves against the source's folder (a fence) or the .d2's own (a link). - The brand colours it in both themes: shapes in tints of the primary,
words and strokes in the text colour, every fill held to 4.5:1 under its
words. Setting
theme-idortheme-overridesin the .d2 turns that off. - Sizing is the tool's. A diagram shows at d2's own size, shrunk to the
800 px column when wider. If that would take its labels under 11 px the
build stops with the fixes in order:
direction: downfor a sideways one,layout-engine: elk, fewer or shorter labels, split it. Do not set font sizes to get round it.
Diagrams: Mermaid
Every Mermaid type (flowchart, sequence, state, class, ER, gantt, pie…), drawn at build time in headless Chrome, once per theme, in the brand's colours and body face. The page carries the SVG, not Mermaid.
```mermaid caption="Ciclo de un aviso"
flowchart TD
s[Sensor] --> g[Gateway] -->|MQTT| p[Plataforma]
```
- Needs Chrome or Chromium on the PATH (
mdlive doctor). - A diagram that does not parse stops the build with Mermaid's own message and the block's heading.
- Wider than the 800 px column with labels under 11 px once shrunk stops the
build:
flowchart TDinstead ofLR, shorter labels, or split it. - For architecture with containers, prefer D2; Mermaid for sequences, states, gantt and quick flows.
Still being built: KPI cards,
3D plots. Until a block
exists, do not paste raw HTML or <script> into the source to get one:
it bypasses the brand, the dark theme and the offline guarantee. Say it is not
available yet, or build the PDF with mdbrand, which already draws D2.
Install
mdlive skill install # this file into ~/.claude/skills/mdlive/
mdlive skill install --force # after upgrading the binary