3 my $mode = ($Request // '') eq 'xorg' || exists $get{xorg};
4 my $modename = $mode ? 'X.Org' : 'RFC-1345';
7 title => 'digraph cheat sheet',
10 "Complete table of digraph characters from $modename.",
13 digraph mnemonic compose composition pair
14 character char glyph table unicode vim xorg x11 x
16 stylesheet => [qw'light'],
17 data => [qw( data/digraphs.inc.pl )],
21 <h1><:= $modename :> Digraphs</h1>
23 <p>Character mnemonics following compose key ⎄<:
26 ' in the X Window System (Shift+AltGr by default).',
27 'Differences from <a href="/digraphs">RFC-1345</a> are indicated.',
29 'i^k in <a href="/vi">Vim</a>,',
30 '^u^\ in <a href="/readline">Emacs</a>,',
31 '^a^v in <a href="/screen">Screen</a>.',
32 'Similar but different from <a href="/digraphs/xorg">X.Org</a>.',
34 'Also see <a href="/unicode">common Unicode</a>.</p>',
36 say '<p class="aside">Unofficial <span class="u-l2">proposals</span>',
37 ' are available as <a href="/digraphs.vim">ex commands</a>.' if not $mode;
41 my $di = Data('digraphs');
44 # show characters for inverted mnemonics (vim alternatives)
45 $di->{key}->{ substr($_, 1, 1) . substr($_, 0, 1) } ||= [
46 $di->{key}->{$_}->[0], '', 'l0 ex', '', $di->{key}->{$_}->[4]
47 ] for grep { ref $di->{key}->{$_} } keys %{ $di->{key} };
51 [qw{! " % ' ( ) * + , - . /}],
52 ['0'..'9'], [qw{: ; < = > ?}],
53 ['A'..'M'], ['N'..'Z'],
54 ['a'..'m'], ['n'..'z'],
56 my @chars2 = (['_'], @chars); # trailing character (extended set)
57 my @columns = !exists $get{split} ? \@chars2 :
58 ([@chars2[0, 1, 3, 4, 6]], [@chars2[2, 5, 7]]);
61 my $xorg = Data('digraphs-xorg');
62 $_->[3] = undef for values %{$xorg}; # reset alias classes
63 $xorg->{$_}->[2] = # class = compatibility
64 !$di->{key}->{$_} ? 'l2' : # free
65 $di->{key}->{$_}->[0] != $xorg->{$_}->[0] ? 'l1' : # conflict
66 $di->{key}->{$_}->[2] eq 'l4' ? 'l5' : # rfc
70 for my $cp (map {$_->[0]} values %{$xorg}) {
71 next if (state $seen = {})->{$cp}++; # List::MoreUtils::uniq
73 # find multiple equivalent mnemonics
74 my @equiv = grep {$cp eq $_->[0]}
75 map {$xorg->{$_}} sort keys %{$xorg}; # values ordered by mnem.
77 # search for the most compatible match
79 $equiv[$b]->[2] cmp $equiv[$a]->[2] # highest level
80 || $b <=> $a # fallback to last mnemonic
83 # reclassify all but one as level 0 (omitted)
84 splice @equiv, $compat // -1, 1, ();
85 $_->[2] = 'l0 ex' for @equiv;
88 $chars2[0] = [qw( # ^ _ ` ~ )];
93 for my $colchars (@columns) {
94 print '<table class="glyphs dimap"><col>';
95 print qq'<colgroup span="$_">' for map {scalar @$_} @{$colchars};
96 say '</colgroup><col>';
97 for my $section (qw{thead tfoot}) {
98 print "<$section><tr><th>↳";
99 print '<th>', EscapeHTML($_) for map {@$_} @{$colchars};
102 for my $c1group (@chars) {
104 for my $c1 (@$c1group) {
105 print '<tr><th>', EscapeHTML($c1);
106 for my $c2 (map {@$_} @$colchars) {
107 my $mnem = $c1 . $c2;
108 if (not defined $di->{key}->{$mnem}) {
112 if (ref $di->{key}->{$mnem} ne 'ARRAY') {
113 printf '<td class="X Xr" title="%s">', EscapeHTML($mnem);
116 my ($codepoint, $name, $support, $script, $string) =
117 @{ $di->{key}->{$mnem} };
119 my $glyph = $string || chr $codepoint;
120 utf8::upgrade($glyph); # prevent latin1 output
121 my $desc = $mnem . ($name && " ($name)");
122 my @class = ('X', grep {$_} $script);
123 push @class, $mode ? $support : "u-$support" if $support;
125 $glyph = EscapeHTML($glyph);
126 $glyph = "<span>$glyph</span>" if $script =~ /\bZs\b/;
128 printf "\n".'<td class="%s" title="%s">%s',
129 join(' ', @class), EscapeHTML($desc), $glyph;
131 say "\n<th>", EscapeHTML($c1);
135 print '<hr>' if exists $get{split};
141 <table class="glyphs"><tr>
142 <td class="X l5">matching RFC-1345
143 <td class="X l3">matching proposal
144 <td class="X l2">unique to Xorg
145 <td class="X l1">conflict
146 <td class="X l0 ex">duplicate
151 <table class="glyphs"><tr>
152 <td class="X Cc">control
153 <td class="X Zs"><span>space</span>
154 <td class="X Mn">combining
155 <td class="X Sk">spacing modifier
156 <td class="X Pf">quote
157 <td class="X Po">punctuation
158 <td class="X So">symbol
159 <td class="X Sm">math
160 <td class="X Sc">currency
161 <td class="X No">numeric
162 <td class="X Greek">greek
163 <td class="X Cyrillic">cyrillic
164 <td class="X Latin">latin
165 <td class="X Hebrew">hebrew
166 <td class="X Arabic">arabic
167 <td class="X Hangul">korean
168 <td class="X Hiragana">japanese
169 <td class="X Bopomofo">chinese
172 <table class="glyphs"><tr><:
173 print qq(\n\t<td class="X u-$_">$di->{flag}->{$_})
174 for sort keys %{ $di->{flag} };