latin: group aliases similar to termcol ea
authorMischa POSLAWSKY <perl@shiar.org>
Sat, 14 May 2022 15:41:13 +0000 (17:41 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Mon, 6 Feb 2023 12:35:54 +0000 (13:35 +0100)
Replacing pairwise list access for order so the structure can be
represented as a proper hash table.

Makefile
latin.plp
writing-latn.inc.pl

index 75f269b81c478281499b4abfc9d75470a402262d..138be91eaa98aa1d72fc1cefa9494641e7b89630 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -89,7 +89,7 @@ data/wordlist.%.inc.pl: tools/mkwordlist data/wordlist.version.txt
 data/word%.json: data/word%.inc.pl
        $(call cmdsave,perl -MJSON=encode_json -E "print encode_json(do \$$ARGV[0])" ./$<)
 data/%.json: %.inc.pl
-       $(call cmdsave,perl -MJSON=encode_json -E "print encode_json([ do \$$ARGV[0] ])" ./$<)
+       $(call cmdsave,perl -MJSON -E "print JSON->new->utf8->canonical->encode(do \$$ARGV[0])" ./$<)
 
 data/wordpairs.inc.pl: data/wordlist.version.txt
        @perl -I. -MShiar_Sheet::DB -MData::Dump=pp -E 'say pp(Shiar_Sheet::DB->connect->select("word w JOIN word a ON w.id=a.ref" => "w.id, a.id", {"a.lang"=>undef})->map or exit 1)' >$@
index cac0e92b3fd7b07c756335a53a0e3519fad87c72..70c9b05ee8dd93a03d9c598a086975738506601d 100644 (file)
--- a/latin.plp
+++ b/latin.plp
@@ -48,28 +48,35 @@ Also see <a href="/writing">related alphabets</a>
 and <a href="/chars/abc">font comparison</a>.</p>
 
 <:
-use List::Util qw( pairs );
-
-my @table = Data('writing-latn');
+my $table = Data('writing-latn');
 {
        say '<div>';
        say '<style>';
-       for my $row (pairs @table) {
-               my ($id, $info) = @{$row};
+       while (my ($id, $info) = each %$table) {
+               ref $info eq 'HASH' or next;
                my $style = $info->{style} or next;
                ref $style or $style = [$style];
                say "\t", !/^@/ && "#$id ", $_ for @{$style};
        }
        say "</style>\n";
+}
 
-       my %VOWELCOLS = (map { ($_ => 1) } 0, 4, 8, 14, 20, 24);
-       say '<table class="glyphs">';
-       say '<thead><tr><th># <small>ASCII − 64</small>';
-       print '<td>', $_ for 1 .. 26;
-       say '</thead>';
+my %VOWELCOLS = (map { ($_ => 1) } 0, 4, 8, 14, 20, 24);
+say '<table class="glyphs">';
+say '<thead>';
+printtr('order');
+say '</thead>';
+printtr('default');
+say "</table></div>";
 
-       for my $row (pairs @table) {
-               my ($id, $info) = @{$row};
+sub printtr {
+       for my $id (@_) {
+               my $info = $table->{$id};
+
+               if (ref $info eq 'ARRAY') {
+                       printtr(@{$info});
+                       next;
+               }
 
                printf '<tr id="%s">', $id;
                my $th = 'th';
@@ -105,7 +112,6 @@ my @table = Data('writing-latn');
                        say;
                }
        }
-       say "</table></div>";
 }
 
 :>
index a2dd4b44d09972b0671fbdaa74958be720fa38d7..806bff2bc9baac3acbe2009f18b7ffb331ac6f40 100644 (file)
@@ -151,7 +151,23 @@ sub disphues {
        );
 }
 
-(
++{
+default => [qw( written sign digital touch tactile sound games semaphore barcode personal )],
+written => [qw( uppercase lowercase suetterlin roman )],
+digital => [qw( stroke ita2 )],
+stroke => [qw( graffiti unistrokes edgewrite )],
+touch => [qw( moon braille )],
+sign => ['sutton'],
+sound => [qw( morse tap shorttap )],
+games => [qw( domino tetromino cards )],
+semaphore => [qw( maritime flag chappe prussian )],
+barcode => [qw( rm4scc code39 code93 code128 )],
+personal => [qw( rgbmap cmymap dni pigpen nyctographs chromacons )],
+
+order => {
+       name => '#',
+       list => [1 .. 26],
+},
 uppercase => {
        list => [qw{ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z }],
 },
@@ -783,4 +799,4 @@ chromacons => {
                }
        ],
 },
-);
+};