7 use open OUT => ':encoding(utf-8)', ':std';
10 our $VERSION = '1.07';
12 # import and combine various digraph data
14 my $rfc = do 'digraphs-rfc.inc.pl'
15 or die "error reading digraphs include: ", $@ // $!;
16 my $extra = do 'digraphs-shiar.inc.pl'
17 or warn "could not include shiar proposals: ", $@ // $!;
18 my $vim = do 'digraphs-vim.inc.pl'
19 or warn "could not include vim extensions ", $@ // $!;
20 my $vimold = do 'digraphs-vim-74.inc.pl'
21 or warn "could not include vim compatibility ", $@ // $!;
22 my $di = { %{$vim // {}}, %{$rfc}, %{$extra // {}} };
24 # optionally get unicode character information
25 my $uninfo = do 'unicode-char.inc.pl'
26 or warn "could not include unicode details: ", $@ // $!;
28 # output json map of character info
31 grep { !defined $di->{$_} }
32 map { substr($_, 1, 1).substr($_, 0, 1) } sort keys %{$di}
35 ord $di->{$_}, # original code point
36 $uninfo->{ $di->{$_} }->[1] // '', # name
39 ? $vim->{$_} ? 'l4' : 'l1' # vim+rfc or rfc only
40 : $vim->{$_} ? 'l3' : 'l2', # vim only or neither
41 $vimold && $vim->{$_} && !$vimold->{$_} ? 'ex' : (), # new vim feature
43 ($uninfo->{ $di->{$_} }->[0] // '') =~ s/ u-di| u-prop| ex//gr, # class
44 $uninfo->{ $di->{$_} }->[4] // (), # string
45 ] for sort keys %{$di};
47 print JSON->new->ascii->canonical->encode({
51 'Character mnemonics following compose key ⎄:',
52 'i^k in <a href="/vi">Vim</a>,',
53 '^u^\ in <a href="/readline">Emacs</a>,',
54 '^a^v in <a href="/screen">Screen</a>.',
55 'Similar but different from <a href="/digraphs/xorg">X.Org</a>.',
56 'Also see <a href="/unicode">common Unicode</a>.</p>',
57 '<p class="aside">Unofficial <span class="u-l2">proposals</span>',
58 'are available as <a href="/digraphs.vim">ex commands</a>.',
62 l3 => 'vim extension',
63 'l3 ex' => 'vim v8.0',
73 mkdigraphlist - Output character list of combined digraph data
77 mkdigraphlist | jq -r '.key."DO"[0]' | perl -nE 'say chr' # $
81 Combines precompiled digraph includes of rfc (1345), vim, and shiar
82 and outputs a complete map including character details and usage classes.
84 The C<key> values can either be a scalar string containing another
85 digraph which can be considered identical (usually inverted),
86 or an array ref containing at least the resulting character's
87 Unicode code point value. If available, the following UCD data
88 is appended: character name, usage classes, unicode classes,
89 and replacement output string.
94 "AE" => [198, "LATIN CAPITAL LETTER AE", "u-di", "Latin Lu Xl u-v11"],
101 Mischa POSLAWSKY <perl@shiar.org>
105 Licensed under the GNU Affero General Public License version 3.