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