unicode: table improvements
[sheet.git] / unicode.plp
1 <:
2 use utf8;
3 use strict;
4 use warnings;
5 use open IO => ':utf8';
6
7 our $VERSION = '1.0';
8
9 $header{content_type} = 'text/html; charset=utf-8';
10
11 :><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
12  "http://www.w3.org/TR/html4/loose.dtd">
13 <html>
14
15 <head>
16 <title>digraph cheat sheet</title>
17 <meta http-equiv="content-type" content="utf-8">
18 <link rel="stylesheet" type="text/css" media="all" href="/digraphs.css">
19 <style>
20 table {
21         margin: 1ex 1ex 2ex;
22         float: left;
23         table-layout: auto;
24 }
25 thead td {
26         width: auto;
27 }
28 tbody {
29         border-width: 0;
30 }
31 h2, h3 {
32         clear: both;
33 }
34
35 th {
36         text-align: left;
37         font-size: 50%;
38         background: #888;
39         color: #FFF;
40         padding: 0 0.2em;
41 }
42 thead td {
43         border: 0;
44 }
45
46 td {
47         background: transparent;
48         vertical-align: top;
49         margin: 0;
50         padding: 0;
51         width: 1.6em;
52 }
53 small {
54         font-size: 50%;
55         display: block;
56 }
57 small.digraph {
58         background: #888;
59         color: #FFF;
60 }
61 small.value {
62         background: #CCC;
63         color: #666;
64 }
65
66 td.empty {
67         background: #DDD;
68 }
69 td.reserved {
70         background: #BBB;
71 }
72 </style>
73 </head>
74
75 <body>
76 <h1>Common Digraphs</h1>
77
78 <p>i^k in <a href="/">Vim</a>.
79 Also see the <a href="/digraphs">complete digraphs table</a>.</p>
80
81 <:
82 my $diinfo = do 'digraphs.inc.pl';
83 my %di = map { $diinfo->{$_}->[0] => $_ } grep { ref $diinfo->{$_} }
84         keys %$diinfo;
85
86 sub quote {
87         local $_ = shift;
88         s/"/&quot;/g;
89         s/</&lt;/g;
90         s/>/&gt;/g;
91         return $_;
92 }
93
94 sub table {
95         my ($width, $digraphs, $rowheads, $colheads) = @_;
96
97         my @rows;
98
99         my $colspan = 1;
100         for my $cell (@$digraphs) {
101                 my $class;
102                 if ($cell eq '.') {
103                         push @rows, '';
104                         $rows[-1] .= '<th>'.(shift @$rowheads || '&nbsp;') if $rowheads;
105                         next;
106                 }
107                 elsif ($cell eq '>') {
108                         $colspan++;
109                         next;
110                 }
111                 elsif ($cell =~ s/^-//) {
112                         $class = 'empty';
113                 }
114                 elsif ($cell eq '=') {
115                         $class = 'reserved';
116                         $cell = '';
117                 }
118
119                 my $code = join '', map { $di{ord $_} || '' } split //, $cell;
120                 my $name = $diinfo->{$code}->[1];
121
122                 $rows[-1] .= sprintf('<td%s%s%s>%s%s',
123                         defined $name  ? qq{ title="$name"}  : '',
124                         defined $class ? qq{ class="$class"} : '',
125                         $colspan > 1 && qq{ colspan="$colspan"},
126                         $cell eq '' ? '&nbsp;' : quote($cell),
127                         $code ne '' ? sprintf(' <small class="digraph">%s</small>', quote($code))
128                                 : length($cell) == 1 && $cell !~ /[a-z]/
129                                         ? sprintf(' <small class="%s">%04X</small>', 'value', ord $cell)
130                                         : '',
131                 );
132
133                 $colspan = 1;
134         }
135
136         if ($colheads) {
137                 unshift @rows, sprintf '<thead><tr><td>%s<tbody>', join '',
138                         map { sprintf '<th title="%2$s">%s', split(/:/, $_, 2) }
139                         @$colheads
140         }
141
142         return sprintf "<table>\n%s</table>\n", join '', map {"<tr>$_\n"} @rows;
143 }
144
145 print "<h2>Arrows</h2>\n\n";
146 print table(@$_) for (
147         [ 4 => [qw{. ↖ ↑ ↗ ↔ . ← - → ↕ . ↙ ↓ ↘ -}]],
148         [ 4 => [qw{. ⇖ ⇑ ⇗ ⇔ . ⇐ - ⇒ ⇕ . ⇘ ⇓ ⇙ -}]],
149         [ 3 => [qw{. ◤ ▲ ◥ . ◀ ◆ ▶ . ◣ ▼ ◢}]],
150         [ 3 => [qw{. ◸ △ ◹ . ◁ ◇ ▷ . ◺ ▽ ◿}]],
151 );
152
153 print "<h2>Line drawing</h2>\n\n";
154 print table(@$_) for (
155         [ 4 => [qw{. ┌ ┬ ┐ ─ . ├ ┼ ┤ │ . └ ┴ ┘ -}]],
156         [ 4 => [qw{. ┏ ┳ ┓ ━ . ┣ ╋ ┫ ┃ . ┗ ┻ ┛ -}]],
157         [ 3 => [qw{. ┍ ┯ ┑ . ┝ ┿ ┥ . ┕ ┷ ┙}]],
158         [ 3 => [qw{. ┎ ┰ ┒ . ┠ ╂ ┨ . ┖ ┸ ┚}]],
159 #       [ 4 => [qw{. ╔ ╦ ╗ ═ . ╠ ╬ ╣ ║ . ╚ ╩ ╝ -}]],
160 #       [ 3 => [qw{. ╒ ╤ ╕ . ╞ ╪ ╡ . ╘ ╧ ╛}]],
161 #       [ 3 => [qw{. ╓ ╥ ╖ . ╟ ╫ ╢ . ╙ ╨ ╜}]],
162 );
163
164 print "<h2>Signs</h2>\n\n";
165 print table(@$_) for (
166         [ 3 => [qw{. ▘ ▀ ▝ . ▌ █ ▐ . ▖ ▄ ▗ . ░ ▒ ▓}]],
167         [ 3 => [qw{. □ ▣ ■ . ▤ ▦ ▥ . ▧ ▩ ▨}]],
168         [ 4 => [qw{. ♠ ♡ ♢ ♣ . ♤ ♥ ♦ ♧}]],
169         [ 5 => [qw{. ☼ ☿ ♀ ♁ ♂ ♃ ♄ ♅ ♆ ♇}]],  # solar
170 #       [12 => [qw{. ♈ ♉ ♊ ♋ ♌ ♍ ♎ ♏ ♐ ♑ ♒ ♓}]],  # zodiac
171         [ 8 => [qw{. ¤ ¢ ₥ € £ ₨ $ ¥ . ₫ ₭ ₦ ₱ ₧ ₮ ₩ ₪}]],
172 );
173
174 print "<h2>IPA</h2>\n\n";
175 print table(@$_) for (
176         [
177                 12 => [qw{
178                         . p  p̪  >  >  t  ʈ  c  k  q  =  ʡ  ʔ
179                         . b  b̪  >  >  d  ɖ  ɟ  ɡ  ɢ  =  -  =
180                         . m  ɱ  >  >  n  ɳ  ɲ  ŋ  ɴ  =  =  =
181                         . ʙ  -  >  >  r  -  -  =  ʀ  =  -я =
182                         . -  ⱱ  >  >  ɾ  ɽ  -  =  ɢ̆  =  -  =
183                         . ɸ  f  θ  s  ʃ  ʂ  ç  x  χ  ħ  ʜ  h
184                         . β  v  ð  z  ʒ  ʐ  ʝ  ɣ  ʁ  ʕ  ʢ  ɦ
185                         . =  =  >  >  ɬ  -  -  -  -  =  =  =
186                         . =  =  >  >  ɮ  -  -  -  -  =  =  =
187                         . -  ʋ  >  >  ɹ  ɻ  j  ɰ  -  -  -  =
188                         . =  =  >  >  l  ɭ  ʎ  ʟ  -  =  =  =
189                         . ʘ  -  ǀ  ǁ  ǃ  -‼ ǂ  -  -  =  =  =
190                         . ɓ  ɗ̪  >  >  ɗ  -ᶑ ʄ  ɠ  ʛ  =  =  =
191                 }],
192                 [
193                         'Plosive',
194                         'Voiced plosive',
195                         'Nasal',
196                         'Trill',
197                         'Tap/flap',
198                         'Fricative',
199                         'Voiced fricative',
200                         'Lateral fricative',
201                         'Voiced lateral fricative',
202                         'Approximant',
203                         'Lateral approximant',
204                         'Click',
205                         'Implosive',
206                 ],
207                 [
208                         qw'BiL:Bilabial LD:Labiodental D:Dental Alv:Alveolar PA:Postalveolar Rf:Retroflex Pal:Palatal Vel:Velar Uv:Uvular Ph:Pharyngeal EG:Epiglottal Gl:Glottal',
209                 ],
210         ],
211         [
212                 6 => [qw{
213                         . i y  ɨ ʉ  ɯ u
214                         . - ɪ  ʏ -  ʊ -
215                         . e ø  ɘ ɵ  ɤ o
216                         . - -  ə -  - -
217                         . ɛ œ  ɜ ɞ  ʌ ɔ
218                         . æ -  ɐ -  - -
219                         . a ɶ  - -  ɑ ɒ
220                 }],
221                 [qw{Close Near-close Close-mid Mid Open-mid Near-open Open}],
222                 [map {substr($_, 0, 1).':'.$_, substr($_, 0, 1)." r:$_ rounded"} qw{Front Central Back}]
223         ],
224 );
225