Skip to content

Commit

Permalink
Trigger a close of td, th and tr tags on tbody
Browse files Browse the repository at this point in the history
When previous TD, TH or TR tags were left open, close them when a TBODY
tag is found.
  • Loading branch information
rodarima committed Jun 22, 2024
1 parent a51dc7a commit 4e180b9
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/html.cc
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ static int
i_TEXTAREA = a_Html_tag_index("textarea"),
i_TD = a_Html_tag_index("td"),
i_TR = a_Html_tag_index("tr"),
i_TBODY = a_Html_tag_index("tbody"),
i_TH = a_Html_tag_index("th");


Expand Down Expand Up @@ -3634,10 +3635,10 @@ static int Html_triggers_optional_close(int old_idx, int cur_idx)
} else if (old_idx == i_TD || old_idx == i_TH) {
/* TD and TH are closed by: TD, TH and TR.
* Note: non-flow should also close it, but FF does not. */
return (cur_idx == i_TD || cur_idx == i_TH || cur_idx == i_TR);
return (cur_idx == i_TD || cur_idx == i_TH || cur_idx == i_TR || cur_idx == i_TBODY);
} else if (old_idx == i_TR) {
/* TR closes TR */
return (cur_idx == i_TR);
return (cur_idx == i_TR || cur_idx == i_TBODY);
} else if (old_idx == i_DD) {
/* DD is closed by DD and DT */
return (cur_idx == i_DD || cur_idx == i_DT);
Expand Down

0 comments on commit 4e180b9

Please sign in to comment.