Zettelmarkup: Attributes

00001007050000 · Info · (manual) · #manual #zettelmarkup #zettelstore

Attributes allows to modify the way how material is presented. Alternatively, they provide additional information to markup elements. To some degree, attributes are similar to HTML attributes➚.

Typical use cases for attributes are to specify the (natural) language for a text region, to specify the programming language for highlighting program code, or to make white space visible in plain text.

Attributes are specified within curly brackets {...}. Of course, more than one attribute can be specified. Attributes are separated by a sequence of space characters or by a comma character.

An attribute normally consists of an optional key and an optional value. The key is a sequence of letters, digits, a hyphen-minus (“-”, U+002D, and a low line / underscore (“_”, U+005D). It can be empty. The value is a sequence of any character, except space and the right curly bracket (“}”, U+007D). If the value must contain a space or the right curly bracket, the value can be specified within two quotation marks (“"”, U+0022). Within the quotation marks, the backslash character functions as an escape character to specify the quotation mark (and the backslash character too).

Some examples:

In these examples, key must conform the the syntax of attribute keys, even if it is used as a value.

If a key is given more than once in an attribute, the values are concatenated (and separated by a space).

This is not true for the generic attribute. In {=key1 =key2}, the first key is ignored. Therefore it is equivalent to {=key2}.

The key “-” (just hyphen-minus) is special. It is called default attribute and has a markup specific meaning. For example, when used for plain text, it replaces the non-visible space with a visible representation:

For some block elements, there is a syntax variant if you only want to specify a generic attribute. For all line-range blocks you can specify the generic attributes directly in the first line, after the three (or more) block characters.

:::attr
...
:::

is equivalent to

:::{=attr}
...
:::

For other blocks, the closing curly bracket must be on the same line where the block element begins. However, spaces are allowed between the blocks characters and the attributes.

=== Heading {style=color:green}

is allowed and equivalent to

=== Heading{style=color:green}

But

=== Heading {style=color:green
background=grey}

is not allowed. Same for

=== Heading {style=color:"
green"}

For inlines, the attributes must immediately follow the inline markup. However, the attributes may be continued on the next line when a space or line ending character is possible.

::GREEN::{style=color:green} is allowed, but not ::GREEN:: {style=color:green}.

::GREEN::{style=color:green
background=grey}

is allowed, but not

::GREEN::{style=color:
green}

However,

::GREEN::{style=color:"
green"}

is allowed, because line endings are allowed within quotes.

Reference material