X-Git-Url: http://git.shiar.nl/sheet.git/blobdiff_plain/67ae97362cec317f2cfc3ae97f9d3810f70d615c..133e96335267b12bb7e97d9bbe551a3a043bd32a:/tools/mkdigraphlist?ds=sidebyside
diff --git a/tools/mkdigraphlist b/tools/mkdigraphlist
index 66ffd2a..5117b76 100755
--- a/tools/mkdigraphlist
+++ b/tools/mkdigraphlist
@@ -4,90 +4,71 @@ use strict;
use warnings;
use utf8;
-use open OUT => ':utf8', ':std';
-use Data::Dumper;
+use open OUT => ':encoding(utf-8)', ':std';
+use JSON ();
-our $VERSION = '1.03';
+our $VERSION = '1.07';
-# create a hash of desired input
-my $di = do 'data/digraphs-rfc.inc.pl'
+# import and combine various digraph data
+push @INC, 'data';
+my $rfc = do 'digraphs-rfc.inc.pl'
or die "error reading digraphs include: ", $@ // $!;
-
-# personal addendums
-my @extra;
-if (-r 'shiar.inc.txt') {
- open my $include, '<:utf8', 'shiar.inc.txt';
- for (readline $include) {
- m{^(\$?[!"%'-Z_a-z]{2}) (.)} or next;
- warn("$1 already defined"), next if defined $di->{$1};
- $di->{$1} = ord $2;
- push @extra, $1;
- }
-}
-warn $@ if $@;
-
-$di->{chr $_} = $_ for 32 .. 126;
-$di->{'\\'.$_} = delete $di->{$_} for '{', '}', '\\';
+my $extra = do 'digraphs-shiar.inc.pl'
+ or warn "could not include shiar proposals: ", $@ // $!;
+my $vim = do 'digraphs-vim.inc.pl'
+ or warn "could not include vim extensions ", $@ // $!;
+my $vimold = do 'digraphs-vim-74.inc.pl'
+ or warn "could not include vim compatibility ", $@ // $!;
+my $di = { %{$vim // {}}, %{$rfc}, %{$extra // {}} };
# optionally get unicode character information
-my %info = eval {
- require Unicode::UCD;
- map {
- $_ => Unicode::UCD::charinfo($di->{$_})
- || { block => '?', category => 'Xn', name => '', script => '' }
- } keys %{$di};
-};
-
-# add custom categories for certain blocks
-for (values %info) {
- $_->{category} .= ' Xa' if $_->{block} eq 'Basic Latin';
- $_->{category} .= ' Xl' if $_->{block} eq 'Latin-1 Supplement';
-}
-
-# mark unofficial extras as such
-$info{$_}->{category} .= ' Xz' for @extra;
-
-for (keys %{$di}) {
- $info{$_}->{string} = chr(9676) . chr($di->{$_}) if $info{$_}->{combining};
- # find control characters (first 32 chars from 0 and 128)
- next unless ($di->{$_} & ~0b1001_1111) == 0 or $di->{$_} == 127;
- # rename to something more descriptive
- $info{$_}->{name} = $info{$_}->{unicode10}
- ? '<'.$info{$_}->{unicode10}.'>' # the old name was much more useful
- : sprintf('
Unofficial proposals',
+ 'are available as ex commands.',
+ ),
+ flag => {
+ l5 => 'full support',
+ l4 => 'vim extension',
+ l3 => 'vim v8.0',
+ l2 => 'proposal',
+ l1 => 'not in vim',
+ },
+ flagclass => {
+ l5 => '', # common
+ l3 => 'u-l5', # rare
+ },
+});
__END__
@@ -97,27 +78,26 @@ mkdigraphlist - Output character list of combined digraph data
=head1 SYNOPSIS
- mkdigraphlist >digraphs.inc.pl
- perl -e'$di = do "digraphs.inc.pl"; print chr $di->{DO}->[0]'
+ mkdigraphlist | jq -r '.key."DO"[0]' | perl -nE 'say chr' # $
=head1 DESCRIPTION
-Parses the official RFC-1345 document, searching the
-'character mnemonic table' for all digraph definitions.
-If successful, Perl code is output resulting in a hash
-with character data keyed by digraph.
-Any errors and warnings are given at STDERR.
+Combines precompiled digraph includes of rfc (1345), vim, and shiar
+and outputs a complete map including character details and usage classes.
-The value can either be a scalar string containing another
+The C