It seems that the node-html-parser is doing some kind of correction of elements that have invalid HTML nesting, but only in some cases?
// valid HTML - nesting kept
const parsedA = parse(`<div>foo<div>bar</div></div>`);
console.log(parsedA.outerHTML); // `<div>foo<div>bar</div></div>`
// invalid HTML (p nested inside of p) - nesting changed
const parsedB = parse(`<p>foo<p>bar</p></p>`);
console.log(parsedB.outerHTML); // `<p>foo</p><p>bar</p>`
// invalid HTML (ul nested inside of p) - nesting kept
const parsedB = parse(`<p>foo<ul><li>bar</li></ul></p>`);
console.log(parsedB.outerHTML); // `<p>foo<ul><li>bar</li></ul></p>`
I found this issues #211 from @lehtu that says there is invalid nesting correction, but it only says it fixes the a tag, but the code above suggests that it is also happening for other elements like p? Shouldn't this be consistent - meaning either fix all invalid nesting or do not fix any invalid nesting?
It seems that the node-html-parser is doing some kind of correction of elements that have invalid HTML nesting, but only in some cases?
I found this issues #211 from @lehtu that says there is invalid nesting correction, but it only says it fixes the
atag, but the code above suggests that it is also happening for other elements likep? Shouldn't this be consistent - meaning either fix all invalid nesting or do not fix any invalid nesting?