cache unicode character details in digraph include
[sheet.git] / digraphs.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 <style>
19 h1 {
20         text-align: center;
21         margin: 0 auto 0.2em;
22 }
23 table {
24         border-collapse: collapse;
25         table-layout: fixed; /* prevent resizing, notably in msie6 */
26 }
27 #legend {
28         margin-top: 1em;
29 }
30 #legend table {
31         width: 100%;
32         table-layout: auto;
33 #}
34 #legend td {
35         padding: 0 0.2em;
36 }
37 thead th, td {
38         width: 1.2em; /* msie only looks at the first row */
39         min-width: 1em; /* prevents gecko from restricting to page width */
40 }
41 th, td {
42         text-align: center;
43 }
44 td {
45         border: 1px solid #888;
46         background: #DDD;
47 }
48 td.X {
49         background: #FFF;
50 }
51
52 td.Lm, td.Mc, td.Me, td.Zl, td.Zp, td.Cs {background:red} /* unknown */
53
54 /* letters */
55 td.Greek    {background: #FFE0CF}
56 td.Cyrillic {background: #FFDDA8}
57 td.Latin    {background: #FFB}
58 td.Hebrew   {background: #FFD}
59 td.Arabic   {background: #EFE}
60 td.Hiragana {background: #DFC}
61 td.Katakana {background: #DFA}
62 td.Bopomofo {background: #BFC}
63
64 td.Nd, td.Nl,
65 td.No {background: #FBB} /* number */
66 td.Sc {background: #FCD} /* currency */
67 td.Sm {background: #ECE} /* math */
68 td.So {background: #DDCCFF} /* symbol */
69 td.Cf, td.Pd,
70 td.Po {background: #CDF} /* punctuation */
71 td.Ps, td.Pe, td.Pi,
72 td.Pf {background: #BEF} /* quote */
73 td.Lm,
74 td.Sk {background: #CEE} /* spacing modifier */
75 td.Mn {background: #ACC} /* modifier */
76 td.Cc {background: #BBB; color: #666} /* control */
77 td.Zs {background: #ACB} /* space */
78 td.Zs span {background: #EEE}
79
80 td.Xa {color: #040} /* ascii */
81 td.Xl {color: #080} /* latin1 */
82 td.Co {color: #800} /* private */
83 td.Xz {color: #F00} /* proposed */
84
85 tr:hover td {
86         background: #FF8;
87 }
88 </style>
89 </head>
90
91 <body>
92 <h1>RFC-1345 Digraphs</h1>
93
94 <:
95 my $di = do 'digraphs.inc.pl';
96
97 sub quote {
98         local $_ = shift;
99         s/"/&quot;/g;
100         s/</&lt;/g;
101         s/>/&gt;/g;
102         return $_;
103 }
104
105 my @chars = ((map {chr} ord '!' .. ord 'Z'), 'a'..'z');
106 splice @chars, $_, 1, () for 2, 3-1, 5-2, 31-3;  # remove character exceptions # $ & @
107 my @chars2 = (@chars, '_');  # trailing character (extended set)
108
109 print '<table>';
110 for my $section (qw{thead tfoot}) {
111         print "<$section><tr><th>&nbsp;";
112         print "<th>$_" for @chars2;
113 }
114 print '<tbody>';
115 for my $c1 (@chars) {
116         print "<tr><th>$c1";
117         for my $c2 (@chars2) {
118                 my $mnem = $c1 . $c2;
119                 if (not defined $di->{$mnem}) {
120                         print '<td>';
121                         next;
122                 }
123                 my ($codepoint, $name, $prop, $script) = @{ $di->{$mnem} };
124
125                 my $glyph = chr $codepoint;
126                 utf8::upgrade($glyph);  # prevent latin1 output
127                 my $desc = $mnem . ($name && " ($name)");
128                 my @class = ('X', grep {$_} $prop, $script);
129
130                 $glyph = quote($glyph);
131                 $glyph = "<span>$glyph</span>" if $prop eq 'Zs';
132
133                 printf "\n".'<td class="%s" title="%s">%s',
134                         join(' ', @class), quote($desc), $glyph;
135         }
136         print "\n<th>$c1\n";
137 }
138 print "</table>\n";
139 :>
140 <div id="legend">
141         <table><tr>
142         <td class="X Cc">control
143         <td class="X Zs"><span>spacing</span>
144         <td class="X Mn">modifier
145         <td class="X Sk">spacing modifier
146         <td class="X Pf">quote
147         <td class="X Po">punctuation
148         <td class="X So">symbol
149         <td class="X Sm">math
150         <td class="X Sc">currency
151         <td class="X No">numeric
152         <td class="X Greek">greek
153         <td class="X Cyrillic">cyrillic
154         <td class="X Latin">latin
155         <td class="X Hebrew">hebrew
156         <td class="X Arabic">arabic
157         <td class="X Hiragana">japanese
158         <td class="X Bopomofo">chinese
159         </table>
160
161         <table><tr>
162         <td class="X">unicode
163         <td class="X Xa">ascii
164         <td class="X Xl">latin1
165         <td class="X Co">private
166         <td class="X Xz">proposed
167         </table>
168 </div>
169
170 </html>