keyboard: fix empty key titles
[sheet.git] / Shiar_Sheet / FormatChar.pm
index b2e4d09cbf22b044434a84b2e63b2a709b714efc..c93a48a708fbff4eccddabfc0bd2a3102759d207 100644 (file)
@@ -10,7 +10,7 @@ use PLP::Functions 'EscapeHTML';
 
 our $VERSION = '1.08';
 
-our $uc = do 'unicode-char.inc.pl';
+our $uc = do 'data/unicode-char.inc.pl';
 
 sub new {
        my ($class) = @_;
@@ -86,7 +86,7 @@ sub cell {
                if ($self->{style} eq 'univer') {
                        if ($input =~ /\p{age=unassigned}/) {
                                # check include for assignments after unicode 6.0 (perl v5.14)
-                               state $agemap = do 'unicode-age.inc.pl';
+                               state $agemap = do 'data/unicode-age.inc.pl';
                                my $version = $agemap->{$codepoint};
                                push @class, $version ? 'l2' : 'l1';
                        }
@@ -136,7 +136,7 @@ sub cell {
                if ($input =~ /[ -~]/) {
                        push @class, 'l5', 'u-ascii'; # ascii
                }
-               elsif ($input =~ /^\p{in=6.0}+$/) {
+               elsif ($input =~ /^\p{in=6.0}+$/ and $input !~ /\p{Co}/) {
                        push @class, 'l2'; # in unicode 6.0
                }
                else {
@@ -173,8 +173,8 @@ sub cell {
                                }
                        }
                        else {
-                               if ($_ eq 'hex' or $cell =~ /^[^a-zA-Z]$/) {
-                                       $anno = sprintf(' <small class="%s">%04X</small>', 'value', ord $cell);
+                               if ($_ eq 'hex' or $input =~ /^[^a-zA-Z]$/) {
+                                       $anno = sprintf(' <small class="%s">%04X</small>', 'value', ord $input);
                                        last;
                                }
                        }
@@ -248,10 +248,16 @@ sub table {
        my @colheads;
        while ($digraphs->[0] !~ /^\./) {
                my $cell = shift @$digraphs or last;
-               push @colheads, sprintf(
-                       '<%s%s>%s',
+               if ($cell eq '>') {
+                       push @colheads, '<tr>';
+                       next;
+               }
+               push @colheads, join('',
+                       '<',
                        $cell =~ s/^-// ? 'td' : 'th',
-                       $cell =~ s/:(.*)// ? qq{ title="$1"} : '',
+                       $cell =~ s/:(.*)// && qq{ title="$1"},
+                       $cell =~ s/^(>+)// && ' colspan='.(length($1) + 1),
+                       '>',
                        $cell eq '_' ? '&nbsp;' : $cell
                );
        }