Parse HTML safely with a tag allowlist, converting disallowed elements to text nodes.
The HTML string to parse. Non-string or empty values return an empty fragment.
Array of allowed tag names. Defaults to ["p","br","strong","em","span","a","ul","ol","li","b","i"].
["p","br","strong","em","span","a","ul","ol","li","b","i"]
A DocumentFragment containing the sanitized DOM nodes.
DocumentFragment
Parses untrusted HTML, keeping only whitelisted tags; validates link hrefs via validateUrl.
Parse HTML safely with a tag allowlist, converting disallowed elements to text nodes.