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