digraphs: mkdigraphlist: avoid undefinedness warnings
[sheet.git] / digraphs.plp
1 <(common.inc.plp)><:
2
3 Html({
4         title => 'digraph cheat sheet',
5         version => 'v1.0',
6         description => [
7                 "Complete table of digraph characters from RFC-1345.",
8         ],
9         keywords => [qw'
10                 digraph compose character char glyph table unicode vim
11         '],
12         stylesheet => [qw'light'],
13         data => [qw( digraphs.inc.pl )],
14 });
15
16 :>
17 <h1>RFC-1345 Digraphs</h1>
18
19 <p>i^k in <a href="/vi">Vim</a>.
20 Also see <a href="/unicode">common digraphs</a>.</p>
21
22 <p class="aside">Unofficial <span class="u-prop ex">proposals</span>
23 are available as <a href="/digraphs.vim">ex commands</a>.</p>
24
25 <:
26 my $di = do 'digraphs.inc.pl'
27         or die "Error loading digraphs data: ", $@ // $!;
28
29 my @chars = (
30         [qw{! " % ' ( ) * + , - . /}],
31         ['0'..'9'], [qw{: ; < = > ?}],
32         ['A'..'M'], ['N'..'Z'],
33         ['a'..'m'], ['n'..'z'],
34 );
35 my @chars2 = (['_'], @chars);  # trailing character (extended set)
36 my @columns = !exists $get{split} ? \@chars2 :
37         ([@chars2[0, 1, 3, 4, 6]], [@chars2[2, 5, 7]]);
38
39 for my $colchars (@columns) {
40 print '<table class="glyphs dimap"><col>';
41 print qq'<colgroup span="$_">' for map {scalar @$_} @{$colchars};
42 print "</colgroup><col>\n";
43 for my $section (qw{thead tfoot}) {
44         print "<$section><tr><th>↳";
45         print '<th>', EscapeHTML($_) for map {@$_} @{$colchars};
46         print "<th>&nbsp;\n";
47 }
48 for my $c1group (@chars) {
49         print '<tbody>';
50         for my $c1 (@$c1group) {
51                 print '<tr><th>', EscapeHTML($c1);
52                 for my $c2 (map {@$_} @$colchars) {
53                         my $mnem = $c1 . $c2;
54                         if (not defined $di->{$mnem}) {
55                                 print '<td>';
56                                 next;
57                         }
58                         if (ref $di->{$mnem} ne 'ARRAY') {
59                                 printf '<td class="X Xr" title="%s">', EscapeHTML($mnem);
60                                 next;
61                         }
62                         my ($codepoint, $name, $prop, $script, $string) = @{ $di->{$mnem} };
63
64                         my $glyph = $string || chr $codepoint;
65                         utf8::upgrade($glyph);  # prevent latin1 output
66                         my $desc = $mnem . ($name && " ($name)");
67                         my @class = ('X', grep {$_} $prop, $script);
68
69                         $glyph = EscapeHTML($glyph);
70                         $glyph = "<span>$glyph</span>" if $script =~ /\bZs\b/;
71
72                         printf "\n".'<td class="%s" title="%s">%s',
73                                 join(' ', @class), EscapeHTML($desc), $glyph;
74                 }
75                 print "\n<th>", EscapeHTML($c1), "\n";
76         }
77 }
78 print "</table>\n";
79 print '<hr>' if exists $get{split};
80 }
81 :>
82 <div class="legend">
83         <table class="glyphs"><tr>
84         <td class="X Cc">control
85         <td class="X Zs"><span>space</span>
86         <td class="X Mn">combining
87         <td class="X Sk">spacing&nbsp;modifier
88         <td class="X Pf">quote
89         <td class="X Po">punctuation
90         <td class="X So">symbol
91         <td class="X Sm">math
92         <td class="X Sc">currency
93         <td class="X No">numeric
94         <td class="X Greek">greek
95         <td class="X Cyrillic">cyrillic
96         <td class="X Latin">latin
97         <td class="X Hebrew">hebrew
98         <td class="X Arabic">arabic
99         <td class="X Hangul">korean
100         <td class="X Hiragana">japanese
101         <td class="X Bopomofo">chinese
102         </table>
103
104         <table class="glyphs"><tr>
105         <td class="X">unicode
106         <td class="X Xl">latin1
107         <td class="X Xa">ascii
108         <td class="X u-prop">vim extension
109         <td class="X u-prop ex">proposal
110         <td class="X ex">not in vim
111         </table>
112 </div>
113