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