sc: hots attributes hash (attr)
[sheet.git] / unicode.plp
1 <(common.inc.plp)><:
2
3 Html({
4         title => 'unicode glyph cheat sheet',
5         version => 'v1.1',
6         description => [
7                 "Common Unicode characters with digraph or code point, layed out for quick location.",
8                 "Includes general symbols, arrows, drawing characters, and IPA letters.",
9         ],
10         keywords => [qw'
11                 unicode glyph char character reference common ipa symbol sign mark table digraph
12         '],
13         stylesheet => [qw'light dark mono circus red'],
14         data => [qw'unicode-table.inc.pl unicode-char.inc.pl'],
15 });
16
17 :>
18 <h1>Common Unicode</h1>
19
20 <p>
21 Glyphs are followed by
22 <a href="/digraphs">digraph</a> or <a href="/charset">code point</a>,
23 i^k or i^vu respectively in <a href="/vi">Vim</a>.
24 </p>
25
26 <div class="diinfo">
27
28 <:
29 use 5.010;
30 use Shiar_Sheet::FormatChar;
31 my $glyphs = Shiar_Sheet::FormatChar->new;
32
33 if (exists $get{di}) {
34         $glyphs->{anno} = [ (!defined $get{di} || $get{di}) && 'di', 'hex' ];
35 }
36 if (exists $get{q}) {
37         $glyphs->{anno} = [];
38 }
39 if (exists $get{html}) {
40         $glyphs->{anno} = ['html', 'xml'];
41         $glyphs->{style} = 'html';
42 }
43
44 our $verbose = exists $get{v};
45
46 my @config = qw(
47         Popular
48                 punctuation/quoting
49                         common=-5?common
50                 symbols/binary?symbols/binary=-5
51                 latin/sample=-1
52                         ?sample=2-
53                         ?uncommon
54                 punctuation/version
55                 punctuation/marks
56                         spacing
57         Symbols
58                 symbols/currency
59                         cards=-3?cards
60                         ?chess
61                         harvey
62                         signs1
63                         communic=0?communic
64                         trinity=0?trinity
65                         signs2
66         Signs
67                         solar
68                         zodiac=0-1=3?zodiac
69         Key_commands
70                 keys/spacing
71                         editing
72                         modifier
73                         control
74                         command
75                         android=0
76                         ps
77                         ?player
78         Mathematics
79                 math/size
80                         equal
81                         set
82                         logic
83         Arrows
84                 arrows/single
85                         double
86                         white
87                         black
88                         block
89                         blacktri
90                         whitetri
91                         ?-large
92                         ?-heavy
93         Line_drawing
94                 lines/double
95                         doubleh
96                         doublev
97                         single
98                         heavy
99                         heavyh
100                         heavyv
101                         straight
102                         curved
103                         diagonal
104         Blocks
105                 block/square
106                         shades
107                         fill4
108                         fill4i
109                         fill8
110         IPA
111                 ipa/cons
112                         consco
113                         vowels
114         ?Japanese
115                 ?japanese/hira
116                         ?hiraderiv
117                         ?kata
118                         ?kataderiv
119 );
120
121 splice @config, 4, 2, qw(
122                 latin/vowels=-5?latin/vowels
123                          westeuro
124                         ?easteuro
125 ) if exists $get{html};
126
127 $_ and m{/*+(.+)} and @config = split /[ ]/, $1 for $ENV{PATH_INFO}, $get{q};
128
129 my $tables = do 'unicode-table.inc.pl' or die $@ || $!;
130
131 $glyphs->print(map {
132         my $_ = /(.*)\?(.*)/ ? ($verbose ? $2 : $1) : $_;
133         if (!$_) {
134                 ();
135         }
136         elsif (/[A-Z]/) {
137                 tr/_/ /;
138                 $_;
139         }
140         else {
141                 state $group;
142                 $group = $1 if s{^([^/]+)/}{};
143                 my @select = s/=(.*)// ? split(/=/, $1) : ();
144                 my $table = $tables->{$group}->{$_}
145                         or die "Unknown table specified: $group/$_";
146
147                 if (@select) {
148                         my $rowlen;
149                         for ($rowlen = 1; $rowlen++; $rowlen <= $#$table) {
150                                 last if $table->[$rowlen] =~ /\./;
151                         }
152                         my @cells = map {
153                                 my $end = (s/-(.+)?// ? ($1 // @$table / $rowlen - 1) : $_) + 1;
154                                 $_ * $rowlen .. $end * $rowlen - 1;
155                         } @select;
156                         $table = [ @$table[@cells] ];
157                 }
158                 $table;
159         }
160 } @config);
161
162 :></div>
163
164 <div class="legend">
165         <table class="glyphs"><tr>
166         <td class="X l5">ascii
167         <td class="X l4"><:= $glyphs->{style} eq 'di' ? 'digraph' : 'latin1' :>
168         <td class="X l3"><:= $glyphs->{style} eq 'di' ? 'proposed' : 'HTML4' :>
169         <td class="X l2">unicode ≤6.0
170         <td class="X l1">other unicode
171         <td class="X ex">discouraged
172         </table>
173 </div>
174
175 <script type="text/javascript" src="/clipboard.js"></script>
176