+sub coltable {
+ my ($term) = @_;
+ my $info = $palettes->{$term};
+ ref $info eq 'HASH' or next;
+
+ my $caption = $info->{name} // $term;
+ $caption = sprintf('<%s %s>%s</%1$s>',
+ $info->{href} ? 'a' : 'span',
+ join(' ',
+ map { sprintf '%s="%s"', $_, $info->{$_} }
+ grep { defined $info->{$_} }
+ qw( href title )
+ ),
+ $caption,
+ ) if $info->{href} or $info->{title};
+
+ if (my $mapinfo = $info->{rgbmap}) {
+ print '<table class="color mapped">'."\n";
+ printf "<caption>%s</caption>\n", $caption;
+ print coltable_hsv(@{$mapinfo});
+ print "</table>\n\n";
+ }
+
+ if (my $table = $info->{table}) {
+ print '<table class="color mapped">'."\n";
+ printf "<caption>%s</caption>\n", $caption;
+ for my $row (@$table) {
+ print '<tr>';
+ print colcell(@$_) for @$row;
+ }
+
+ my $width = scalar @{ $table->[0] };
+ my @imgpal = map { [ @{$_}[1 .. 3] ] } map { @{$_} } @{$table};
+ for (@draw) {
+ print "<tr><td colspan=$width>", img_egapal(\@imgpal, @{$_});
+ }
+ print "</table>\n\n";
+ }
+
+ if (my $palette = $info->{list}) {
+ my $order = $get{order} && $get{order}.'order';
+ my $colours = colorder($palette,
+ $info->{$order} // $palettes->{ $info->{parent} }->{$order}
+ );
+
+ my $rows = 8;
+ my $columns = ceil(@{$palette} / $rows);
+
+ print '<table class=color>', "\n";
+ printf "<caption>%s</caption>\n", $caption;
+ for my $row (0 .. $rows - 1) {
+ print '<tr>';
+ for my $col (0 .. $columns - 1) {
+ my $num = $row + $col * $rows;
+ my ($rgb, $name) = split /:/, $colours->[$num], 3;
+ $name //= $rgb && $num;
+ $name = [ $name, [] ] if $term =~ /^msx/ and !$num;
+ $name = [ $name, ['#333'] ] if $term eq 'xkcd';
+ print colcell($name, $rgb);
+ }