termcol: trim 8-colour xcolors palettes
[sheet.git] / termcol.plp
index 2c16fe9999d38001eb8cc167e09337443503c7ee..26a5c70e4343d71a343484ee7a91f3a1e6c30624 100644 (file)
@@ -46,8 +46,6 @@ use POSIX qw( ceil );
 
 my $palettes = do 'termcol.inc.pl';
 die "Cannot open palette data: $_\n" for $@ || $! || ();
-my $more = do 'termcol-xcolor.inc.pl' || {};
-$palettes = {%$palettes, %$more};
 
 sub colcell {
        my $name = shift // return "<td>\n";
@@ -108,6 +106,12 @@ sub coltable {
 
        if (ref $info eq 'ARRAY') {
                coltable($_) for @{$info};
+               return;
+       }
+
+       if (ref $info eq 'CODE') {
+               coltable($_) for $info->($palettes);
+               return;
        }
 
        ref $info eq 'HASH' or return;
@@ -134,6 +138,10 @@ sub coltable {
                say '<table class="color mapped">';
                say sprintf '<caption>%s</caption>', $caption;
                for my $row (@$table) {
+                       if (!$row) {
+                               say '<tbody>';
+                               next;
+                       }
                        print '<tr>';
                        print colcell(ref $_ ? @$_ : $_ ? reverse split /:/ : undef) for @$row;
                }