The specifications, their reference implementations, and the conformance fixtures
These pages are Kribble's specifications as they are in the repository's spec/ folder, kept in step with the code that implements them.
What Kribble's content is, written down so that anyone can build on it: an editor, a renderer, a converter, an agent, a publishing pipeline. The reference implementations follow these specifications, and their tests check them against the same fixtures.
The Kribble Document Format: a note's content as JSON, blocks with ids holding text runs, parts and other blocks; and its markdown. | |
Every block, part and run, with its fields (generated from the registry). | |
Drawings: the scene a drawing block holds (shapes, arrows, freehand, text, images). | |
The diagram language: the text diagram blocks are made from (flow, sequence, class). | |
The chart language: bar, line, area, pie and doughnut charts from text, in | |
The registry: the machine-readable source of the document format. | |
The document format as JSON Schema (2020-12; generated). | |
The drawing scene as JSON Schema. | |
fixtures/ | Conformance fixtures: valid documents, validation cases, markdown, diagrams. |
Language | ||
|---|---|---|
| TypeScript | The document format: registry, types, validation, the canonical form, walking, the nesting caps. No dependencies, no DOM. |
| TypeScript | The editor (ProseMirror) and its renderer, and the markdown converters. It keeps a note in ProseMirror's JSON while editing and maps it to and from the format without loss. |
| TypeScript | The drawing editor and renderer (canvas and SVG), and the scene model. |
| TypeScript | The diagram language: parsing, layout into a scene, editing helpers. |
| TypeScript | The chart language: parsing, writing, drawing as SVG. No dependencies, no DOM. |
| Go | The document format: registry, validation, the canonical form, walking, ids, the nesting caps. |
| Go | Notes to HTML for sites and printing: the HTML, the table of contents, search sections, drawings as SVG. |
| Go | Markdown in and out of the format, and editing a note through its markdown keeping what markdown can't express. |
| Go | The diagram language's parser, for the server. |
| Go | The chart language's parser and SVG renderer, for sites and PDFs. |
Programs in other languages get the reference converters and validator from the CLI: kribble convert (markdown ⇄ document JSON) and kribble validate.
The server validates every document before it stores it (see document.md, Validation), so what an API, an agent or an editor sends has to be a valid document; the same validation is one call away in either language (validate from @kribble/document, kdoc.Validate).
An implementation conforms when it passes the fixtures for what it does:
Fixtures | For |
|---|---|
| Readers and validators: valid documents in canonical form, with every block, part and run. A validator reports no problems; a reader that reads one and writes it back gives the same bytes as the fixture without its indentation. |
| Validators: a document and the exact problems (severity, code, path) to report, in any order. |
| Writers: a document and its exact canonical bytes (strings, numbers, scene key order, clean-up). |
| Editors: base, server and mine, and their merge ( |
| Markdown converters (see document.md, Markdown). |
| Diagram language parsers and layouts (see diagram-language.md). |
| Chart language parsers and renderers (see chart-language.md). |
The TypeScript packages run them with pnpm test:packages, the Go ones with go test ./internal/format/... ./internal/diagram/... ./internal/chart/... in backend/.
Change the registry (registry.json) and the page that describes it. Decide whether the change fits the current version (document.md, Versions) or needs a new one with a migration.
pnpm spec:generate writes what comes from the registry: the JSON Schema, the reference, and the copies @kribble/document and kdoc embed. pnpm spec:check fails when any of them is out of date, and so do both packages' tests.
Add fixtures for it: a valid document using it, and a check for anything new a validator should report.
Implement it: the editor's schema and its mapping (packages/kribble-editor/src/editor/prosemirror-json.ts; its test fails until the valid fixtures map), the markdown converters (TypeScript and Go, with markdown fixtures), the renderers.