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