unicode: dedicated include with character details
[sheet.git] / unicode.plp
1 <(common.inc.plp)><:
2
3 Html({
4         title => 'unicode glyph cheat sheet',
5         version => 'v1.0',
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 }
42
43 our $verbose = exists $get{v};
44
45 my @config = qw(
46         Popular
47                 punctuation/quoting
48                         common
49                 symbols/binary?symbols/binary=-5
50                 latin/sample=-1
51                         sample=2-
52                         ?uncommon
53                 punctuation/version
54                 punctuation/marks
55                         spacing
56         Symbols
57                 symbols/currency
58                         cards
59                         ?chess
60                         signs1
61                         communic=0?communic
62                         trinity=0?trinity
63                         signs2
64         Signs
65                         solar
66                         zodiac=0?zodiac
67         Key_commands
68                 keys/spacing
69                         editing
70                         modifier
71                         control
72                         command
73                         ?player
74         Mathematics
75                 math/size
76                         equal
77                         set
78                         logic
79         Arrows
80                 arrows/single
81                         double
82                         white
83                         black
84                         block
85                         blacktri
86                         whitetri
87                         ?-large
88                         ?-heavy
89         Line_drawing
90                 lines/double
91                         doubleh
92                         doublev
93                         single
94                         heavy
95                         heavyh
96                         heavyv
97                         straight
98                         curved
99                         diagonal
100         Blocks
101                 block/square
102                         shades
103                         fill4
104                         fill4i
105                         fill8
106         IPA
107                 ipa/cons
108                         consco
109                         vowels
110         ?Japanese
111                 ?japanese/hira
112                         ?hiraderiv
113                         ?kata
114                         ?kataderiv
115 );
116
117 $_ and m{/*+(.+)} and @config = split /[ ]/, $1 for $ENV{PATH_INFO}, $get{q};
118
119 my $tables = do 'unicode-table.inc.pl' or die $@ || $!;
120
121 $glyphs->print(map {
122         my $_ = /(.*)\?(.*)/ ? ($verbose ? $2 : $1) : $_;
123         if (!$_) {
124                 ();
125         }
126         elsif (/[A-Z]/) {
127                 tr/_/ /;
128                 $_;
129         }
130         else {
131                 state $group;
132                 $group = $1 if s{^([^/]+)/}{};
133                 my @select = s/=(.*)// ? split(/=/, $1) : ();
134                 my $table = $tables->{$group}->{$_}
135                         or die "Unknown table specified: $group/$_";
136
137                 if (@select) {
138                         my $rowlen;
139                         for ($rowlen = 1; $rowlen++; $rowlen <= $#$table) {
140                                 last if $table->[$rowlen] =~ /\./;
141                         }
142                         my @cells = map {
143                                 my $end = (s/-(.+)?// ? ($1 // @$table / $rowlen - 1) : $_) + 1;
144                                 $_ * $rowlen .. $end * $rowlen - 1;
145                         } @select;
146                         $table = [ @$table[@cells] ];
147                 }
148                 $table;
149         }
150 } @config);
151
152 :></div>
153
154 <div class="legend">
155         <table class="glyphs"><tr>
156         <td class="X l4">ascii
157         <td class="X l3"><:= $glyphs->{style} eq 'di' ? 'digraph' : 'latin1' :>
158         <td class="X l2"><:= $glyphs->{style} eq 'di' ? 'proposed' : 'BMP' :>
159         <td class="X l1">other unicode
160         <td class="X ex">discouraged
161         </table>
162 </div>
163
164 <script type="text/javascript" src="/clipboard.js"></script>
165