(Video materials in preparation)
trconnect : merges <tr> elements
Usage : trconnect [-l<label>] num=<n> <html>
Version : Tue Jan 9 09:02:34 JST 2024
Edition : 2
Vertically merges <td> elements within <tr> elements surrounded by
<label>. For <tr> elements generated repeatedly with strmerge -l,
the first <n> keys specified by num=<n> are checked, and if they
have the same value then the table cell is heirarchicaly merged
vertically. For example, if there are five key cells in a row with
the same value, then the five cells are vertically merged. The
attribute rowspan="5" is added to the first <td> element, and the
remaining four <td> elements are commented out.
1. The <tr> and </tr> elements must be by themselves on different
lines.
2. The <td>..</td> or <th>..</th> must be independent blocks (can
span multiple lines).
3. The area enclosed by <label> cannot contain elements other than
<tr>, <th> or <td>.
4. If there are merged cells in the input html file, <td> elements
that are not to be displayed must be exist as comment like
follows:
<!-- <td>....</td> -->
If the data is not in HTML format as expected by trconnect, then the
output of trconnect is undefined.
$ cat html
<html>
<body>
<table>
<tbody>
<!-- TRCONNECT -->
<!-- MOJIHAME -->
<tr>
<td>%1</td>
<td>%2</td>
<td>%3</td>
</tr>
<!-- MOJIHAME -->
<!-- TRCONNECT -->
</tbody>
</table>
</body>
</html>
$ cat data
a x 1
a x 2
a y 1
a y 2
b z 3
$ strmerge -lMOJIHAME html data | trconnect -lTRCONNECT num=2
<html>
<body>
<table>
<tbody>
<tr>
<td rowspan="4">a</td>
<td rowspan="2">x</td>
<td>1</td>
</tr>
<tr>
<!-- <td>a</td> -->
<!-- <td>x</td> -->
<td>2</td>
</tr>
<tr>
<!-- <td>a</td> -->
<td rowspan="2">y</td>
<td>1</td>
</tr>
<tr>
<!-- <td>a</td> -->
<!-- <td>y</td> -->
<td>2</td>
</tr>
<tr>
<td>b</td>
<td>z</td>
<td>3</td>
</tr>
</tbody>
</table>
</body>
</html>