writing: highlight cells according to unicode version
authorMischa POSLAWSKY <perl@shiar.org>
Wed, 11 Feb 2015 22:01:46 +0000 (23:01 +0100)
committerMischa POSLAWSKY <perl@shiar.org>
Fri, 13 Feb 2015 16:46:33 +0000 (17:46 +0100)
Shiar_Sheet/FormatChar.pm
digits.plp
writing.plp

index a3f4cc9c3725bdee642fecceb91ae5b79c1b29ca..6b5fb6c175829c64241f82e0d094549188a7b6f7 100644 (file)
@@ -1,5 +1,6 @@
 package Shiar_Sheet::FormatChar;
 
+use 5.010;
 use strict;
 use warnings;
 
@@ -70,7 +71,7 @@ sub cell {
                push @class, 'u-invalid';
                $cell = '';
        }
-       else {
+       else {{
                push @class, 'X';
 
                if ($input =~ s/^-//) {
@@ -80,6 +81,30 @@ sub cell {
                $input =~ s/^\\//;  # escaped char
                ($cell, $title, my $class, $mnem, $entity) = $self->glyphs_html($input);
 
+               if ($self->{style} eq 'univer') {
+                       state $agemap = do 'unicode-age.inc.pl' or die $!;
+                       my $version = $agemap->{ord $input};
+                       if (!$version) {
+                               push @class, 'l1';  # no known unicode assignment
+                       }
+                       elsif ($version < 20) {
+                               push @class, 'l5';  # first release 1993
+                       }
+                       elsif ($version < 31) {
+                               push @class, 'l4';  # 20th century
+                       }
+                       elsif ($version < 50) {
+                               push @class, 'l4';  # over 10 years ago
+                       }
+                       elsif ($version < 61) {
+                               push @class, 'l3';  # before 2012
+                       }
+                       else {
+                               push @class, 'l2';  # more recent
+                       }
+                       next;
+               }
+
                if ($self->{style} eq 'di') {
                        if ($class =~ /\bu-di\b/) {
                                push @class, ('l3', 'u-di'); # standard digraph
@@ -109,7 +134,7 @@ sub cell {
                else {
                        push @class, 'l1'; # basic unicode
                }
-       }
+       }}
 
        my $anno = '';
        if ($cell ne '') {
index f688d054104071ac5d4d817215e2de8862d7acf8..10311511b73a1c71b6aff83a003b939728ac20e1 100644 (file)
@@ -29,7 +29,7 @@ my $glyphs = Shiar_Sheet::FormatChar->new;
 unless (exists $get{v}) {
        $glyphs->{unicode}--;
        $glyphs->{anno}  = [];
-       $glyphs->{style} = 0;
+       $glyphs->{style} = 'univer';
 }
 
 my $scriptname = do 'writing-script.inc.pl';
index c430bbd7ae62b618776721addca64ac0a36ad167..8ea9a0c970c7442aba681d895ff1dcb8ebcb8821 100644 (file)
@@ -32,7 +32,7 @@ my $glyphs = Shiar_Sheet::FormatChar->new;
 unless (exists $get{v}) {
        $glyphs->{unicode}--;
        $glyphs->{anno}  = [];
-       $glyphs->{style} = 0;
+       $glyphs->{style} = 'univer';
 }
 
 my $scriptname = do 'writing-script.inc.pl';
@@ -60,3 +60,14 @@ for (
 
 <hr>
 
+<div class="legend">
+       <table class="glyphs"><tr>
+       <td class="X l5">unicode 1.1
+       <td class="X l4">20th century
+       <td class="X l3">in 6.0 (2010)
+       <td class="X l2">recent assignments
+       <td class="X l1">proposed
+       <td class="ex">irregular
+       </table>
+</div>
+