termcol: avoid plp code breaks for hsv tables
[sheet.git] / termcol.plp
index fd2bc9bf0107d36fd2f5c3ff21ef6c3a967c39b3..9262bf35c64a090ccf9e1c8b32c70540060c9893 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) = @_;
@@ -281,14 +268,13 @@ sub coltable_hsv {
                $out .= '<tr>';
                $out .= colcell(@$_) for map { $_->[$h] } map { @{$_} } @colmap;
        }
-       $out .= "</table>\n\n";
 
        $offset += $dim ** 3;
        $greymap{$offset++} = $_ for @{$greyramp};
 
-       $out .= '<table>';
+       $out .= '<tbody>';
        my $col = 0;
-       my $colbreak = keys(%greymap) / 2;  # split into 2 rows
+       my $colbreak = scalar map { @$_ } @colmap;  # same width as hue rows
        for my $num (sort { $greymap{$a} <=> $greymap{$b} } keys %greymap) {
                $out .= '<tr>' unless $col++ % $colbreak;
                $out .= colcell($num, ($greymap{$num}) x 3);
@@ -298,11 +284,21 @@ sub coltable_hsv {
        return $out;
 }
 
-print coltable_hsv(6,
-       sub { $_[0] && $_[0]*40 + 55 },
-       [ map { $_ * 10 + 8 } 0 .. 23 ],
-);
+{
+       print "<h2>88-colour space</h2>\n";
+       print coltable_hsv(4,
+               sub {(0, 139, 205, 255)[$_[0]]},
+               [map { ($_ + 2 + ($_>0)) * 255/11 } 0 .. 7],
+       );
+}
+
+if ($ENV{PATH_INFO} =~ /256/) {
+       print "<h2>256-colour space</h2>\n";
+       print coltable_hsv(6,
+               sub { $_[0] && $_[0]*40 + 55 },
+               [ map { $_ * 10 + 8 } 0 .. 23 ],
+       );
+}
 :></div>
-<: } :>
 <hr>