modl Manual Override Diagram Language Open the editor

Source structure

modl source is read one line at a time. Every line stands on its own: there are no blocks, no brackets, and no line continuations.

Kinds of lines

After its comment is removed, each line is classified by the first rule that matches:

  1. Blank: nothing left but whitespace, so the line is ignored.
  2. Background: the whole line is exactly one unquoted color name, which sets the background color.
  3. Edge: the line contains -> anywhere outside quotes, so it declares one or more edges.
  4. Node: anything else declares or updates a node.
One of each
# a comment line, then a blank line

teal               # background
a square Start     # node
a -> b             # edge
Open in editor

Because rule 3 only looks for -> somewhere in the line, an unquoted node label that contains -> turns the line into an edge line. Put such a label in quotes. See Gotchas.

Comments

A # starts a comment in two situations:

A # directly after another character is ordinary text. That keeps URL fragments and names like C# intact. A # inside quotes is always text.

Comment rules
# whole-line comment
    # indented whole-line comment
a square Server A        # trailing comment
lang square C# and F#    # the # in C# and F# is text; this one starts a comment
docs /example.com/page#section Fragment links survive
bug square "Fix issue #42"   # quoted, so the first # is text
Open in editor

Quoted strings

A word can be wrapped in double quotes "…" or single quotes '…'. Everything between the quotes is one word, taken literally: spaces, -> and # are just characters, and the word is never read as a size, shape, color or URL. The quotes themselves aren't part of the word.

Quoted text
a square "Input -> Output"      # an arrow in a label
b square red "Issue #42"        # a # in a label
c "big" data                    # a label starting with a reserved word
d "red"                         # a gray node labeled red
Open in editor

Ids can be quoted too, which lets them contain any characters. "a" and a are the same node.

Quoted ids
"example.com" square blue
"v1.2" -> "v1.3" upgrade
"example.com" -> "v1.2"
Open in editor

The rules for quotes:

Mixing quotes
a "Bob's car"
b 'She said "hi"'
c Bob's car                     # mid-word apostrophe: plain text
d "it's "'"fine"'
Open in editor

Whitespace

Whitespace doesn't matter
a->b
    b   ->    c
c	square	   lots    of     space
Open in editor

Line order

Lines can appear in any order. A node can be used in an edge before or after the line that styles it, and the result is the same:

Styles first
a square red Alpha
b hex blue Beta
a -> b
Open in editor
Edges first
a -> b
a square red Alpha
b hex blue Beta
Open in editor

Order matters in only two cases. When a node is declared more than once, later attributes override earlier ones (see Redefining nodes). When several background lines appear, the last one wins.

Background color

A line holding nothing but a color name (a trailing comment is fine) fills the canvas with that color. Without one, the editor's default dark backdrop shows through. Background colors are solid, unlike node fills, which are translucent.

Black background
black
a circle orange Sun
b circle blue Earth
a -> b yellow
Open in editor
White background
white
a square blue Light theme
a -> b black
b circle black
Open in editor
The last background line wins
red
blue
green     # this one is used
a -> b
Open in editor

Color names are case-sensitive, so Red alone on a line is a node named Red, not a background. All 12 colors are shown on Sizes, shapes, lines & colors.

Case sensitivity

Everything is case-sensitive. Web and web are different nodes, and only lowercase reserved words are recognized. BIG or Circle are just label text.

Case matters
web circle blue lowercase keywords work
Web Circle Blue capitalized ones are text
Open in editor

Errors

A line that can't be understood is listed in the editor's error box as Line N: …, counting blank and comment lines. The rest of the diagram still draws. The possible messages are listed in the grammar reference.

An error doesn't stop the rest
good -> fine
bad.id circle red     # Line 2: invalid node id "bad.id"
fine square teal Still drawn
Open in editor