5 title => 'digraph cheat sheet',
8 "Complete table of digraph characters from RFC-1345.",
11 digraph mnemonic compose composition pair
12 character char glyph table unicode vim
14 stylesheet => [qw'light'],
15 data => [qw( digraphs.inc.pl )],
19 <h1>RFC-1345 Digraphs</h1>
21 <p>Character mnemonics
22 following composition key ⎄:
23 i^k in <a href="/vi">Vim</a>,
24 ^u^\ in <a href="/readline">Emacs</a>,
25 ^a^v in <a href="/screen">Screen</a>.
26 Also see <a href="/unicode">common Unicode</a>.</p>
28 <p class="aside">Unofficial <span class="u-prop ex">proposals</span>
29 are available as <a href="/digraphs.vim">ex commands</a>.</p>
32 my $di = do 'digraphs.inc.pl'
33 or die "Error loading digraphs data: ", $@ // $!;
36 # show characters for inverted mnemonics (vim alternatives)
37 $di->{ substr($_, 1, 1) . substr($_, 0, 1) } ||=
38 [ $di->{$_}->[0], '', 'l0 ex', '', $di->{$_}->[4] ]
39 for grep { ref $di->{$_} } keys %{$di};
43 [qw{! " % ' ( ) * + , - . /}],
44 ['0'..'9'], [qw{: ; < = > ?}],
45 ['A'..'M'], ['N'..'Z'],
46 ['a'..'m'], ['n'..'z'],
48 my @chars2 = (['_'], @chars); # trailing character (extended set)
49 my @columns = !exists $get{split} ? \@chars2 :
50 ([@chars2[0, 1, 3, 4, 6]], [@chars2[2, 5, 7]]);
52 if (exists $get{xorg}) {
53 my $xorg = do 'data/digraphs-xorg.inc.pl'
54 or die "Error loading Xorg data: ", $@ // $!;
55 $_ = [ord $_] for values %{$xorg};
56 $xorg->{$_}->[2] = # class = compatibility
57 $di->{$_} ? $di->{$_}->[0] != $xorg->{$_}->[0] ? 'l1' : # conflict
58 $di->{$_}->[2] =~ /\bu-di\b/ ? 'l5' : 'l3' : 'l2' # rfc|any|none
61 for my $cp (map {$_->[0]} values %{$xorg}) {
62 next if (state $seen = {})->{$cp}++; # List::MoreUtils::uniq
64 # find multiple equivalent mnemonics
65 my @equiv = grep {$cp eq $_->[0]}
66 map {$xorg->{$_}} sort keys %{$xorg}; # values ordered by mnem.
68 # search for the most compatible match
70 $equiv[$b]->[2] cmp $equiv[$a]->[2] # highest level
71 || $b <=> $a # fallback to last mnemonic
74 # reclassify all but one as level 0 (omitted)
75 splice @equiv, $compat // -1, 1, ();
76 $_->[2] = 'l0 ex' for @equiv;
79 $chars2[0] = [qw( # ^ _ ` ~ )];
84 for my $colchars (@columns) {
85 print '<table class="glyphs dimap"><col>';
86 print qq'<colgroup span="$_">' for map {scalar @$_} @{$colchars};
87 print "</colgroup><col>\n";
88 for my $section (qw{thead tfoot}) {
89 print "<$section><tr><th>↳";
90 print '<th>', EscapeHTML($_) for map {@$_} @{$colchars};
93 for my $c1group (@chars) {
95 for my $c1 (@$c1group) {
96 print '<tr><th>', EscapeHTML($c1);
97 for my $c2 (map {@$_} @$colchars) {
99 if (not defined $di->{$mnem}) {
103 if (ref $di->{$mnem} ne 'ARRAY') {
104 printf '<td class="X Xr" title="%s">', EscapeHTML($mnem);
107 my ($codepoint, $name, $prop, $script, $string) = @{ $di->{$mnem} };
109 my $glyph = $string || chr $codepoint;
110 utf8::upgrade($glyph); # prevent latin1 output
111 my $desc = $mnem . ($name && " ($name)");
112 my @class = ('X', grep {$_} $prop, $script);
114 $glyph = EscapeHTML($glyph);
115 $glyph = "<span>$glyph</span>" if $script =~ /\bZs\b/;
117 printf "\n".'<td class="%s" title="%s">%s',
118 join(' ', @class), EscapeHTML($desc), $glyph;
120 print "\n<th>", EscapeHTML($c1), "\n";
124 print '<hr>' if exists $get{split};
127 if (exists $get{xorg}) {
130 <table class="glyphs"><tr>
131 <td class="X l5">matching RFC-1345
132 <td class="X l3">matching proposal
133 <td class="X l2">unique to Xorg
134 <td class="X l1">conflict
135 <td class="X l0 ex">duplicate
140 <table class="glyphs"><tr>
141 <td class="X Cc">control
142 <td class="X Zs"><span>space</span>
143 <td class="X Mn">combining
144 <td class="X Sk">spacing modifier
145 <td class="X Pf">quote
146 <td class="X Po">punctuation
147 <td class="X So">symbol
148 <td class="X Sm">math
149 <td class="X Sc">currency
150 <td class="X No">numeric
151 <td class="X Greek">greek
152 <td class="X Cyrillic">cyrillic
153 <td class="X Latin">latin
154 <td class="X Hebrew">hebrew
155 <td class="X Arabic">arabic
156 <td class="X Hangul">korean
157 <td class="X Hiragana">japanese
158 <td class="X Bopomofo">chinese
161 <table class="glyphs"><tr>
162 <td class="X">unicode
163 <td class="X Xl">latin1
164 <td class="X Xa">ascii
165 <td class="X u-prop">vim extension
166 <td class="X u-prop ex">proposal
167 <td class="X ex">not in vim