charset: cols option to override table width
authorMischa POSLAWSKY <perl@shiar.org>
Sat, 8 Apr 2017 21:11:44 +0000 (23:11 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Mon, 24 Apr 2017 23:51:41 +0000 (01:51 +0200)
Properly implemented configuration to replace doubling hack (trailing +).

charset.plp

index 8996c5866975ad4fcc4ebf3ffc7c38691bd663db..33e5db49c3af58910f0f2048e1412343cabd5141 100644 (file)
@@ -78,7 +78,7 @@ sub tabinput {
 
        state $ALIAS = {
                default    => [qw( unicode+0-639 utf-8 iso-8859-1 iso-8859-15 cp1252 cp437 cp850 )],
 
        state $ALIAS = {
                default    => [qw( unicode+0-639 utf-8 iso-8859-1 iso-8859-15 cp1252 cp437 cp850 )],
-               uc         => [qw( U++ unicode+0-4095 unicode+4096-6319  unicode+6320-8191 )],
+               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 )],
                iso        => [map {"iso-8859-$_"} 1 .. 11, 13 .. 16],
                us         => [qw( cp437 cp863 gsm0338 AdobeStandardEncoding )],
                ebcdic     => [qw( cp37 cp500 cp1047 posix-bc cp1026 cp875 )],
                iso        => [map {"iso-8859-$_"} 1 .. 11, 13 .. 16],
@@ -221,13 +221,11 @@ sub tabinput {
                $visible->{$_} //= 0 for $row{parent} || ();
        }
 
                $visible->{$_} //= 0 for $row{parent} || ();
        }
 
-       if (length $params) {
-               # manual option to double table width
-               $row{cols} *= 2 if $params =~ s/[+]\z//;
-       }
-
        for my $param (split /[+]+/, $params // '') {
        for my $param (split /[+]+/, $params // '') {
-               if ($param =~ m{ \A (?<offset> \d+) (?: [-] (?<endpoint> \d+) )? \z }x) {
+               if ($param =~ m{ \A cols = (\d+) \z }x) {
+                       $row{cols} = $1;
+               }
+               elsif ($param =~ m{ \A (?<offset> \d+) (?: [-] (?<endpoint> \d+) )? \z }x) {
                        if ($row{offset}) {
                                my $skip = int(($row{endpoint} || $row{offset}) / $row{cols});
                                for ($skip + 1 .. ($+{offset} / $row{cols}) - 1) {
                        if ($row{offset}) {
                                my $skip = int(($row{endpoint} || $row{offset}) / $row{cols});
                                for ($skip + 1 .. ($+{offset} / $row{cols}) - 1) {