Options: {
    allowDangerousCharacters?: boolean | null;
    allowDangerousHtml?: boolean | null;
    allowParseErrors?: boolean | null;
    bogusComments?: boolean | null;
    characterReferences?: CharacterReferences | null;
    closeEmptyElements?: boolean | null;
    closeSelfClosing?: boolean | null;
    collapseEmptyAttributes?: boolean | null;
    omitOptionalTags?: boolean | null;
    preferUnquoted?: boolean | null;
    quote?: Quote | null;
    quoteSmart?: boolean | null;
    space?: Space | null;
    tightAttributes?: boolean | null;
    tightCommaSeparatedLists?: boolean | null;
    tightDoctype?: boolean | null;
    tightSelfClosing?: boolean | null;
    upperDoctype?: boolean | null;
    voids?: ReadonlyArray<string> | null;
}

Configuration.

Type declaration

  • Optional allowDangerousCharacters?: boolean | null

    Do not encode some characters which cause XSS vulnerabilities in older browsers (default: false).

    ⚠️ Danger: only set this if you completely trust the content.

  • Optional allowDangerousHtml?: boolean | null

    Allow 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 allowParseErrors?: boolean | null

    Do 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 bogusComments?: boolean | null

    Use “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 characterReferences?: CharacterReferences | null

    Configure how to serialize character references (optional).

  • Optional closeEmptyElements?: boolean | null

    Close 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 closeSelfClosing?: boolean | null

    Close 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 collapseEmptyAttributes?: boolean | null

    Collapse 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 omitOptionalTags?: boolean | null

    Omit 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 preferUnquoted?: boolean | null

    Leave attributes unquoted if that results in less bytes (default: false).

    Not used in the SVG space.

  • Optional quote?: Quote | null

    Preferred quote to use (default: '"').

  • Optional quoteSmart?: boolean | null

    Use the other quote if that results in less bytes (default: false).

  • Optional space?: Space | null

    When 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 tightAttributes?: boolean | null

    Join 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 tightCommaSeparatedLists?: boolean | null

    Join 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 tightDoctype?: boolean | null

    Drop 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 tightSelfClosing?: boolean | null

    Do not use an extra space when closing self-closing elements: <img/> instead of <img /> (default: false).

    👉 Note: only used if closeSelfClosing: true or closeEmptyElements: true.

  • Optional upperDoctype?: boolean | null

    Use a <!DOCTYPE… instead of <!doctype… (default: false).

    Useless except for XHTML.

  • Optional voids?: ReadonlyArray<string> | null

    Tag 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.