formatchar: separate anno and style options
authorMischa POSLAWSKY <perl@shiar.org>
Thu, 23 Dec 2010 20:52:24 +0000 (21:52 +0100)
committerMischa POSLAWSKY <perl@shiar.org>
Tue, 11 Jan 2011 22:41:38 +0000 (23:41 +0100)
Split single digraph boolean into distinct configuration for cell annotation
and styling.

Shiar_Sheet/FormatChar.pm
latin.plp
unicode.plp
writing.plp

index 185e0af713889ae2984b3cd531825422a4b37f9a..30aab5ed68d853141c0bd1b844c813eaf34215e6 100644 (file)
@@ -14,7 +14,7 @@ our %di = map { $diinfo->{$_}->[0] => $_ } grep { ref $diinfo->{$_} }
 
 sub new {
        my ($class) = @_;
-       bless { digraph => 1, unicode => 0 }, $class;
+       bless { unicode => 0, anno => 'di', style => 'di' }, $class;
 }
 
 sub glyph_info {
@@ -83,7 +83,7 @@ sub cell {
 
                ($cell, $title, my $class, $mnem) = $self->glyphs_html($input);
 
-               if ($self->{digraph}) {
+               if ($self->{style} = 'di') {
                        if (defined $mnem) {
                                push @class, $class =~ /\bXz\b/ ? ('l2', 'u-prop') # unofficial
                                        : ('l3', 'u-di'); # standard digraph
@@ -112,7 +112,7 @@ sub cell {
                @class ? sprintf(' class="%s"', join ' ', @class) : '',
                $html || '',
                $cell eq '' ? ('&nbsp;', '') : ($cell,
-                       $self->{digraph} && defined $mnem && length $mnem
+                       $self->{anno} eq 'di' && defined $mnem && length $mnem
                        ? sprintf(' <small class="digraph">%s</small>', EscapeHTML($mnem))
                        : $self->{unicode} + $cell =~ /^[^a-zA-Z]$/ > 0
                                ? sprintf(' <small class="%s">%04X</small>', 'value', ord $cell)
@@ -164,7 +164,7 @@ sub table {
        }
 
        return sprintf qq{<table class="glyphs%s">\n%s</table>\n},
-               $self->{digraph} || $self->{unicode} >= 0 ? ' dilabel' : '',
+               $self->{anno} || $self->{unicode} >= 0 ? ' dilabel' : '',
                join '', map {"$_\n"} @rows;
 }
 
index 54846248ce5b0932a548eb4869dc62868e4b8cfe..f91055d7bcbfba28c447371f37e55494977ec09a 100644 (file)
--- a/latin.plp
+++ b/latin.plp
@@ -39,7 +39,8 @@ use Shiar_Sheet::FormatChar;
 my $glyphs = Shiar_Sheet::FormatChar->new;
 unless (exists $get{v}) {
        $glyphs->{unicode}--;
-       $glyphs->{digraph}--;
+       $glyphs->{anno}  = 0;
+       $glyphs->{style} = 0;
 }
 
 my %scriptname = (
index d7e5e01544596da7675b0c9cdbdb766736be03fe..5b3093d05c781db29e05d3c0219cb4ea90a1fac3 100644 (file)
@@ -31,12 +31,12 @@ use Shiar_Sheet::FormatChar;
 my $glyphs = Shiar_Sheet::FormatChar->new;
 
 if (exists $get{di}) {
-       $glyphs->{digraph} = defined $get{di} ? ! !$get{di} : 1;
+       $glyphs->{anno} = (!defined $get{di} || $get{di}) && 'di';
        $glyphs->{unicode} = 1;
 }
 if (exists $get{q}) {
        $glyphs->{unicode} = -1;
-       $glyphs->{digraph}--;
+       $glyphs->{anno} = 0;
 }
 
 our $verbose = exists $get{v};
@@ -136,8 +136,8 @@ $glyphs->print(map {
 <div class="legend">
        <table class="glyphs"><tr>
        <td class="X l4">ascii
-       <td class="X l3"><:= $glyphs->{digraph} ? 'digraph' : 'latin1' :>
-       <td class="X l2"><:= $glyphs->{digraph} ? 'proposed' : 'BMP' :>
+       <td class="X l3"><:= $glyphs->{style} eq 'di' ? 'digraph' : 'latin1' :>
+       <td class="X l2"><:= $glyphs->{style} eq 'di' ? 'proposed' : 'BMP' :>
        <td class="X l1">other unicode
        <td class="X ex">discouraged
        </table>
index eab00514088e689124b252f780948ed917c8028d..86654e2ca3f352f7325317655140dc2e33809f43 100644 (file)
@@ -29,7 +29,8 @@ use Shiar_Sheet::FormatChar;
 my $glyphs = Shiar_Sheet::FormatChar->new;
 unless (exists $get{v}) {
        $glyphs->{unicode}--;
-       $glyphs->{digraph}--;
+       $glyphs->{anno}  = 0;
+       $glyphs->{style} = 0;
 }
 
 my $scriptname = do 'writing-script.inc.pl';