Parse HTML string into a DOM document.
HTML string to parse
Optional
Optional base URL for resolving relative URLs
Parsed DOM document
Parses HTML using linkedom, providing a standards-compliant DOM implementation. This should be called once per document, with the result passed to all metadata extractors for performance.
Never throws - returns a document even for malformed HTML.
const doc = parseHTML('<html><head><title>Test</title></head></html>');const title = doc.querySelector('title')?.textContent; Copy
const doc = parseHTML('<html><head><title>Test</title></head></html>');const title = doc.querySelector('title')?.textContent;
Parse HTML string into a DOM document.