common: debug option ?f to ignore json caches
[sheet.git] / latin.plp
1 <(common.inc.plp)><:
2
3 Html({
4         title => 'latin alphabet cheat sheet',
5         version => '1.7',
6         description => [
7         ],
8         keywords => [qw'
9                 latin roman alphabet script letter unicode font glyph abc
10                 code encoding spelling symbol writing comparison character
11                 secret cursive fraktur blind braille morse deaf asl hand
12                 barcode bar color semaphore flag
13         '],
14         data => ['writing-latn.inc.pl'],
15 });
16
17 :>
18 <style>
19         td svg {
20                 vertical-align: middle;
21         }
22         svg path:not([fill]) {
23                 stroke: currentColor;
24                 fill: none;
25         }
26         svg circle:not([fill]) {
27                 fill: currentColor;
28         }
29
30         .sample {
31                 text-align: left;
32                 padding: 1px 0.3em;
33         }
34         td.sample {
35                 width: auto;
36         }
37         th {
38                 white-space: nowrap; /* prevent resize by sample */
39         }
40 </style>
41
42 <h1>Latin alphabet</h1>
43
44 <p id=intro>Variant encodings of the common ASCII (latin, roman,
45 or <span title="fuck yeah!">'mercan</span>) letters A–Z.
46 Also see <a href="/writing">related alphabets</a>
47 and <a href="/chars/abc">font comparison</a>.</p>
48
49 <:
50 my $table = Data('writing-latn');
51 {
52         say '<div>';
53         say '<style>';
54         while (my ($id, $info) = each %$table) {
55                 ref $info eq 'HASH' or next;
56                 my $style = $info->{style} or next;
57                 ref $style or $style = [$style];
58                 say "\t", !/^@/ && "#$id ", $_ for @{$style};
59         }
60         say "</style>\n";
61 }
62
63 my %VOWELCOLS = (map { ($_ => 1) } 0, 4, 8, 14, 20, 24);
64 say '<table class="glyphs">';
65 say '<thead>';
66 printtr('order');
67 say '</thead>';
68 printtr('default');
69 say "</table></div>";
70
71 sub printtr {
72         for my $id (@_) {
73                 my $info = $table->{$id};
74
75                 if (ref $info eq 'ARRAY') {
76                         printtr(@{$info});
77                         next;
78                 }
79
80                 printf '<tr id="%s">', $id;
81                 my $th = 'th';
82                 $th .= sprintf ' title="%s"', $_ for $info->{title} || ();
83                 say "<$th>", $info->{name} // ucfirst $id;
84
85                 my $colspan = 1;
86                 my $col = 0;
87                 for (@{ $info->{list} }) {
88                         $col++;
89                         if ($_ eq '>') {
90                                 $colspan++;
91                                 next;
92                         }
93                         my @class;
94                         push @class ,'l0' if $VOWELCOLS{$col - $colspan};
95                         push @class, $_ ? 'ex' : 'u-invalid' if s/^-//;
96
97                         print "\t<td";
98                         if ($col > 26) {
99                                 # special character for sample generation
100                                 print ' hidden';  # sample only
101                         }
102                         else {
103                                 print ' title=', chr($col + ord('A') - $colspan);
104                         }
105                         if ($colspan > 1) {
106                                 print " colspan=$colspan";
107                                 $colspan = 1;
108                         }
109                         printf ' class="%s"', "@class" if @class;
110                         print '>';
111                         say;
112                 }
113         }
114 }
115
116 :>
117 <script type="text/javascript" src="/latinsample.js"></script>
118 <script type="text/javascript"><!--
119         prependinput(document.getElementById('intro'));
120 //--></script>
121