charset: realsize option to keep utf-8 table unabbreviated
authorMischa POSLAWSKY <perl@shiar.org>
Sat, 8 Apr 2017 21:33:21 +0000 (23:33 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Mon, 24 Apr 2017 23:51:41 +0000 (01:51 +0200)
Hardcoded rowspans break with recently introduced row abbreviation.

charset.plp

index 74ea8e7c2d4095cc57aee87b80d64e96f495c277..e82e3d7b25f07412a26a22805f653a702bb04664 100644 (file)
@@ -77,7 +77,7 @@ sub tabinput {
        my $input = shift or return;
 
        state $ALIAS = {
-               default    => [qw( unicode+0-639 utf-8 iso-8859-1 iso-8859-15 cp1252 cp437 cp850 )],
+               default    => [qw( unicode+0-639 utf-8+realsize iso-8859-1 iso-8859-15 cp1252 cp437 cp850 )],
                uc         => [qw( U+cols=32 unicode+0-4095 unicode+4096-6319  unicode+6320-8191 )],
                us         => [qw( cp437 cp863 gsm0338 AdobeStandardEncoding )],
                ebcdic     => [qw( cp37 cp500 cp1047 posix-bc cp1026 cp875 )],
@@ -222,7 +222,10 @@ sub tabinput {
        }
 
        for my $param (split /[+]+/, $params // '') {
-               if ($param =~ m{ \A cols = (\d+) \z }x) {
+               if ($param eq 'realsize') {
+                       $row{realsize}++;
+               }
+               elsif ($param =~ m{ \A cols = (\d+) \z }x) {
                        $row{cols} = $1;
                }
                elsif ($param =~ m{ \A (?<offset> \d+) (?: [-] (?<endpoint> \d+) )? \z }x) {
@@ -361,13 +364,15 @@ sub range_cell {
                        $class .= ' joind';
                }
 
-               # coalesce multiple rows
-               while ($rows > 3) {
-                       $info->{skip}->{$offset += $rowsize}++;
-                       $rows--;
-               }
-               if ($rows > 2) {
-                       $info->{skip}->{$offset += $rowsize} = 0;
+               unless ($info->{realsize}) {
+                       # coalesce multiple rows
+                       while ($rows > 3) {
+                               $info->{skip}->{$offset += $rowsize}++;
+                               $rows--;
+                       }
+                       if ($rows > 2) {
+                               $info->{skip}->{$offset += $rowsize} = 0;
+                       }
                }
 
                $attr .= sprintf ' rowspan=%d', $rows;