X-Git-Url: http://git.shiar.nl/sheet.git/blobdiff_plain/d7efdac99433a38f91de80792fc037351798b267..ff84da253ec62aa4a552d8b98aae013b0c7ea5f8:/termcol.plp diff --git a/termcol.plp b/termcol.plp index 9411ba4..44ee75b 100644 --- a/termcol.plp +++ b/termcol.plp @@ -75,18 +75,30 @@ if ($get{v}) { my @termlist = qw( cga xterm tango app html xkcd ); push @termlist, qw( c64 msx2 mac2 risc arnegame ) if exists $get{v}; for my $term (@termlist) { - my ($name, @index) = @{ $palettes->{$term} }; - my $caption = $name // $term; - - print '', "\n"; - printf "\n", $caption; - for my $num (0 .. $#index) { - my ($rgb, $name) = split /:/, $index[$num], 3; - $name ||= $num; - $name = [ $name, ['#333'] ] if $term eq 'xkcd'; - print '', colcell($name, $rgb); + my $info = $palettes->{$term}; + ref $info eq 'HASH' or next; + my $caption = $info->{name} // $term; + $caption = sprintf('<%s %s>%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 $colours = $info->{list}) { + print '
%s
', "\n"; + printf "\n", $caption; + for my $num (0 .. $#{$colours}) { + my ($rgb, $name) = split /:/, $colours->[$num], 3; + $name ||= $num; + $name = [ $name, ['#333'] ] if $term eq 'xkcd'; + print '', colcell($name, $rgb); + } + print "
%s
\n\n"; } - print "\n\n"; } if (exists $get{v}) {