termcol: move generated xcolors include to data/
[sheet.git] / Shiar_Sheet / FormatChar.pm
index 839144fb5e2328581ccd5e97f4a8c50d4aaaa5b2..c0a4cb0b6032ddf36bd181a0d78a85f8f6c7d1cb 100644 (file)
@@ -136,7 +136,7 @@ sub cell {
                if ($input =~ /[ -~]/) {
                        push @class, 'l5', 'u-ascii'; # ascii
                }
-               elsif ($input =~ /^\p{in=6.0}+$/) {
+               elsif ($input =~ /^\p{in=6.0}+$/ and $input !~ /\p{Co}/) {
                        push @class, 'l2'; # in unicode 6.0
                }
                else {
@@ -173,8 +173,8 @@ sub cell {
                                }
                        }
                        else {
-                               if ($_ eq 'hex' or $cell =~ /^[^a-zA-Z]$/) {
-                                       $anno = sprintf(' <small class="%s">%04X</small>', 'value', ord $cell);
+                               if ($_ eq 'hex' or $input =~ /^[^a-zA-Z]$/) {
+                                       $anno = sprintf(' <small class="%s">%04X</small>', 'value', ord $input);
                                        last;
                                }
                        }
@@ -248,10 +248,16 @@ sub table {
        my @colheads;
        while ($digraphs->[0] !~ /^\./) {
                my $cell = shift @$digraphs or last;
-               push @colheads, sprintf(
-                       '<%s%s>%s',
+               if ($cell eq '>') {
+                       push @colheads, '<tr>';
+                       next;
+               }
+               push @colheads, join('',
+                       '<',
                        $cell =~ s/^-// ? 'td' : 'th',
-                       $cell =~ s/:(.*)// ? qq{ title="$1"} : '',
+                       $cell =~ s/:(.*)// && qq{ title="$1"},
+                       $cell =~ s/^(>+)// && ' colspan='.(length($1) + 1),
+                       '>',
                        $cell eq '_' ? '&nbsp;' : $cell
                );
        }
@@ -275,13 +281,21 @@ sub print {
 }
 
 sub legend {
-       my @classes = (
+       my $self = shift;
+       my @classes = $self->{style} eq 'univer' ? (
                [l5 => 'unicode 1.1'],
                [l4 => '20th century'],
                [l3 => 'in 6.0 (2010)'],
                [l2 => 'recent assignments'],
                [l1 => 'proposed'],
                [ex => 'irregular'],
+       ) : (
+               [l5 => 'ascii'],
+               [l4 => $self->{style} eq 'di' ? 'digraph' : 'latin1'],
+               [l3 => $self->{style} eq 'di' ? 'proposed' : 'HTML4'],
+               [l2 => 'unicode ≤6.0'],
+               [l1 => 'other unicode'],
+               [ex => 'discouraged'],
        );
 
        return (