unicode: fix for non-digraph digraphs
[sheet.git] / unicode.plp
index dd7de6d2fe3f8f2825b425e1b96d656908599ce8..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';
 
@@ -16,11 +16,16 @@ $header{content_type} = 'text/html; charset=utf-8';
 <head>
 <title>digraph cheat sheet</title>
 <meta http-equiv="content-type" content="utf-8">
-<link rel="stylesheet" type="text/css" media="all" href="/digraphs.css">
-<link rel="vcs" type="git" href="git://dev.shiar.nl/sheet">
+<link rel="stylesheet" type="text/css" media="all" href="/base.css"><:
+       my %styles = map {$_ => $_} qw(dark circus mono red terse);
+       our $style = exists $get{style} && $styles{$get{style}} || 'light';
+       printf(qq{\n<link rel="%s" type="text/css" media="all" href="%s" title="%s">},
+               $_ eq $style ? 'stylesheet' : 'alternate stylesheet', "$_.css", $_
+       ) for keys %styles;
+:>
 </head>
 
-<body>
+<body id="unicode">
 <h1>Common uncommon Unicode</h1>
 
 <p>i^k in <a href="/">Vim</a>.
@@ -76,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;
@@ -93,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
@@ -113,7 +124,7 @@ sub glyph_table {
                        @class ? sprintf(' class="%s"', join ' ', @class) : '',
                        $colspan > 1 && qq{ colspan="$colspan"},
                        $cell eq '' ? '&nbsp;' : 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)
                                        : '',
@@ -270,7 +281,7 @@ print_glyph_tables(
 
 :></div>
 
-<div id="legend">
+<div class="legend">
        <table class="glyphs"><tr>
        <td class="X di-a">ascii
        <td class="X di-d">digraph
@@ -280,16 +291,12 @@ print_glyph_tables(
        </table>
 </div>
 
-<p id="footer">
-       <a href="http://sheet.shiar.nl/unicode">sheet.shiar.nl<strong>/unicode</strong></a>
-       <a href="git://dev.shiar.nl/sheet"><:= "v$VERSION" :></a>
-       created by Shiar •
-       <a title="Licensed under the GNU Affero General Public License, version 3"
-          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]);
-       :>
+<p class="footer">
+       <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>
 </p>
 
 </html>