charset: no .X on empty glyph cells
[sheet.git] / Shiar_Sheet / FormatChar.pm
index 834b71bc03405f32198a348af6a9995f71d20738..ef0445d01d968f127be31ebc2f821affb0fed564 100644 (file)
@@ -8,7 +8,7 @@ use utf8;
 use Data::Dump 'pp';
 use PLP::Functions 'EscapeHTML';
 
-our $VERSION = '1.06';
+our $VERSION = '1.07';
 
 our $uc = do 'unicode-char.inc.pl';
 
@@ -31,15 +31,15 @@ sub glyph_html {
        my ($self, $char) = @_;
        my $codepoint = ord $char;
        my $info = $self->glyph_info($codepoint);
-       my ($class, $name, $mnem, $html, $string) = @$info;
+       my ($class, $name, $mnem, $entity, $string) = @$info;
 
        my $cell = EscapeHTML($string || $char);
-       my $title = sprintf 'U+%04X%s', $codepoint, $name && " ($name)";
+       my $title = sprintf 'U+%04X%s', $codepoint, !!$name && " ($name)";
 
-       $cell = "<span>$cell</span>" if $class =~ /\bZs\b/;
+       $cell = "<span>$cell</span>" if $class and $class =~ /\bZs\b/;
        $cell = '&nbsp;' if $cell eq '';
 
-       return ($cell, EscapeHTML($title), "X $class", $mnem, $html);
+       return ($cell, EscapeHTML($title), !!$class && "X $class", $mnem, $entity);
 }
 
 sub glyphs_html {
@@ -109,7 +109,7 @@ sub cell {
                }
 
                if ($self->{style} eq 'di') {
-                       if ($mnem =~ /…/) {
+                       if ($mnem and $mnem =~ /…/) {
                                # incomplete representation, usually partial
                        }
                        elsif ($class =~ /\bu-di\b/) {
@@ -231,6 +231,10 @@ sub table {
                        $rows[-1] .= '<th>';
                        next;
                }
+               elsif ($cell =~ m/^</) {
+                       $rows[-1] .= '<td>'.$cell;
+                       next;
+               }
 
                $rows[-1] .= $self->cell($cell,
                        $colspan > 1 && qq{colspan="$colspan"},