- my ($name, @index) = @{ $palettes->{$term} };
- my $caption = $name // $term;
-
- print '<table>', "\n";
- printf "<caption>%s</caption>\n", $caption;
- for my $num (0 .. $#index) {
- my ($rgb, $name) = split /:/, $index[$num], 3;
- $name ||= $num;
- $name = [ $name, ['#333'] ] if $term eq 'xkcd';
- print '<tr>', colcell($name, $rgb);
+ 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="mapped">'."\n";
+ printf "<caption>%s</caption>\n", $caption;
+ print coltable_hsv(@{$mapinfo});
+ print "</table>\n\n";