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