latin: match suetterlin row by identifier
[sheet.git] / latin.plp
index ed68caeaf2e6940cd5ccbf33ec2f9463485c6e12..8c2bef5a32019d82b639f0c48ff57c1b80407666 100644 (file)
--- a/latin.plp
+++ b/latin.plp
@@ -1,5 +1,4 @@
 <(common.inc.plp)><:
-use 5.014;
 
 Html({
        title => 'latin alphabet cheat sheet',
@@ -22,7 +21,7 @@ Html({
                font-family: Suetterlin; /* R. G. Arens */
                src: url("/suetterlin.ttf");
        }
-       .glyphs tr:first-child+tr+tr td { font-family: Suetterlin }
+       #sütterlin td { font-family: Suetterlin }
 
        svg path:not([fill]) {
                stroke: currentColor;
@@ -47,14 +46,20 @@ and <a href="/unicode">common chars</a>.</p>
 <div>
 
 <:
+use List::Util qw( pairs );
+
 my @table = do 'writing-latn.inc.pl';
 if ($! or $@) {
-       printf "<p class=error>Table data not found: <em>%s</em>.</p>\n", $@ || $!;
+       Alert("Table data not found", $@ || $!);
 }
 else {
        say '<table class="glyphs">';
-       print ref $_ ne 'ARRAY' ? "<tr><th>$_\n" : map {/^<td/ ? $_ : "\t<td>$_\n"} @$_
-               for @table;
+       for my $row (pairs @table) {
+               my ($title, $cells) = @{$row};
+               printf '<tr id="%s">', (lc $title) =~ s/<[^>]+>//gr =~ s/\s+/-/gr;
+               say '<th>', $title;
+               print /^<td/ ? $_ : "\t<td>$_\n" for @{$cells};
+       }
        say "</table>\n";
 }