apl: group similar operators into distinct table bodies
[sheet.git] / apl.plp
1 <(common.inc.plp)><:
2
3 Html({
4         title => 'APL',
5         version => 'v1.0',
6         description => [
7         ],
8         keywords => [qw'
9         '],
10         stylesheet => [qw'light circus dark red'],
11         data => [qw'apl.inc.pl'],
12 });
13
14 use Shiar_Sheet::FormatChar;
15 my $glyphs = Shiar_Sheet::FormatChar->new;
16
17 my @ops = do 'apl.inc.pl';
18 @ops > 1 or die "cannot open operator include: $@\n";
19
20 :>
21 <h1>APL Symbols</h1>
22
23 <div class="section">
24 <table class="mapped">
25         <col><colgroup span=3><colgroup span=2>
26 <thead><tr>
27         <td rowspan=2>op
28         <td colspan=3>input
29         <td colspan=2>meaning
30 <tr>
31         <td title="unified/Dyalog key combination">⎈
32         <td><a href="/digraphs" title="digraph">di</a><td>html
33         <td title="…B">monadic
34         <td title="A…B">dyadic
35 <tbody>
36
37 <:
38 for my $op (@ops) {
39         $op or do {
40                 print "<tbody>\n";
41                 next;
42         };
43
44         my ($chr, $dyad, $monad) = @{$op};
45         ($chr, my $altkey) = split /\n/, $chr;
46         my $codepoint = ord $chr;
47         my $ascii = $codepoint <= 127;
48         my $info = $glyphs->glyph_info($codepoint);
49         my ($class, $name, $mnem, $html, $string) = @{$info};
50
51         printf '<tr><th title="%2$s">%s', $chr, EscapeHTML($name || '?'), $class;
52         printf '<td class="%s">%s', @{$_} for (
53                 [$ascii ? 'l5' : defined $altkey ? 'l4' : 'l3', $altkey],
54                 [defined $mnem ? $class =~ /\bu-di\b/ ? 'l4' : 'l3' : $ascii ? 'l5' : 'l1',
55                         EscapeHTML($mnem) // sprintf('%s%0*X', $codepoint < 256 ? (x => 2) : (u => 4), $codepoint)],
56                 [defined $html ? 'l4' : $ascii ? 'l5' : 'l1', $html // "#$codepoint"],
57         );
58         printf(
59                 defined $_ ? '<td%s>%s' : '<td class=Xi>',
60                 map { !!$_->[1] && qq( title="$_->[1]"), $_->[0] }
61                 [map { EscapeHTML($_) } split /\n/, $_, 2]
62         ) for $monad, $dyad;
63         print "\n";
64 }
65
66 :></table>
67 </div>
68
69 <hr>
70
71 <div class="legend">
72         <table class="glyphs"><tr>
73         <td class="X l5">unicode 1.1
74         <td class="X l4">20th century
75         <td class="X l3">in 6.0 (2010)
76         <td class="X l2">recent assignments
77         <td class="X l1">proposed
78         <td class="ex">irregular
79         </table>
80 </div>
81