Function serializeOuter

  • Serializes an AST element node to an HTML string, including the element node.

    Type Parameters

    • T extends TreeAdapterTypeMap<
          unknown,
          unknown,
          unknown,
          unknown,
          unknown,
          unknown,
          unknown,
          unknown,
          unknown,
          unknown,
      > = DefaultTreeAdapterMap

    Parameters

    Returns string

    const parse5 = require('parse5');

    const document = parse5.parseFragment('<div>Hello, <b>world</b>!</div>');

    // Serializes the <div> element.
    const str = parse5.serializeOuter(document.childNodes[0]);

    console.log(str); //> '<div>Hello, <b>world</b>!</div>'