termcol: separate gameboy table rows in cpcboy
[sheet.git] / termcol.plp
index bd9fd538f8117860593facfafecb8d588bf6625c..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,16 +127,13 @@ 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>';
@@ -151,6 +152,8 @@ sub coltable {
                        print "<tr><td colspan=$width>", img_egapal(\@imgpal, @{$_});
                }
        }
+               }
+
                say "</table>\n";
        }