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";
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;
$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>';
print "<tr><td colspan=$width>", img_egapal(\@imgpal, @{$_});
}
}
+ }
+
say "</table>\n";
}