SHTML Encoding

00001012920525 · Info · (manual) · #api #manual #reference #zettelstore

A zettel representation that is a s-expression, syntactically similar to the Sz encoding, but denotes HTML semantics. It is derived from a XML encoding in s-expressions, called SXML.

It is (relatively) easy to parse and contains everything to transform it into real HTML. In contrast to HTML, SHTML is easier to parse and to manipulate. For example, take a look at the SHTML encoding of this page, which is available via the “Info” sub-page of this zettel:

If transferred via HTTP, the content type will be text/plain.

Internally, if a zettel should be transformed into HTML, the zettel is translated into the Sz encoding, which is transformed into this SHTML encoding to produce the HTML encoding.

Syntax of SHTML

There are only two types of elements: atoms and lists, similar to the Sz encoding.

A list always starts with the left parenthesis (“(”, U+0028) and ends with a right parenthesis (“)”, U+0029). A list may contain a possibly empty sequence of elements, i.e. lists and / or atoms. Before the last element of a list of at least to elements, a full stop character (“.”, U+002E) signal a pair as the last two elements. This allows a more space economic storage of data.

An HTML tag like < a href="link">Text</a> is encoded in SHTML with a list, where the first element is a symbol named a the tag. The second element is an optional encoding of the tag's attributes. Further elements are either other tag encodings or a string. The above tag is encoded as (a (@ (href . "link")) "Text"). Also possible is to encode the attribute without pairs: (a (@ (href "link")) "Text") (note the missing full stop character).