termcol: float text samples in cells
[sheet.git] / termcol.plp
index 0c5d3e4d27819484ea19e4c54a047b2939bfea43..0b3d2364a11ed39824afd06ca979833a12ea0f1f 100644 (file)
@@ -49,7 +49,7 @@ my $palettes = do 'termcol.inc.pl';
 die "Cannot open palette data: $_\n" for $@ || $! || ();
 
 sub colcell {
-       my $name = shift // return "<td colspan=3>\n";
+       my $name = shift // return "<td>\n";
        my $col = Shiar_Sheet::Colour->new(@_);
        my $minhex = $col->rgb24;
        my $css     = '#' . $col->rgb48;
@@ -58,13 +58,14 @@ sub colcell {
        my $sample = [ qw(#000 #FFF) ];
        ($name, $sample) = @$name if ref $name eq 'ARRAY';
 
-       my $out = sprintf('<th title="%s" style="%s">%s',
+       my $out = sprintf('<td title="%s" style="%s">%s',
                join(',', map { int } @$col),
                "background:$css; color:$inverse",
                $name,
        );
-       $out .= sprintf '<td style="%s">%s', "background:$_; color:$css", $minhex
-               for @$sample;
+       $out .= sprintf('<samp style="%s"><small>%s</small></samp>',
+               "background:$_; color:$css", $minhex
+       ) for @$sample;
        return "$out\n";
 }
 
@@ -149,7 +150,7 @@ sub coltable_hsv {
        }
 
        my $out = '';
-       $out .= sprintf '<colgroup span=%d>', 3 * @{$_} for @colmap;
+       $out .= sprintf '<colgroup span=%d>', scalar @{$_} for @colmap;
        my $huerow = $colmap[0][0]; # first {$_} map { @{$_} } @colmap;
        for my $h (grep { $huerow->[$_] } 0 .. $#{$huerow}) {
                $out .= '<tr>';