digraphs: option to show xorg digraphs instead
[sheet.git] / digraphs.plp
index ce149628c324a074854e2d7eebacf85341bc6db2..b40eac0915cefd19f0176e4bbed836f7f4da169d 100644 (file)
@@ -23,7 +23,8 @@ Also see <a href="/unicode">common digraphs</a>.</p>
 are available as <a href="/digraphs.vim">ex commands</a>.</p>
 
 <:
-my $di = do 'digraphs.inc.pl';
+my $di = do 'digraphs.inc.pl'
+       or die "Error loading digraphs data: ", $@ // $!;
 
 my @chars = (
        [qw{! " % ' ( ) * + , - . /}],
@@ -35,6 +36,18 @@ my @chars2 = (['_'], @chars);  # trailing character (extended set)
 my @columns = !exists $get{split} ? \@chars2 :
        ([@chars2[0, 1, 3, 4, 6]], [@chars2[2, 5, 7]]);
 
+if (exists $get{xorg}) {
+       my $xorg = do 'data/digraphs-xorg.inc.pl'
+               or die "Error loading Xorg data: ", $@ // $!;
+       $_ = [ord $_] for values %{$xorg};
+       $xorg->{$_}->[2] =  # class = same as rfc | any other spec | xorg only
+               $di->{$_} ? $di->{$_}->[2] =~ /\bu-di\b/ ? 'l5' : 'l3' : 'l1'
+               for keys %{$xorg};
+       $chars2[0] = [qw( # ^ _ ` ~ )];
+       @chars = @chars2;
+       $di = $xorg;
+}
+
 for my $colchars (@columns) {
 print '<table class="glyphs dimap"><col>';
 print qq'<colgroup span="$_">' for map {scalar @$_} @{$colchars};
@@ -66,7 +79,7 @@ for my $c1group (@chars) {
                        my @class = ('X', grep {$_} $prop, $script);
 
                        $glyph = EscapeHTML($glyph);
-                       $glyph = "<span>$glyph</span>" if $prop =~ /\bZs\b/;
+                       $glyph = "<span>$glyph</span>" if $script =~ /\bZs\b/;
 
                        printf "\n".'<td class="%s" title="%s">%s',
                                join(' ', @class), EscapeHTML($desc), $glyph;