force keyboard width to prevent row breaks
[sheet.git] / unicode.plp
1 <:
2 use utf8;
3 use strict;
4 use warnings;
5 no  warnings 'qw';  # that's not a comment, it's a NUMBER SIGN
6 use open IO => ':utf8';
7
8 our $VERSION = 'v1.0';
9
10 $header{content_type} = 'text/html; charset=utf-8';
11
12 :><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
13  "http://www.w3.org/TR/html4/loose.dtd">
14 <html>
15
16 <head>
17 <title>digraph cheat sheet</title>
18 <meta http-equiv="content-type" content="utf-8">
19 <link rel="stylesheet" type="text/css" media="all" href="/base.css"><:
20         my %styles = map {$_ => $_} qw(dark circus mono red terse);
21         our $style = exists $get{style} && $styles{$get{style}} || 'light';
22         printf(qq{\n<link rel="%s" type="text/css" media="all" href="%s" title="%s">},
23                 $_ eq $style ? 'stylesheet' : 'alternate stylesheet', "$_.css", $_
24         ) for keys %styles;
25 :>
26 </head>
27
28 <body id="unicode">
29 <h1>Common uncommon Unicode</h1>
30
31 <p>i^k in <a href="/">Vim</a>.
32 Also see the <a href="/digraphs">complete digraphs table</a>.</p>
33
34 <div class="diinfo">
35
36 <:
37 my $diinfo = do 'digraphs.inc.pl';
38 my %di = map { $diinfo->{$_}->[0] => $_ } grep { ref $diinfo->{$_} }
39         sort { length $a <=> length $b } keys %$diinfo;
40
41 sub quote {
42         local $_ = shift;
43         s/"/&quot;/g;
44         s/</&lt;/g;
45         s/>/&gt;/g;
46         return $_;
47 }
48
49 sub glyph_table {
50         my ($digraphs) = @_;
51
52         my @rows;
53
54         my @colheads;
55         while ($digraphs->[0] !~ /^\./) {
56                 my $cell = shift @$digraphs or last;
57                 push @colheads, sprintf(
58                         '<%s%s>%s',
59                         $cell =~ s/^-// ? 'td' : 'th',
60                         $cell =~ s/:(.*)// ? qq{ title="$1"} : '',
61                         $cell eq '_' ? '&nbsp;' : $cell
62                 );
63         }
64         push @rows, sprintf '<thead><tr>%s<tbody>', join '', @colheads if @colheads;
65
66         my $colspan = 1;
67         for my $cell (@$digraphs) {
68                 if ($cell =~ s/^\.//) {
69                         # dot indicates start of a new row
70                         push @rows, '';
71                         if ($cell =~ s/^>//) {
72                                 # header cell text follows
73                                 $cell =~ s/_/ /g;  # underscores may be used instead of whitespace (for qw//ability)
74                                 $rows[-1] .= '<th>'.($cell || '&nbsp;');
75                         }
76                         next;
77                 }
78                 elsif ($cell eq '>') {
79                         # merge this cell to the next column
80                         $colspan++;
81                         next;
82                 }
83
84                 my ($code, $name);
85
86                 # determine display class
87                 my @class;
88                 if ($cell eq '-') {
89                         $cell = '';
90                 }
91                 elsif ($cell eq '=') {
92                         push @class, 'di-invalid';
93                         $cell = '';
94                 }
95                 else {
96                         if ($cell =~ s/^-//) {
97                                 push @class, 'di-rare'; # discouraged
98                         }
99
100                         $code = join '', map { $di{ord $_} || '' } split //, $cell;
101                         $name = $diinfo->{$code}->[1];
102                         length $code == 2 or undef $code;
103
104                         if (defined $code) {
105                                 push @class, 'di-d'; # digraph
106                                 push @class, 'di-prop' # unofficial
107                                         if $diinfo->{$code}->[2] =~ /\bXz\b/;
108                         }
109                         elsif (defined $name) {
110                                 push @class, 'X';
111                         }
112
113                         if ($cell =~ /[ -~]/) {
114                                 push @class, 'di-a'; # ascii
115                         }
116                         else {
117                                 push @class, 'di-b'; # basic unicode
118                         }
119                 }
120
121                 # add cell html
122                 $rows[-1] .= sprintf('<td%s%s%s>%s%s',
123                         defined $name  ? qq{ title="$name"}  : '',
124                         @class ? sprintf(' class="%s"', join ' ', @class) : '',
125                         $colspan > 1 && qq{ colspan="$colspan"},
126                         $cell eq '' ? '&nbsp;' : quote($cell),
127                         defined $code ? 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         return sprintf qq{<table class="glyphs dilabel">\n%s</table>\n},
137                 join '', map {"<tr>$_\n"} @rows;
138 }
139
140 sub print_glyph_tables {
141         while (@_) {
142                 printf "<div><h2>%s</h2>\n\n", shift;
143                 while (ref $_[0] and $_ = shift) {
144                         print glyph_table($_);
145                 }
146                 print '</div>';
147         }
148 }
149
150 our $verbose = exists $get{v};
151
152 print_glyph_tables(
153         'Popular',
154         [qw{. « » . ‹ › . ‘ ’ . “ ” . „ ‚ . ‟ ‛}],
155         [qw{. † ‡ • . § ¶ # . © ® ™ . ° ′ ″ . − × ÷ . ± ² √}],
156         [qw{. ⚋ ⚊ . ⚐ ⚑ . ☺ ☹ . ✓ ✗ . ✔ ✘ . ◄ ► }],
157         [qw{. å ä ö ü ß . Å æ ø ű ſ}],
158         [qw{. ¿ ç ñ é ê è}],
159
160         'Signs',
161         [qw{. ¤ ¢ ₥ € £ ₨ $ ¥ . ₫ ₭ ₦ ₱ ₧ ₮ ₩ ₪}],
162         [qw{. ♠ ♡ ♢ ♣ . ♤ ♥ ♦ ♧}],
163         [qw{. ☉ ☿ ♀ ♁ ♂ ♃ ♄ ♅ ♆ ♇}],  # solar
164         [qw{. ♈ ♉ ♊ ♋ ♌ ♍ ♎ ♏ ♐ ♑ ♒ ♓}],  # zodiac
165
166         'Arrows',
167         [qw{. ↖ ↑ ↗ ↔ . ← - → ↕ . ↙ ↓ ↘ -}],
168         [qw{. ⇖ ⇑ ⇗ ⇔ . ⇐ - ⇒ ⇕ . ⇙ ⇓ ⇘ -}],
169         [qw{. ⬁ ⇧ ⬀ ⬄ . ⇦ - ⇨ ⇳ . ⬃ ⇩ ⬂ -}],
170         [qw{. ⬉ ⬆ ⬈ ⬌ . ⬅ - ➡ ⬍ . ⬋ ⬇ ⬊ -}],
171         [qw{. ◩ ⬒ ⬔   . ◧ □ ◨   . ⬕ ⬓ ◪  }],
172         [qw{. ◤ ▲ ◥   . ◀ ◆ ▶   . ◣ ▼ ◢  }],
173         [qw{. ◸ △ ◹   . ◁ ◇ ▷   . ◺ ▽ ◿  }],
174 $verbose ? (
175         [qw{.    .  -  .    }],
176         [qw{.    .  -  .    }],
177 ) : (),
178
179         'Line drawing',
180         [qw{. ╔ ╦ ╗ ═ . ╠ ╬ ╣ ║ . ╚ ╩ ╝ - }],
181         [qw{. ╒ ╤ ╕ . ╞ ╪ ╡ . ╘ ╧ ╛ }],
182         [qw{. ╓ ╥ ╖ . ╟ ╫ ╢ . ╙ ╨ ╜ }],
183         [qw{. ┌ ┬ ┐ . ├ ┼ ┤ . └ ┴ ┘}],
184         [qw{. ┏ ┳ ┓ . ┣ ╋ ┫ . ┗ ┻ ┛}],
185         [qw{. ┍ ┯ ┑ . ┝ ┿ ┥ . ┕ ┷ ┙}],
186         [qw{. ┎ ┰ ┒ . ┠ ╂ ┨ . ┖ ┸ ┚}],
187         [qw{
188                 . ╴ ─ ╌ ┄ ┈ ╶ ╾
189                 . ╸ ━ ╍ ┅ ┉ ╺ ╼
190                 . ╵ │ ╎ ┆ ┊ ╷ ╿
191                 . ╹ ┃ ╏ ┇ ┋ ╻ ╽
192         }],
193         [qw{. ╱ ╳ ╲ }],
194
195         'Blocks',
196         [qw{. □ ▣ ■ . ▤ ▦ ▥ . ▧ ▩ ▨}],
197         [qw{. ░ . ▒ . ▓ }],
198         [qw{. ▘ ▀ ▝ . ▌ █ ▐ . ▖ ▄ ▗ }],
199         [qw{. ▛ ▚ ▟ . ▙ ▞ ▜ }],
200         [qw{. ▁ ▂ ▃ ▄ ▅ ▆ ▇ ▔ . ▏ ▎ ▍ ▌ ▋ ▊ ▉ ▕ }],
201
202         'IPA',
203         [qw{
204                 - BiL:Bilabial LD:Labiodental D:Dental Alv:Alveolar PA:Postalveolar
205                   Rf:Retroflex Pal:Palatal Vel:Velar Uv:Uvular Ph:Pharyngeal
206                   EG:Epiglottal Gl:Glottal
207                 .>Plosive                   p  -ȹ >  >  t  ʈ  c  k  q  =  ʡ  ʔ
208                 .>Voiced_Plosive            b  -ȸ >  >  d  ɖ  ɟ  ɡ  ɢ  =  -  =
209                 .>Nasal                     m  ɱ  >  >  n  ɳ  ɲ  ŋ  ɴ  =  =  =
210                 .>Trill                     ʙ  -  >  >  r  -  -  =  ʀ  =  -я =
211                 .>Tap/flap                  -  ⱱ  >  >  ɾ  ɽ  -  =  ɢ̆  =  -  =
212                 .>Fricative                 ɸ  f  θ  s  ʃ  ʂ  ç  x  χ  ħ  ʜ  h
213                 .>Voiced_fricative          β  v  ð  z  ʒ  ʐ  ʝ  ɣ  ʁ  ʕ  ʢ  ɦ
214                 .>Lateral_fricative         =  =  >  >  ɬ  -  -  -  -  =  =  =
215                 .>Voiced_lateral_fricative  =  =  >  >  ɮ  -  -  -  -  =  =  =
216                 .>Approximant               -  ʋ  >  >  ɹ  ɻ  j  ɰ  -  -  -  =
217                 .>Lateral_approximant       =  =  >  >  l  ɭ  ʎ  ʟ  -  =  =  =
218                 .>Click                     ʘ  -  ǀ  ǁ  ǃ  -‼ ǂ  -  -  =  =  =
219                 .>Implosive                 ɓ  ɗ̪  >  >  ɗ  -ᶑ ʄ  ɠ  ʛ  =  =  =
220         }],
221         [qw{
222                 co . ɕ . ʑ . ɧ . ɥ . ʍ . w
223         }],
224         [(
225                 '-',
226                 map { substr($_, 0, 1).':'.$_, substr($_, 0, 1)." r:$_ rounded" }
227                 qw{Front Central Back}
228         ), qw{
229                 .>Close      i y  ɨ ʉ  ɯ u
230                 .>Near-close ɪ ʏ  - -  - ʊ
231                 .>Close-mid  e ø  ɘ ɵ  ɤ o
232                 .>Mid        - -  ə -  - -
233                 .>Open-mid   ɛ œ  ɜ ɞ  ʌ ɔ
234                 .>Near-open  æ -  ɐ -  - -
235                 .>Open       a ɶ  - -  ɑ ɒ
236         }],
237
238 $verbose ? (
239         'Japanese',
240         [qw{
241                   - A  I  U  E  O  _
242                 .>  あ い う え お =
243                 .>K か き く け こ =
244                 .>S さ し す せ そ =
245                 .>T た ち つ て と =
246                 .>N な に ぬ ね の ん
247                 .>H は ひ ふ へ ほ =
248                 .>M ま み む め も =
249                 .>Y や =  ゆ =  よ =
250                 .>R ら り る れ ろ =
251                 .>W わ -ゐ = -ゑ を =
252         }],
253         [qw{
254                   - A  I  U  E  O
255                 .>G が ぎ ぐ げ ご
256                 .>Z ざ じ ず ぜ ぞ
257                 .>D だ ぢ づ で ど
258                 .>B ば び ぶ べ ぼ
259                 .>P ぱ ぴ ぷ ぺ ぽ
260         }],
261         [qw{
262                   - A  I  U  E  O  _
263                 .>  ア イ ウ エ オ ー
264                 .>K カ キ ク ケ コ =
265                 .>S サ シ ス セ ソ =
266                 .>T タ チ ツ テ ト =
267                 .>N ナ ニ ヌ ネ ノ ン
268                 .>H ハ ヒ フ ヘ ホ =
269                 .>M マ ミ ム メ モ =
270                 .>Y ヤ -  ユ -  ヨ =
271                 .>R ラ リ ル レ ロ =
272                 .>W ワ ヰ -  ヱ ヲ =
273         }],
274         [qw{
275                   - A  I  U  E  O
276                 .>G ガ ギ グ ゲ ゴ
277                 .>Z ザ ジ ズ ゼ ゾ
278                 .>D ダ ヂ ヅ デ ド
279                 .>B バ ビ ブ ベ ボ
280                 .>P パ ピ プ ペ ポ
281                 .>V ヷ ヸ ヴ ヹ ヺ
282         }],
283 ) : (),
284 );
285
286 :></div>
287
288 <div class="legend">
289         <table class="glyphs"><tr>
290         <td class="X di-a">ascii
291         <td class="X di-d">digraph
292         <td class="X di-prop">proposed
293         <td class="X di-b">other unicode
294         <td class="X di-rare">discouraged
295         </table>
296 </div>
297
298 <p class="footer">
299         <a href="/" rel="home">sheet.shiar.nl</a>/unicode
300         <a href="git://git.shiar.nl/sheet" rel="vcs-git" title="Git repository"><:= $VERSION :></a>
301         created by <a href="http://shiar.nl/" rel="author">Shiar</a> •
302         <a title="Licensed under the GNU Affero General Public License, version 3" rel="copyright"
303            href="http://www.fsf.org/licensing/licenses/agpl-3.0.html">AGPLv3</a>
304 </p>
305
306 </html>