modl Manual Override Diagram Language Open the editor

Gotchas

modl's parser is deliberately simple, and a few of its rules produce surprising results. Each gotcha below has an example you can open to see the behavior, plus a workaround. Many of them are avoided by quoting the label or id.

  1. -> in a label makes an edge
  2. Space before # starts a comment
  3. Out-of-order attributes become text
  4. Labels that start with a keyword
  5. Words in the middle of a chain are ignored
  6. A color alone on a line is a background
  7. Keywords are case-sensitive
  8. Ids can't contain dots or spaces
  9. A bad id in a chain joins its neighbors
  10. A dangling arrow
  11. Attributes can't be removed by redefining
  12. Edge size doesn't thicken lines
  13. Repeated, reverse and self edges overlap
  14. Long labels are truncated
  15. Image node quirks
  16. A leading / means https
  17. Renaming a node loses its position
  18. Edges run into wide nodes
  19. A quote at the start of a word opens a string

1. -> in a label makes an edge

Any line containing -> outside quotes is an edge line, even when the arrow is meant as text. Below, the first line was meant to be a node labeled "Input -> Output". Instead it creates an edge from step to a new node named Output, and "square Input" is silently dropped.

Problem
step square Input -> Output
Open in editor

Workaround: quote the label, or use a Unicode arrow such as →.

Fixed
step1 square "Input -> Output"
step2 square Input → Output
Open in editor

2. Space before # starts a comment

Outside quotes, whitespace followed by # ends the line. The label below is only "Fix issue".

Problem
bug square red Fix issue #42
Open in editor

Workaround: quote the label or the word with the #, or keep the # attached to the previous word.

Fixed
bug1 square red "Fix issue #42"
bug2 square red Fix issue "#42"
bug3 square red Fix issue#42
Open in editor

3. Out-of-order attributes become text

Attributes must come in the order size, style, color, URL. A word after its slot has been passed is label text, along with everything after it, URLs included.

Problem
a red square /example.com Home    # label is "square /example.com Home", no link
Open in editor
Fixed
a square red /example.com Home
Open in editor

See Attributes for more examples.

4. Labels that start with a keyword

If the label's first word is a reserved word for a slot that hasn't been passed yet, it becomes that attribute.

Problem: big node labeled "data", red node labeled "alert"
a big data
b red alert
Open in editor

Workaround: quote the word, fill a later slot (for example with the default color gray), or capitalize the word.

Fixed
a "big data"
b gray red alert
c Big Data
Open in editor

5. Words in the middle of a chain are ignored

In a … -> b … -> c …, only the last segment's attributes count. Everything after the id in earlier segments is dropped without an error.

Problem
a -> b red -> c dashed
Open in editor

Workaround: write differently styled edges on separate lines.

Fixed
a -> b red
b -> c dashed
Open in editor

6. A color alone on a line is a background

A line holding just a color name sets the background, so it can't declare a node called red.

Problem: turns the canvas red instead of adding a node
red
red -> green
Open in editor

Workaround: quote the id, give the node any attribute, or create it with an edge only.

Fixed
"red"
red -> green
Open in editor

7. Keywords are case-sensitive

Big, Square and Red aren't keywords, so they become the label.

Problem
a Big Square Red
Open in editor
Fixed
a big square red
Open in editor

8. Ids can't contain dots or spaces

Unquoted ids allow only letters, digits, _, : and -. A line starting with something like a domain name or version number is an error.

Problem
example.com square blue
v1.2 -> v1.3
Open in editor

Workaround: quote the id, or use a simple id and put the real name in the text.

Fixed
"example.com" square blue
"v1.2" -> "v1.3"
site square blue example.com
Open in editor

9. A bad id in a chain joins its neighbors

When an id in the middle of a chain is invalid, the editor reports an error but still draws the chain without that node, connecting the ids on either side. An invalid last id discards the whole line instead. Quote the id to keep it in the chain: a -> "b.x" -> c.

Draws a -> c, reports b.x
a -> b.x -> c
Open in editor

10. A dangling arrow

A line with an arrow but only one id, like a ->, is a malformed edge line error. Empty segments are skipped, though, so a -> b -> and a -> -> b both quietly mean a -> b.

One error, two edges
a ->
b -> c ->
d -> -> e
Open in editor

11. Attributes can't be removed by redefining

A later node line only overrides the attributes it gives. A bare id doesn't reset anything.

Still big, red and labeled
n big square red Label
n
Open in editor

Workaround: set attributes back explicitly (normal, circle, gray, and "" for the text) or delete the earlier line.

Fixed
n big square red Label
n normal circle gray ""
Open in editor

12. Edge size doesn't thicken lines

On edges, size only scales the label. For a thicker line use bold.

Problem: same thin line, bigger label
a -> b huge heavy?
Open in editor
Fixed
a -> b bold heavy
Open in editor

13. Repeated, reverse and self edges overlap

Edges are straight lines, so two edges between the same nodes are drawn on top of each other. Reverse edges overlap too, giving a double-headed arrow. A self edge like a -> a has no length, so its arrowhead and label are drawn on top of the node, covering the node's label.

Overlapping edges and a self edge
a -> b red one
a -> b blue two
b -> a green back
a -> a self
Open in editor

Workaround: combine parallel labels into one edge, or route through an extra node with shape none.

Two labeled routes between the same nodes
via1 small none red fast
via2 small none blue cheap
a -> via1 red
via1 -> b red
a -> via2 blue
via2 -> b blue
Open in editor

14. Long labels are truncated

Node labels show at most 22 characters and edge labels 28. The rest is replaced by …, and the full text shows on hover.

Truncated labels
a square A rather long name for a node
b square Short
a -> b This edge label is also quite long
Open in editor

Workaround: keep labels short, or put details in a linked page.

15. Image node quirks

Image with and without frame and text
a /curtcox.github.io/modl/docs/img/cloud.svg
b circle teal /curtcox.github.io/modl/docs/img/cloud.svg Cloud
a -> b
Open in editor

16. A leading / means https

/example.com/page is shorthand for https://example.com/page, not a path on the current site. There is no relative-link form. A URL can't contain spaces, since the first space ends it. Quoting doesn't help, because a quoted word is always text; write spaces as %20.

These go to https://docs/... and https://my
a /docs/intro.html Not a relative link
b /my page.html Space ends the URL
Open in editor

17. Renaming a node loses its position

Positions are stored by id. Changing an id, even its case, creates a new node that is placed automatically, and the old position is discarded. To relabel a node without moving it, change its text instead of its id.

18. Edges run into wide nodes

An edge stops at a fixed distance from a node's center rather than at its outline. A square is wider than that distance, so a line arriving from the side runs into the box and can cross the label. Large nodes make it worse.

Problem: side-on arrows cross square labels
a big square blue Source system
b big square purple Target system
a -> b
Open in editor

Workaround: place connected squares above and below each other rather than side by side, or use circles, which the lines don't enter.

Fixed
a big square blue Source system
b big square purple Target system
a -> b
Open in editor

19. A quote at the start of a word opens a string

A " or ' at the start of a word opens a string if the same quote appears anywhere later on the line, even in the middle of another word or in what would otherwise be a comment. Below, the leading apostrophes of 'tis and 'twas pair up and disappear. In the second line, the single-quoted string ends at the apostrophe in Bob's.

Problem
a 'tis and 'twas
b 'Bob's car'
Open in editor

Workaround: put text with apostrophes in double quotes, and text with double quotes in single quotes.

Fixed
a "'tis and 'twas"
b "Bob's car"
Open in editor