minor code cosmetics (declare version first)
[sheet.git] / digraphs.plp
1 <(common.inc.plp)><:
2         our $VERSION = 'v1.0';
3
4 :><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
5  "http://www.w3.org/TR/html4/loose.dtd">
6 <html>
7
8 <head>
9 <meta http-equiv="content-type" content="<:= $header{content_type} :>">
10 <title>digraph cheat sheet</title>
11 <:= stylesheet(qw'light') :>
12 </head>
13
14 <body id="digraphs">
15 <h1>RFC-1345 Digraphs</h1>
16
17 <p>i^k in <a href="/">Vim</a>.
18 Also see <a href="/unicode">common digraphs</a>.</p>
19
20 <p class="aside">Unofficial <span class="Xz">proposals</span>
21 are available as <a href="/digraphs.vim">ex commands</a>.</p>
22
23 <:
24 my $di = do 'digraphs.inc.pl';
25
26 sub quote {
27         local $_ = shift;
28         s/"/&quot;/g;
29         s/</&lt;/g;
30         s/>/&gt;/g;
31         return $_;
32 }
33
34 my @chars = (
35         [qw{! " % ' ( ) * + , - . /}],
36         ['0'..'9'], [qw{: ; < = > ?}],
37         ['A'..'M'], ['N'..'Z'],
38         ['a'..'m'], ['n'..'z'],
39 );
40 my @chars2 = (['_'], @chars);  # trailing character (extended set)
41
42 print '<table class="glyphs dimap"><col>';
43 print qq'<colgroup span="$_">' for map {scalar @$_} @chars2;
44 print "</colgroup><col>\n";
45 for my $section (qw{thead tfoot}) {
46         print "<$section><tr><th>↳";
47         print '<th>', quote($_) for map {@$_} @chars2;
48         print "<th>&nbsp;\n";
49 }
50 for my $c1group (@chars) {
51         print '<tbody>';
52         for my $c1 (@$c1group) {
53                 print '<tr><th>', quote($c1);
54                 for my $c2 (map {@$_} @chars2) {
55                         my $mnem = $c1 . $c2;
56                         if (not defined $di->{$mnem}) {
57                                 print '<td>';
58                                 next;
59                         }
60                         if (ref $di->{$mnem} ne 'ARRAY') {
61                                 printf '<td class="X Xr" title="%s">', quote($mnem);
62                                 next;
63                         }
64                         my ($codepoint, $name, $prop, $script, $string) = @{ $di->{$mnem} };
65
66                         my $glyph = $string || chr $codepoint;
67                         utf8::upgrade($glyph);  # prevent latin1 output
68                         my $desc = $mnem . ($name && " ($name)");
69                         my @class = ('X', grep {$_} $prop, $script);
70
71                         $glyph = quote($glyph);
72                         $glyph = "<span>$glyph</span>" if $prop eq 'Zs';
73
74                         printf "\n".'<td class="%s" title="%s">%s',
75                                 join(' ', @class), quote($desc), $glyph;
76                 }
77                 print "\n<th>", quote($c1), "\n";
78         }
79 }
80 print "</table>\n";
81 :>
82 <div class="legend">
83         <table class="glyphs"><tr>
84         <td class="X Cc">control
85         <td class="X Zs"><span>spacing</span>
86         <td class="X Mn">modifier
87         <td class="X Sk">spacing modifier
88         <td class="X Pf">quote
89         <td class="X Po">punctuation
90         <td class="X So">symbol
91         <td class="X Sm">math
92         <td class="X Sc">currency
93         <td class="X No">numeric
94         <td class="X Greek">greek
95         <td class="X Cyrillic">cyrillic
96         <td class="X Latin">latin
97         <td class="X Hebrew">hebrew
98         <td class="X Arabic">arabic
99         <td class="X Hangul">korean
100         <td class="X Hiragana">japanese
101         <td class="X Bopomofo">chinese
102         </table>
103
104         <table class="glyphs"><tr>
105         <td class="X">unicode
106         <td class="X Xl">latin1
107         <td class="X Xa">ascii
108         <td class="X Xz">proposed
109         </table>
110 </div>
111
112 <p class="footer">
113         <a href="/" rel="home">sheet.shiar.nl</a>/digraphs.<a href="/source/digraphs.plp"
114          rel="code" title="Written in Perl">plp</a>
115         <a href="http://git.shiar.nl/sheet.git/history/HEAD:/digraphs.plp"
116          rel="vcs-git" title="Git repository"><:= $VERSION :></a>
117         created by <a href="http://shiar.nl/" rel="author">Shiar</a> •
118         <a href="http://www.fsf.org/licensing/licenses/agpl-3.0.html" rel="copyright"
119          title="Licensed under the GNU Affero General Public License, version 3">AGPLv3</a>
120 </p>
121
122 </html>