References
Relations and styles name what they apply to with references. One symbol has one meaning:
| Meaning | Symbol | Example |
|---|---|---|
| Text | bare or "…" | Mercury, "Stage 1" |
| Position: a row, a column or one cell (even an empty one) | @r, @c | @r3, @c2, @r3c2 |
| Text narrowed by a position (plain numbers) | text@… | 43@r3, •@c2 |
| A position relative to a token (signed numbers) | text@…±n | Rethink@c-1, OK@r+1c-1 |
| The n-th occurrence, from 1 | [n] after text | •@r2[3] |
| Range: the rectangle between two cells | .. | A..D, 43@r1..95@r7 |
| List | [ ] | [A B C D] |
| One relation, by id | #name | #frame |
| Relations, by class | .name | .card |
| Several selectors (styles only) | , | Z, H: rect |
Text
A token is named by its text. Text that appears once needs nothing more:
A B C
--- styles
B: circle r=16 fill=#fde68a
Positions
@r2 is row 2, @c3 column 3, and @r2c3 the cell where they meet, even if it's empty. Whole rows and columns are handy in styles:
Name Age
Alice 31
Bob 27
--- styles
@r1: font-weight=bold
@c2: fill=gray
Narrowing and relative positions
When text appears more than once, narrow it with a position: a plain number narrows. 43@r3 is the 43 in row 3.
A signed number moves. Rethink@c-1 is the cell one column left of Rethink, whatever is there. Relative positions follow the token when rows or columns are added elsewhere, so they're the way to name the empty cells next to a token:
Alice . John
. "Hello John" .
--- relations
arrow "Hello John"@c-1 "Hello John"@c+1
Occurrences
[n] picks the n-th match, counting from 1 in reading order: •@r2[3] is the third • in row 2. Occurrences count things that can move, so prefer a position when one exists.
Ranges and lists
A..D is every cell in the rectangle from A to D, and 43@r1..95@r7 a block of a table. [A B C] is a list. Ranges read well for blocks; lists survive rearranging.
Ids and classes
Sketch tokens are named by text; ids and classes name relations. box#frame […] can be styled as #frame and used as an arrow's target; arrow.move […] is styled as .move. A class as an arrow's targets is its relations, in the order they were drawn, so arrow .card chains through the cards.
Exactly one, in relations
In relations, a reference must match exactly one cell (a range or a list: one per item). No match, or several, is an error that lists the candidates and how to narrow them:
render(`x x
--- relations
stack [x]`);
// DiyaError: Line 3: "x" matches 2 nodes: x@r1c1, x@r1c2. Narrow it with @r…, @c… or [n].
In styles, a reference applies to every match: H: rect styles every H.