Attributes
After the id (for nodes) or the last id (for edges) come up to five attributes, always in the same order. Each one is optional.
| # | Slot | Node values | Edge values |
|---|---|---|---|
| 1 | size | tiny small normal big bigger huge | |
| 2 | style | shape: none circle square diamond triangle hex | line style: solid dashed dotted bold |
| 3 | color | gray black white red orange yellow green teal blue purple pink brown | |
| 4 | url | a word starting with /, http://, https://, www. or mailto: | |
| 5 | text | all remaining words, to the end of the line | |
The values are described in detail on Sizes, shapes, lines & colors and Links & image nodes.
How words are recognized
The words after the id are read left to right against the slots, in order:
- If the next word is a size, it becomes the size.
- If the next word is a shape (for a node) or a line style (for an edge), it becomes the style.
- If the next word is a color, it becomes the color.
- If the next word looks like a URL, it becomes the link.
- Whatever is left is the text, joined with single spaces.
A quoted word never fills steps 1 to 4, so it always starts the text.
Each slot is checked once, in that order, and the reader never goes back. Omitting a slot is therefore free, and any combination works, as long as the attributes you include stay in order:
a big
b hex
c red
d /example.com
e Just text
f big red
g hex /example.com Shape and link
h small diamond teal
i big square blue /example.com All five
Open in editor
a -> b bold
c -> d red
e -> f dotted /example.com
g -> h big dashed purple /example.com All five
Open in editor
Out-of-order words become text
Once the reader has moved past a slot, a word that belongs in that slot is no longer recognized. It and everything after it become label text. This is the most common surprise in modl. The highlighting shows the result:
a red big # color, then size: "big" is text
b circle small # shape, then size: "small" is text
c blue square # color, then shape: "square" is text
d red blue # only one color: "blue" is text
Open in editor
a big red
b small circle
c square blue
d blue
Open in editor
The same applies to edges, and to node shapes used on edges or line styles used on nodes. Those words aren't valid in that position at all, so they always become text:
a -> b red dashed # color, then style: "dashed" is text
c dashed # line styles aren't shapes: "dashed" is text
c -> d circle # shapes aren't line styles: "circle" is text
Open in editor
Text
The text is everything after the last recognized attribute. It may contain spaces, punctuation, Unicode and even reserved words, since the attribute slots have already been passed by the time text starts:
a square Big red circle with a dashed border
a -> b Edges can say bold or blue too
Open in editor
Whitespace between words of text collapses to single spaces, and text ends at a comment. Only one URL is recognized; a second URL-like word is plain text.
docs /example.com see also /example.org
Open in editor
Text can mix plain and quoted words. The quotes are removed and the words are joined with single spaces, while whitespace inside the quotes is kept:
a square Step "1 -> 2" of "#3" # label: Step 1 -> 2 of #3
Open in editor
Starting text with a reserved word
If the label should begin with a reserved word, the reader will take that word as an attribute instead.
For example, n big data makes a big node labeled "data". The simplest fix is to
quote the word, or the whole label:
a big data
b red alert
c circle of friends
d hex nut
Open in editor
a "big" data
b "red alert"
c "circle of friends"
d 'hex' nut
Open in editor
Another way is to fill a later slot explicitly, so the reader is already past the slot the word belongs
to. The color slot is usually the easiest, using the default gray if you don't want a color:
b gray red alert. For edges, a -> b "dashed line" or
a -> b gray dashed line labels a gray, solid edge "dashed line". To start text with something that
looks like a URL, quote it: a "/etc/hosts" file.
Case
Reserved words are recognized only in lowercase. Big, RED and Circle are
always text, which is one more way to start a label with one of these words:
a Big Data
b Red Alert
Open in editor