@rhys87 & @v-chenzhi
I realised a while back one thing, and just now another.
All of our answers thus far are not strictly valid, because HTML allows for a table to be made within a table.
So you will need to caveat to whomever this is for that the following failure scenarios are true:
- Definite Failure - When there is a table within a table.
- Probable Failure - When there any <colspan¹ or <rowspan² tags.
Example of a table in a table:
| nameGiven | nameFamily | favouriteHtml |
| Jane | Smith | Emboldened text like this. |
| John | Jones | Tables like this: | header1 | header1 | header1 | | entryA | answerA | dataA | | entryB | answerB | dataB |
|
The code for this (literally ripped from this post 😅😞
<table border="1" width="100%">
<tbody>
<tr>
<td width="14.197530864197535%"><strong>nameGiven</strong></td>
<td width="16.54320987654321%"><strong>nameFamily</strong></td>
<td width="69.25925925925927%"><strong>favouriteHtml</strong></td>
</tr>
<tr>
<td width="14.197530864197535%">Jane</td>
<td width="16.54320987654321%">Smith</td>
<td width="69.25925925925927%">
<p>Emboldened text like <strong>this</strong>.</p>
</td>
</tr>
<tr>
<td width="14.197530864197535%">John</td>
<td width="16.54320987654321%">Jones</td>
<td width="69.25925925925927%">
<p>Tables like this:</p>
<table border="1" width="100%">
<tbody>
<tr>
<td width="33.333333333333336%"><strong>header1</strong></td>
<td width="33.333333333333336%"><strong>header1</strong></td>
<td width="33.333333333333336%"><strong>header1</strong></td>
</tr>
<tr>
<td width="33.333333333333336%">entryA</td>
<td width="33.333333333333336%">answerA</td>
<td width="33.333333333333336%">dataA</td>
</tr>
<tr>
<td width="33.333333333333336%">entryB</td>
<td width="33.333333333333336%">answerB</td>
<td width="33.333333333333336%">dataB</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
As you can see, if we split as we have been doing, this will mean the first table will not close properly('legally'), especially if there are more rows below the table. If that table is on a page where there are two root level tables (with one or more having a sub table) then you are in even more trouble.
To be clear, it's still doable, and I suspect some creative use of indexOf() and/or substring() could help here, but it will result in either huge expressions, or increased (and therefore slower) action steps, for sure.
_________
Footnotes:
- data spans multiple columns
- data spans multiple rows