unicode: common (western) characters
[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 <link rel="stylesheet" type="text/css" media="all" href="digraphs.css">
19 </head>
20
21 <body>
22 <h1>RFC-1345 Digraphs</h1>
23
24 <p>i^k in <a href="/">Vim</a>.
25 Also see <a href="/unicode">common digraphs</a>.</p>
26
27 <:
28 my $di = do 'digraphs.inc.pl';
29
30 sub quote {
31         local $_ = shift;
32         s/"/&quot;/g;
33         s/</&lt;/g;
34         s/>/&gt;/g;
35         return $_;
36 }
37
38 my @chars = (
39         [qw{! " % ' ( ) * + , - . /}],
40         ['0'..'9'], [qw{: ; < = > ?}],
41         ['A'..'M'], ['N'..'Z'],
42         ['a'..'m'], ['n'..'z'],
43 );
44 my @chars2 = (['_'], @chars);  # trailing character (extended set)
45
46 print '<table><col>';
47 print qq'<colgroup span="$_">' for map {scalar @$_} @chars2;
48 print "</colgroup><col>\n";
49 for my $section (qw{thead tfoot}) {
50         print "<$section><tr><th>&nbsp;";
51         print '<th>', quote($_) for map {@$_} @chars2;
52         print "<th>&nbsp;\n";
53 }
54 for my $c1group (@chars) {
55         print '<tbody>';
56         for my $c1 (@$c1group) {
57                 print '<tr><th>', quote($c1);
58                 for my $c2 (map {@$_} @chars2) {
59                         my $mnem = $c1 . $c2;
60                         if (not defined $di->{$mnem}) {
61                                 print '<td>';
62                                 next;
63                         }
64                         if (ref $di->{$mnem} ne 'ARRAY') {
65                                 printf '<td class="X Xr" title="%s">', quote($mnem);
66                                 next;
67                         }
68                         my ($codepoint, $name, $prop, $script, $string) = @{ $di->{$mnem} };
69
70                         my $glyph = $string || chr $codepoint;
71                         utf8::upgrade($glyph);  # prevent latin1 output
72                         my $desc = $mnem . ($name && " ($name)");
73                         my @class = ('X', grep {$_} $prop, $script);
74
75                         $glyph = quote($glyph);
76                         $glyph = "<span>$glyph</span>" if $prop eq 'Zs';
77
78                         printf "\n".'<td class="%s" title="%s">%s',
79                                 join(' ', @class), quote($desc), $glyph;
80                 }
81                 print "\n<th>", quote($c1), "\n";
82         }
83 }
84 print "</table>\n";
85 :>
86 <div id="legend">
87         <table><tr>
88         <td class="X Cc">control
89         <td class="X Zs"><span>spacing</span>
90         <td class="X Mn">modifier
91         <td class="X Sk">spacing modifier
92         <td class="X Pf">quote
93         <td class="X Po">punctuation
94         <td class="X So">symbol
95         <td class="X Sm">math
96         <td class="X Sc">currency
97         <td class="X No">numeric
98         <td class="X Greek">greek
99         <td class="X Cyrillic">cyrillic
100         <td class="X Latin">latin
101         <td class="X Hebrew">hebrew
102         <td class="X Arabic">arabic
103         <td class="X Hangul">korean
104         <td class="X Hiragana">japanese
105         <td class="X Bopomofo">chinese
106         </table>
107
108         <table><tr>
109         <td class="X">unicode
110         <td class="X Xl">latin1
111         <td class="X Xa">ascii
112         <td class="X Xz">proposed
113         </table>
114 </div>
115
116 <p id="footer">
117         <a href="http://vi.shiar.net/digraphs">vi.<strong>shiar.net</strong>/digraphs</a>
118         <a href="git://dev.shiar.net/vi-cheat"><:= "v$VERSION" :></a>
119         created by Shiar •
120         <a title="Licensed under the GNU Affero General Public License, version 3"
121            href="http://www.fsf.org/licensing/licenses/agpl-3.0.html">AGPLv3</a> •
122         last update <:
123                 use Time::Format qw(time_format);
124                 print time_format('yyyy-mm-dd', (stat 'digraphs.inc.pl')[9]);
125         :>
126 </p>
127
128 </html>