termcol: omit table tags from coltable_hsv() output
[sheet.git] / termcol.plp
index 60afba6d564e5dac1829d8f3bcfa88795eceed70..e34ceada9d45204cf9af827be33092b71fe5f069 100644 (file)
@@ -32,7 +32,7 @@ use Shiar_Sheet::Colour '1.03';
 use List::Util qw( min max );
 
 sub colcell {
-       my $name = shift or return "<td colspan=3>\n";
+       my $name = shift // return "<td colspan=3>\n";
        my $col = Shiar_Sheet::Colour->new(@_);
        my $minhex = $col->rgb24;
        my $css     = '#' . $col->rgb48;
@@ -226,19 +226,6 @@ for my $term (@termlist) {
 <hr>
 
 <div class="section">
-<h2>88-colour space</h2>
-<:
-print coltable_hsv(4,
-       sub {(0, 139, 205, 255)[$_[0]]},
-       [map { ($_ + 2 + ($_>0)) * 255/11 } 0 .. 7],
-);
-
-:></div>
-<: if ($ENV{PATH_INFO} =~ /256/) { :>
-<hr>
-
-<div class="section">
-<h2>256-colour space</h2>
 <:
 sub coltable_hsv {
        my ($dim, $rgbval, $greyramp) = @_;
@@ -274,7 +261,7 @@ sub coltable_hsv {
                }
        }
 
-       my $out = '<table class=mapped>';
+       my $out = '';
        $out .= sprintf '<colgroup span=%d>', 3 * @{$_} for @colmap;
        my $huerow = $colmap[0][0]; # first {$_} map { @{$_} } @colmap;
        for my $h (grep { $huerow->[$_] } 0 .. $#{$huerow}) {
@@ -292,16 +279,29 @@ sub coltable_hsv {
                $out .= '<tr>' unless $col++ % $colbreak;
                $out .= colcell($num, ($greymap{$num}) x 3);
        }
-       $out .= "</table>\n\n";
 
        return $out;
 }
 
-print coltable_hsv(6,
-       sub { $_[0] && $_[0]*40 + 55 },
-       [ map { $_ * 10 + 8 } 0 .. 23 ],
-);
+{
+       print "<h2>88-colour space</h2>\n";
+       print "<table class=mapped>\n";
+       print coltable_hsv(4,
+               sub {(0, 139, 205, 255)[$_[0]]},
+               [map { ($_ + 2 + ($_>0)) * 255/11 } 0 .. 7],
+       );
+       print "</table>\n";
+}
+
+if ($ENV{PATH_INFO} =~ /256/) {
+       print "<h2>256-colour space</h2>\n";
+       print "<table class=mapped>\n";
+       print coltable_hsv(6,
+               sub { $_[0] && $_[0]*40 + 55 },
+               [ map { $_ * 10 + 8 } 0 .. 23 ],
+       );
+       print "</table>\n";
+}
 :></div>
-<: } :>
 <hr>