zzzprojects/html-agility-pack

The html rendering result is different from the html output result when we have two unclosed tbody tags

pauloortins opened this issue · 2 comments

When we have two unclosed tbody tags the output is different from the way chrome renders it.
While chrome closes the first tbody before the second opening tbody, HAP adds two closing tbody tags at the end.

HTML: <table><tbody><tr><td></td></tr><tbody><tr><td></td></tr></table>
HAP Result: <table><tbody><tr><td></td></tr><tbody><tr><td></td></tr></tbody></tbody></table>
Chrome Result: <table><tbody><tr><td></td></tr></tbody><tbody><tr><td></td></tr></tbody></table>

This is the test I used:

var html = @"<table><tbody><tr><td></td></tr><tbody><tr><td></td></tr></table>";
var doc = new HtmlDocument();
doc.LoadHtml(html);
var newHtml = doc.DocumentNode.OuterHtml;  //<table><tbody><tr><td></td></tr><tbody><tr><td></td></tr></tbody></tbody></table>
var res = @"<table><tbody><tr><td></td></tr></tbody><tbody><tr><td></td></tr></tbody></table>"; //chrome or edge rendering results
var b = newHtml == res; //false

Hello @pauloortins ,

Thank you for reporting.

We will add a rule similar to what we did here for <tbody>: a7b18a3

Best Regards,

Jon

Hello @pauloortins ,

v1.11.60 is now available. The tbody will now be closed when the parent tag is also a tbody, like in your case.

Best Regards,

Jon