node-html-parser
node-html-parser copied to clipboard
BUG: outerHTML drop <script>'s start tag
<!DOCTYPE html
><html lang="en"
><meta charset="UTF-8"
><title aria-live="polite">test</title
><link href="/style/app" rel="stylesheet"
><link rel="icon" href="/image/logo"><script src="/script/app" type="module"></script
></html>
Parse the above and then retrieve the document text from outerHTML.
The <script> will be dropped, making the end </script> tag immediately follow <link>:
<link rel="icon" href="/image/logo"></script
The result is caused by close tag. you may try this:
const html = `<!DOCTYPE html
><html lang="en"
><meta charset="UTF-8"
><title aria-live="polite">test</title
><link href="/style/app" rel="stylesheet"
><link rel="icon" href="/image/logo"><script src="/script/app" type="module"></script
></html>`.replace(/\n*>/g, '>');
const root = parse(html);