Node to serialize.
Optionaloptions: SerializerOptions<T>
Serialization options.
import * as parse5 from 'parse5';
const document = parse5.parse('<!DOCTYPE html><html><head></head><body>Hi there!</body></html>');
// Serializes a document.
const html = parse5.serialize(document);
// Serializes the <html> element content.
const htmlElement = document.childNodes.find(parse5.defaultTreeAdapter.isElementNode);
if (htmlElement) {
const str = parse5.serialize(htmlElement);
console.log(str); //> '<head></head><body>Hi there!</body>'
}
Serializes an AST node to an HTML string.