Skip to main content

The sketch

The sketch is everything before the first --- line. It's the diagram's content and its default layout: you write the picture as a grid of text.

. Start .
Left . Right
. End .

Rows and cells​

  • Each line is a row, numbered from 1. A blank line between rows is an empty row; blank lines before and after the sketch are dropped. Leading spaces mean nothing.
  • Each token is a cell. Tokens are separated by spaces, and column n is the n-th token of every row. Extra spaces don't matter, so you can align columns to make the sketch readable.
  • A token's text is what's drawn and how you refer to it. Start is drawn as "Start" and named Start in relations and styles. There are no separate ids.

Quotes​

A token with spaces or symbols is quoted: "Stage 1", "Is it?". Quotes also write a literal ., ^ or <, and a row that starts with --- must be quoted.

"Stage 1" 9 43 15
"Stage 2" 9 15 43

Empty cells: .​

A . is an empty cell, as in CSS grid-template-areas. Missing cells at the end of a short row are empty too. Empty cells take no space, but they're still cells: relations can name them, which is how arrows get waypoints and how a message runs under its label.

Spans: ^ and <​

^ means "this cell belongs to the token above", and < "to the token on the left". The token is centered in its combined area. They repeat, and together they can cover a rectangle:

a < < <
b c < d
e ^ ^ f

--- styles
a..f: rect width=100% height=100% fill=#ececff stroke=#9370db

c spans two rows and two columns. A span that isn't a rectangle (an L shape, say) is an error.

The default layout​

Without relations, the sketch is laid out as a grid:

  • a column is as wide as its widest cell, and a row as tall as its tallest;
  • cells are centered;
  • columns are 20px apart and rows 12px, set with column-gap and row-gap.

Relations adjust this layout; they never change the grid itself. See relations.