keyboard/altgr/index: ignore js include on tableless pages
[sheet.git] / tools / mkjson
index 6a7d9489a46bcd75fe59e1a2f1b6fab531c547fc..3b1bfa9317cce5f17308fb44cc733fa7e26adb91 100755 (executable)
@@ -1,7 +1,22 @@
 #!/usr/bin/env perl
 use 5.012;
 use warnings;
 #!/usr/bin/env perl
 use 5.012;
 use warnings;
+use re '/msx';
 use JSON;
 
 use JSON;
 
-my $data = do "./$ARGV[0]" or die $@;
-print JSON->new->utf8->canonical->encode($data);
+our $VERSION = '1.00';
+
+our %get;
+while (@ARGV) {
+       $ARGV[0] =~ s/^--// or last;  # --flag
+       my ($name, $val) = split /=/, shift, 2 or last;  # set until empty
+       $get{$name} = $val // 1;
+}
+my $file = shift or die "Usage: $0 [--options] <input>\n";
+
+my $jsonify = JSON->new->utf8->canonical;
+$jsonify->pretty if $get{pretty};
+
+my $data = do "./$file" or die $@;
+print $jsonify->encode($data)
+       =~ s{\[ \K\n ([^][]+) (?=\])}{$1 =~ s/(?:\A|\n) \s*//gr}reg;