common: treat exception references as alert parameters
[sheet.git] / latin.plp
1 <(common.inc.plp)><:
2
3 Html({
4         title => 'latin alphabet cheat sheet',
5         version => '1.6',
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         stylesheet => [qw( light dark red mono )],
15         data => ['writing-latn.inc.pl'],
16 });
17
18 :>
19 <style>
20         td svg {
21                 vertical-align: middle;
22         }
23         svg path:not([fill]) {
24                 stroke: currentColor;
25                 fill: none;
26         }
27         svg circle:not([fill]) {
28                 fill: currentColor;
29         }
30
31         .sample {
32                 text-align: left;
33                 padding: 1px 0.3em;
34         }
35         td.sample {
36                 width: auto;
37         }
38         th {
39                 white-space: nowrap; /* prevent resize by sample */
40         }
41 </style>
42
43 <h1>Latin alphabet</h1>
44
45 <p id=intro>Variant encodings of the common ASCII (latin, roman,
46 or <span title="fuck yeah!">'mercan</span>) letters A–Z.
47 Also see <a href="/writing">related alphabets</a>
48 and <a href="/chars/abc">font comparison</a>.</p>
49
50 <:
51 use List::Util qw( pairs );
52
53 my @table = do 'writing-latn.inc.pl';
54 if ($! or $@ or !@table) {
55         die ["Table data not found", $@ || $!];
56 }
57 else {
58         say '<div>';
59         say '<style>';
60         for my $row (pairs @table) {
61                 my ($id, $info) = @{$row};
62                 my $style = $info->{style} or next;
63                 ref $style or $style = [$style];
64                 say "\t", !/^@/ && "#$id ", $_ for @{$style};
65         }
66         say "</style>\n";
67
68         my %VOWELCOLS = (map { ($_ => 1) } 0, 4, 8, 14, 20, 24);
69         say '<table class="glyphs">';
70         say '<thead><tr><th># <small>ASCII − 64</small>';
71         print '<td>', $_ for 1 .. 26;
72         say '</thead>';
73
74         for my $row (pairs @table) {
75                 my ($id, $info) = @{$row};
76
77                 printf '<tr id="%s">', $id;
78                 my $th = 'th';
79                 $th .= sprintf ' title="%s"', $_ for $info->{title} || ();
80                 say "<$th>", $info->{name} // ucfirst $id;
81
82                 my $colspan = 1;
83                 my $col = 0;
84                 for (@{ $info->{list} }) {
85                         $col++;
86                         if ($_ eq '>') {
87                                 $colspan++;
88                                 next;
89                         }
90                         my @class;
91                         push @class ,'l0' if $VOWELCOLS{$col - $colspan};
92                         push @class, $_ ? 'ex' : 'u-invalid' if s/^-//;
93
94                         print "\t<td";
95                         if ($col > 26) {
96                                 # special character for sample generation
97                                 print ' hidden';  # sample only
98                         }
99                         else {
100                                 print ' title=', chr($col + ord('A') - $colspan);
101                         }
102                         if ($colspan > 1) {
103                                 print " colspan=$colspan";
104                                 $colspan = 1;
105                         }
106                         printf ' class="%s"', "@class" if @class;
107                         print '>';
108                         say;
109                 }
110         }
111         say "</table></div>";
112 }
113
114 :>
115 <script type="text/javascript" src="/latinsample.js"></script>
116 <script type="text/javascript"><!--
117         prependinput(document.getElementById('intro'));
118 //--></script>
119