termcol: separate gameboy table rows in cpcboy
[sheet.git] / termcol.plp
index 2c16fe9999d38001eb8cc167e09337443503c7ee..a090fc7ffe7a36ee3583b570abf1863d92cf338d 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;
@@ -123,17 +127,18 @@ sub coltable {
                $caption,
        ) if $info->{href} or $info->{title};
 
-       if (my $mapinfo = $info->{rgbmap}) {
+       if ($info->{table} or $info->{rgbmap}) {
                say '<table class="color mapped">';
                say sprintf '<caption>%s</caption>', $caption;
-               print coltable_hsv(@{$mapinfo});
-               say "</table>\n";
-       }
 
-       if (my $table = $info->{table}) {
-               say '<table class="color mapped">';
-               say sprintf '<caption>%s</caption>', $caption;
+               print coltable_hsv(@{$_}) for $info->{rgbmap} || ();
+
+               if (my $table = $info->{table}) {
                for my $row (@$table) {
+                       if (!$row) {
+                               say '<tbody>';
+                               next;
+                       }
                        print '<tr>';
                        print colcell(ref $_ ? @$_ : $_ ? reverse split /:/ : undef) for @$row;
                }
@@ -147,6 +152,8 @@ sub coltable {
                        print "<tr><td colspan=$width>", img_egapal(\@imgpal, @{$_});
                }
        }
+               }
+
                say "</table>\n";
        }