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