Closed depeiwang closed 2 years ago
I got a non-standard code like this:
const badHtml = ` <!DOCTYPE html> <html> <body> <div id="abc"> <ol> <li> <p>hello</p> </li> <li> <p>world</p> </li> <li> <!-- miss </p> here --> <p> </li> </ol> </div> </body> </html> `;
it's miss close tag: </p>, and when i parse this html by node-html-parser, i got a bad parse result, here is my test code:
</p>
const { parse } = require("node-html-parser"); (() => { const doc = parse(badHtml); const div = doc.querySelector("#abc"); console.log(div === null); // output: true console.log(doc.toString()); })();
when i print doc.toString() to console, the result is:
doc.toString()
<!DOCTYPE html> <html> <li> <p>hello</p> </li> <li> <p>world</p> </li> <p> </p> </html>
the div tag is deleted. Is it possible to automatically fill in missing tags?
same issue: https://github.com/taoqf/node-html-parser/issues/152
I got a non-standard code like this:
it's miss close tag:
</p>
, and when i parse this html by node-html-parser, i got a bad parse result, here is my test code:when i print
doc.toString()
to console, the result is:the div tag is deleted. Is it possible to automatically fill in missing tags?