chez-libs

Artifact [97554544e3]
Login

Artifact 97554544e332951db9958a90b93ec2dcffbe9742:

Wiki page [(data html)] by murphy 2018-02-02 16:21:40.
D 2018-02-02T16:21:40.501
L (data\shtml)
P bed3dbdd91e01055bc25e08d4700618ad238292a
U murphy
W 1935
<h1>HTML Output</h1>

<h2>Synopsis</h2>

<code>(import (data html))</code>

Encoding of S-expressions as [https://www.w3.org/TR/html5/|HTML5].

<h2>S-Expression HTML Grammar</h2>

Elements are represented as lists starting with a tag symbol, optionally followed by an association list of attributes and by element contents:
<code><pre>
html    → (SYMBOL content ...)
        | (SYMBOL ((SYMBOL . value) ...) content ...)
</pre></code>

The value of an attribute may be a boolean or a list of text contents:
<code><pre>
value   → BOOLEAN
        | (text ...)
</pre></code>

An attribute with value <tt>#f</tt> is not serialized as HTML5; an attribute with value <tt>#t</tt> is serialized without a value assignment in HTML5.

The contents of elements and attributes may consist of plain text and entity references represented as symbols or positive integers. Normal elements may also contain other elements:
<code><pre>
content → text
        | html

text    → STRING
        | NUMBER
        | SYMBOL
</pre></code>

<h2>Operations</h2>

<h3>procedure: <code>(js-encode <i>string</i>)</code></h3>

Replace dangerous characters in the string by backslash escape sequences. The result is safe to include in a JavaScript string between single or double quotes.

<h3>procedure: <code>(html-tag-rule <i>tag</i>)</code></h3>
<h3>procedure: <code>(html-tag-rule <i>tag</i> <i>rule</i>)</code></h3>

Get or set serialization rules for the given tag. The rule may be <tt>void</tt>, <tt>raw</tt> or <tt>normal</tt>. <tt>void</tt> elements cannot have contents, <tt>raw</tt> elements cannot have other elements as contents and <tt>normal</tt> elements are the default.

<h3>procedure: <code>(write-html <i>html</i>)</code></h3>
<h3>procedure: <code>(write-html <i>html</i> <i>port</i>)</code></h3>

Write an S-expression as HTML5 to the given port or to the <tt>(current-output-port)</tt>.

Z e6226993433daf9c56bc3a28859ac5df