The parse(data, options) method parses the provided HTML string and returns the root of the generated DOM.
Options object schema:
{
lowerCaseTagName: false, // convert tag name to lower case (hurts performance heavily)
comment: false, // retrieve comments (hurts performance slightly)
fixNestedATags: false, // fix invalid nested <a> HTML tags
parseNoneClosedTags: false, // close none closed HTML tags instead of removing them
preserveTagNesting: false, // preserve invalid HTML nesting instead of auto-closing tags (e.g. <p><p>bar</p></p>)
voidTag: {
tags: ['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'param', 'source', 'track', 'wbr'], // default list
closingSlash: true // add a final slash <br/> during serialization
},
blockTextElements: {
script: true, // keep text content when parsing
noscript: true,
style: true,
pre: true
},
closeAllByClosing: false // Close all non-closed tags when containing element closes
}