charset: coalesce and abbreviate rowspan>3
authorMischa POSLAWSKY <perl@shiar.org>
Sat, 8 Apr 2017 16:07:40 +0000 (18:07 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Mon, 24 Apr 2017 23:51:41 +0000 (01:51 +0200)
Hide useless whitespace of huge CJK blocks; only indicate start and end rows.

charset.plp

index b1c680e1d833f41b623b981e8b878854bab4866c..18d7c50453c83ca2237ee5c9773473123f338a7f 100644 (file)
@@ -303,11 +303,22 @@ sub range_cell {
        }
        elsif (my $rows = int($len / $cols)) {
                # multiple full rows
+               my $rowsize = $colsize * $cols;
                if ($len -= $rows * $cols) {
                        # partial row remains
-                       $table->{$offset + $colsize*$rows * $cols} //= [$len*$colsize, "$class joinu", '', $title];
+                       $table->{$offset + $rowsize * $rows} //= [$len*$colsize, "$class joinu", '', $title];
                        $class .= ' joind';
                }
+
+               # coalesce multiple rows
+               while ($rows > 3) {
+                       $info->{skip}->{$offset += $rowsize}++;
+                       $rows--;
+               }
+               if ($rows > 2) {
+                       $info->{skip}->{$offset += $rowsize} = 0;
+               }
+
                $attr .= sprintf ' rowspan=%d', $rows;
                $len = $cols;
        }
@@ -346,7 +357,10 @@ for my $row (@request) {
                }
 
                print '<tr><th>';
-               {
+               if (defined $row->{skip}->{$offset}) {
+                       print '⋮';
+               }
+               else {
                        if (my $rowmod = $offset % $rowdiv) {
                                # offset in column units
                                printf '<small>+%X</small>', $rowmod;