Optional allowDo not encode some characters which cause XSS vulnerabilities in older
browsers (default: false).
⚠️ Danger: only set this if you completely trust the content.
Optional allowAllow raw nodes and insert them as raw HTML (default: false).
When false, Raw nodes are encoded.
⚠️ Danger: only set this if you completely trust the content.
Optional allowDo not encode characters which cause parse errors (even though they work),
to save bytes (default: false).
Not used in the SVG space.
👉 Note: intentionally creates parse errors in markup (how parse errors are handled is well defined, so this works but isn’t pretty).
Optional bogusUse “bogus comments” instead of comments to save byes: <?charlie>
instead of <!--charlie--> (default: false).
👉 Note: intentionally creates parse errors in markup (how parse errors are handled is well defined, so this works but isn’t pretty).
Optional characterConfigure how to serialize character references (optional).
Optional closeClose SVG elements without any content with slash (/) on the opening tag
instead of an end tag: <circle /> instead of <circle></circle>
(default: false).
See tightSelfClosing to control whether a space is used before the
slash.
Not used in the HTML space.
Optional closeClose self-closing nodes with an extra slash (/): <img /> instead of
<img> (default: false).
See tightSelfClosing to control whether a space is used before the
slash.
Not used in the SVG space.
Optional collapseCollapse empty attributes: get class instead of class="" (default:
false).
Not used in the SVG space.
👉 Note: boolean attributes (such as
hidden) are always collapsed.
Optional omitOmit optional opening and closing tags (default: false).
For example, in <ol><li>one</li><li>two</li></ol>, both </li> closing
tags can be omitted.
The first because it’s followed by another li, the last because it’s
followed by nothing.
Not used in the SVG space.
Optional preferLeave attributes unquoted if that results in less bytes (default: false).
Not used in the SVG space.
Optional quote?: Quote | nullPreferred quote to use (default: '"').
Optional quoteUse the other quote if that results in less bytes (default: false).
Optional space?: Space | nullWhen an <svg> element is found in the HTML space, this package already
automatically switches to and from the SVG space when entering and exiting
it (default: 'html').
👉 Note: hast is not XML. It supports SVG as embedded in HTML. It does not support the features available in XML. Passing SVG might break but fragments of modern SVG should be fine. Use [
xast][xast] if you need to support SVG as XML.
Optional tightJoin attributes together, without whitespace, if possible: get
class="a b"title="c d" instead of class="a b" title="c d" to save
bytes (default: false).
Not used in the SVG space.
👉 Note: intentionally creates parse errors in markup (how parse errors are handled is well defined, so this works but isn’t pretty).
Optional tightJoin known comma-separated attribute values with just a comma (,),
instead of padding them on the right as well (,␠, where ␠ represents a
space) (default: false).
Optional tightDrop unneeded spaces in doctypes: <!doctypehtml> instead of
<!doctype html> to save bytes (default: false).
👉 Note: intentionally creates parse errors in markup (how parse errors are handled is well defined, so this works but isn’t pretty).
Optional tightDo not use an extra space when closing self-closing elements: <img/>
instead of <img /> (default: false).
👉 Note: only used if
closeSelfClosing: trueorcloseEmptyElements: true.
Optional upperUse a <!DOCTYPE… instead of <!doctype… (default: false).
Useless except for XHTML.
Optional voids?: ReadonlyArray<string> | nullTag names of elements to serialize without closing tag (default: html-void-elements).
Not used in the SVG space.
👉 Note: It’s highly unlikely that you want to pass this, because hast is not for XML, and HTML will not add more void elements.
Configuration.