Tiago is a Typst package for rendering diagrams with Diago, a D2-compatible diagram engine implemented in MoonBit. It can render a D2 diagram to SVG, ASCII or Unicode text.
The typst package removed embedded fonts and font metrics data from the WASM, and uses release build with --strip tag compared to diago's WASM demo, which reduces its binary size from ~21 MiB to ~5 MiB unzipped.
| architecture.typ | c4.typ | containers.typ |
| isomorphic.typ | sequence.typ | sql_tables.typ |
| styles.typ | markdown.typ | security.typ |
#import "@preview/tiago:0.1.0": *Renders diagram source to an SVG-backed Typst image. Extra arguments are forwarded to Typst's image(...), so you can pass values like width, height, or alt.
#render(
"a -> b: hello",
// engine: "elk",
// width: 220pt,
// height: ...
)Renders diagram source to raw SVG bytes.
#let svg = render-svg("a -> b")Renders diagram source to ASCII text.
#raw(render-ascii("a -> b"))Renders diagram source to Unicode box-drawing text.
#raw(render-unicode("a -> b"))engine is optional. When omitted, the package uses Diago's default layout engine.
Supported engine names:
dagreelkrailway
#import "@preview/tiago:0.1.0": *
= Tiago Example
#let source = ```
server: Web Server
database: Database {
shape: cylinder
}
cache: Cache
server -> database: queries
server -> cache: reads
cache -> database: fallback
```.text
== SVG
#render(
source,
engine: "elk",
width: 300pt,
)
== ASCII
#raw(render-ascii(source))
== Unicode
#raw(render-unicode(source))For a sample document, see example.typ.
- Image paths in D2 diagrams are linked images. Path to linked images are relative to the
--rootdirectory. Linked SVG images are not supported yet. - Some features are not properly supported. Switching rendering engines may help.
Apache-2.0. See LICENSE.