title: Encoding of Sz
role: manual
tags: #api #manual #reference #zettelstore
syntax: zmk
backward: 00001012920516
box-number: 1
copyright: (c) 2020-present by Detlef Stern <ds@zettelstore.de>
created: 20230403153903
forward: 00001006020000 00001007030000 00001007040000 00001007050000 00001012920516 00001012930000 00001012931200 00001012931400 00001012931600 00001012931800
lang: en
license: EUPL-1.2-or-later
modified: 20260612185204
published: 20260612185204
visibility: public

Zettel in a [Sz encoding](00001012920516) are represented as a [symbolic expression](00001012930000).
To process these symbolic expressions, you need to know, how a specific part of a zettel is represented by a symbolic expression.

Basically, each part of a zettel is represented as a list, often a nested list.
The first element of that list is always a unique symbol, which denotes that part.
The meaning / semantic of all other elements depend on that symbol.

# Zettel

A full zettel is represented by a list of two elements.
The first element represents the metadata, the second element represents the zettel content.

*Zettel* __=__ `(` [*Metadata*](#metadata) [*Content*](#content) `)`.

# Metadata

Metadata is represented by a list, where the first element is the symbol `META`.
Following elements represent each metadatum of a zettel in standard order.

Standard order is: [Title](00001006020000#title), [Role](00001006020000#role), [Tags](00001006020000#tags), [Syntax](00001006020000#syntax), all other [keys](00001006020000) in alphabetic order.

*Metadata* __=__ `(META` [*Metadatum*](00001012931200) … `)`.

# Content

Zettel content is represented by a block.

*Content* __=__ [*Block*](#block).

## Block

A block is represented by a list with the symbol `BLOCK` as the first element.
All following elements represent a nested [block-structured element](00001007030000).

*Block* __=__ `(BLOCK` [*BlockElement*](00001012931400) … `)`.

## Inline

Both block-structured elements and some metadata values may contain [inline-structured elements](00001007040000).
Similar, inline-structured elements are represented as follows:

*Inline* __=__ `(INLINE` [*InlineElement*](00001012931600) … `)`.

## Attribute

[Attributes](00001007050000) may be specified for both block- and inline- structured elements.
Attributes are represented by the following schema.

*Attribute* __=__ `(` __[__ [*AttributeKeyValue*](00001012931800) … __]__ ')'.

Either, there are no attributes.
These are specified by the empty list `()`.
Or there are attributes.
In this case, the first element of the list must be the symbol `quote`: `(quote` `(` A<sub>1</sub> A<sub>2</sub> … A<sub>n</sub> `)``)`.

# Other

## `UNKNOWN`

A list with `UNKNOWN` as its first element signals an internal error during transforming a zettel into the Sz encoding.
It may be ignored or may result in an error.

*Unknown* __=__ `(UNKNOWN` Object … `)`.

The list may only contain the symbol `UNKNOWN`, or, in addition, an unlimited amount of other objects.

## `**xyz:NOT-FOUND**`

Any symbol with the pattern `**xyz:NOT-FOUND**`, where &ldquo;`xyz`&rdquo; is any string, signals an internal error.

## `*SPLICE-NODES*`

A list with `*SPLICE-NODES*` as its first element may occur during internal processing.
It signals that some processing routine intends to return more than one object instead of just one [*BlockElement*](00001012931400) or one [*InlineElement*](00001012931600).
The elements of such a list should be &ldquo;spliced&rdquo; into the parent list.

## NIL (or `()`)

Analogous to a splice node, which signals that more than one values is about to be returned, a &ldquo;NIL&rdquo; value (denoted as &ldquo;`()`&rdquo;) signals that no object should be returned.
Therefore, a [*BlockElement*](00001012931400) or an [*InlineElement*](00001012931600) may be &ldquo;NIL&rdquo;.