unicode: fix for non-digraph digraphs
[sheet.git] / unicode.plp
index 25f89de638afb27cdbe212c52b7cea65eb9e5d63..bcfebd1adb3cac2d75aadbc12b9e4a93fae06229 100644 (file)
@@ -5,7 +5,7 @@ use warnings;
 no  warnings 'qw';  # that's not a comment, it's a NUMBER SIGN
 use open IO => ':utf8';
 
-our $VERSION = '1.0';
+our $VERSION = 'v1.0';
 
 $header{content_type} = 'text/html; charset=utf-8';
 
@@ -81,8 +81,7 @@ sub glyph_table {
                        next;
                }
 
-               my $code = join '', map { $di{ord $_} || '' } split //, $cell;
-               my $name = $diinfo->{$code}->[1];
+               my ($code, $name);
 
                # determine display class
                my @class;
@@ -98,11 +97,18 @@ sub glyph_table {
                                push @class, 'di-rare'; # discouraged
                        }
 
-                       if ($code) {
+                       $code = join '', map { $di{ord $_} || '' } split //, $cell;
+                       $name = $diinfo->{$code}->[1];
+                       length $code == 2 or undef $code;
+
+                       if (defined $code) {
                                push @class, 'di-d'; # digraph
                                push @class, 'di-prop' # unofficial
                                        if $diinfo->{$code}->[2] =~ /\bXz\b/;
                        }
+                       elsif (defined $name) {
+                               push @class, 'X';
+                       }
 
                        if ($cell =~ /[ -~]/) {
                                push @class, 'di-a'; # ascii
@@ -118,7 +124,7 @@ sub glyph_table {
                        @class ? sprintf(' class="%s"', join ' ', @class) : '',
                        $colspan > 1 && qq{ colspan="$colspan"},
                        $cell eq '' ? ' ' : quote($cell),
-                       $code ne '' ? sprintf(' <small class="digraph">%s</small>', quote($code))
+                       defined $code ? sprintf(' <small class="digraph">%s</small>', quote($code))
                                : length($cell) == 1 && $cell !~ /[a-z]/
                                        ? sprintf(' <small class="%s">%04X</small>', 'value', ord $cell)
                                        : '',
@@ -286,15 +292,11 @@ print_glyph_tables(
 </div>
 
 <p class="footer">
-       <a href="http://sheet.shiar.nl/" rel="home">sheet.shiar.nl</a>/unicode
-       <a href="git://dev.shiar.nl/sheet" rel="vcs-git" title="Git repository"><:= "v$VERSION" :></a>
+       <a href="/" rel="home">sheet.shiar.nl</a>/unicode
+       <a href="git://git.shiar.nl/sheet" rel="vcs-git" title="Git repository"><:= $VERSION :></a>
        created by <a href="http://shiar.nl/" rel="author">Shiar</a> •
        <a title="Licensed under the GNU Affero General Public License, version 3" rel="copyright"
-          href="http://www.fsf.org/licensing/licenses/agpl-3.0.html">AGPLv3</a> •
-       last update <:
-               use Time::Format qw(time_format);
-               print time_format('yyyy-mm-dd', (stat $ENV{SCRIPT_FILENAME})[9]);
-       :>
+          href="http://www.fsf.org/licensing/licenses/agpl-3.0.html">AGPLv3</a>
 </p>
 
 </html>