SHTML Encoding
manual
api manual reference zettelstore
zmk
00001004051200 00001012920500
00001004051200 00001012920500
1
(c) 2020-present by Detlef Stern
20230316181044
00001012920510 00001012920516 00001012930000
en
EUPL-1.2-or-later
20230403150657
20230403150657
public
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:
/z/00001012920525?enc=shtml&part=zettel,
/z/00001012920525?enc=shtml&part=meta,
/z/00001012920525?enc=shtml&part=content.
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 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).