-for my $term (qw/html cga xterm tango/) {
- print '<li>', "\n";
- print '<table>', "\n";
- print "<caption>$term</caption>\n";
- for my $num (0 .. 15) {
- my $rgb = $col{$term}[$num + 2];
- print '<tr>',
- colcell($term eq 'html' ? $col{-name}[$num] : $num, $rgb, $col{$term}[0]);
+for my $term (@termlist) {
+ 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 $palette = $info->{list}) {
+ my $colours = colorder($palette, $get{v} && $info->{ansiorder});
+
+ 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);
+ }
+ }
+
+ for (@draw) {
+ my $imgpal = colorder($palette, $info->{ansiorder});
+ print "<tr><td colspan=$columns>", img_egapal($imgpal, @{$_});
+ }
+ print "</table>\n\n";