Attribute shorthands

The four ways an attribute can be written shorter than key: value — implicit values, bare booleans, ! negation and aliases.

#:value, the implicit attribute

:value in the head fills whichever attribute the element declares first — its implicit attribute. Every reference page marks which one that is. The value is a simple token: it ends at the first bracket, whitespace, or end of line, so anything longer is written in the group instead.

image:photo.jpg(caption: Fig 1)    image(source: photo.jpg; caption: Fig 1)
curve:x^2(colour: blue)            curve(expression: x^2; colour: blue)

A node is still recognised only by its bracket, so the shorthand does not remove the need for one: image:photo.jpg on its own is a paragraph, and image:photo.jpg() is the node. Micronodes and directives carry their own sigil and stand bare — @include:overview.part.chalk needs no bracket.

#Boolean shorthand

An attribute typed bool may be written as a bare name, with no : and no value, and ! before the name sets it false. curve(dashed) is curve(dashed: true); curve(!dashed) is curve(dashed: false). The negated form reaches attributes that default to true — show-ticks, show-axes and show-background among them, though show-grid defaults to false.

curve(expression: x^2; dashed)
canvas.graph{}(show-grid; !show-ticks)
The ! here is not the micronode sigil. In an attribute group a leading ! on a name negates a boolean; in prose or a value it opens a micronode. The position tells them apart, so hidden: false, !hidden and hidden: true !cue.to{false}(at: 2) are three different statements about the same attribute.

#Hyphens and case in attribute names

An attribute name is an identifier. Written as a key, it folds internal whitespace to a single hyphen and matches case-insensitively, so x-domain, x domain, X-DOMAIN and X Domain all set the same attribute.

canvas.graph{}(x domain: [0, 5])    sets x-domain
canvas.graph{}(Show-Grid)           sets show-grid: true

The folding applies to keys and to {{ }} substitutions, not to bindings. A binding carries the name through to the renderer exactly as written, so a hyphenated attribute must be referred to by its canonical spelling — #id.text-size resolves and #id.text size does not. Every reference page lists the canonical name, and it is the one to write in every position.

#Aliases

Many attributes accept more than one spelling: colour and color, scatter's data and points, curve's expression, exp, f, func and function. Aliases are declared by the element, not general rewriting, so a reference page's attribute table is the list of what that element takes.