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 [qw{! " % ' ( ) * + , - . /}],
37 ['0'..'9'], [qw{: ; < = > ?}],
38 ['A'..'M'], ['N'..'Z'],
39 ['a'..'m'], ['n'..'z'],
41 my @chars2 = (['_'], @chars); # trailing character (extended set)
42 my @columns = !exists $get{split} ? \@chars2 :
43 ([@chars2[0, 1, 3, 4, 6]], [@chars2[2, 5, 7]]);
45 if (exists $get{xorg}) {
46 my $xorg = do 'data/digraphs-xorg.inc.pl'
47 or die "Error loading Xorg data: ", $@ // $!;
48 $_ = [ord $_] for values %{$xorg};
49 $xorg->{$_}->[2] = # class = compatibility
50 $di->{$_} ? $di->{$_}->[0] != $xorg->{$_}->[0] ? 'l1' : # conflict
51 $di->{$_}->[2] =~ /\bu-di\b/ ? 'l5' : 'l3' : 'l2' # rfc|any|none
54 for my $cp (map {$_->[0]} values %{$xorg}) {
55 next if (state $seen = {})->{$cp}++; # List::MoreUtils::uniq
57 # find multiple equivalent mnemonics
58 my @equiv = grep {$cp eq $_->[0]}
59 map {$xorg->{$_}} sort keys %{$xorg}; # values ordered by mnem.
61 # search for the most compatible match
63 $equiv[$b]->[2] cmp $equiv[$a]->[2] # highest level
64 || $b <=> $a # fallback to last mnemonic
67 # reclassify all but one as level 0 (omitted)
68 splice @equiv, $compat // -1, 1, ();
69 $_->[2] = 'l0 ex' for @equiv;
72 $chars2[0] = [qw( # ^ _ ` ~ )];
77 for my $colchars (@columns) {
78 print '<table class="glyphs dimap"><col>';
79 print qq'<colgroup span="$_">' for map {scalar @$_} @{$colchars};
80 print "</colgroup><col>\n";
81 for my $section (qw{thead tfoot}) {
82 print "<$section><tr><th>↳";
83 print '<th>', EscapeHTML($_) for map {@$_} @{$colchars};
86 for my $c1group (@chars) {
88 for my $c1 (@$c1group) {
89 print '<tr><th>', EscapeHTML($c1);
90 for my $c2 (map {@$_} @$colchars) {
92 if (not defined $di->{$mnem}) {
96 if (ref $di->{$mnem} ne 'ARRAY') {
97 printf '<td class="X Xr" title="%s">', EscapeHTML($mnem);
100 my ($codepoint, $name, $prop, $script, $string) = @{ $di->{$mnem} };
102 my $glyph = $string || chr $codepoint;
103 utf8::upgrade($glyph); # prevent latin1 output
104 my $desc = $mnem . ($name && " ($name)");
105 my @class = ('X', grep {$_} $prop, $script);
107 $glyph = EscapeHTML($glyph);
108 $glyph = "<span>$glyph</span>" if $script =~ /\bZs\b/;
110 printf "\n".'<td class="%s" title="%s">%s',
111 join(' ', @class), EscapeHTML($desc), $glyph;
113 print "\n<th>", EscapeHTML($c1), "\n";
117 print '<hr>' if exists $get{split};
121 <table class="glyphs"><tr>
122 <td class="X Cc">control
123 <td class="X Zs"><span>space</span>
124 <td class="X Mn">combining
125 <td class="X Sk">spacing modifier
126 <td class="X Pf">quote
127 <td class="X Po">punctuation
128 <td class="X So">symbol
129 <td class="X Sm">math
130 <td class="X Sc">currency
131 <td class="X No">numeric
132 <td class="X Greek">greek
133 <td class="X Cyrillic">cyrillic
134 <td class="X Latin">latin
135 <td class="X Hebrew">hebrew
136 <td class="X Arabic">arabic
137 <td class="X Hangul">korean
138 <td class="X Hiragana">japanese
139 <td class="X Bopomofo">chinese
142 <table class="glyphs"><tr>
143 <td class="X">unicode
144 <td class="X Xl">latin1
145 <td class="X Xa">ascii
146 <td class="X u-prop">vim extension
147 <td class="X u-prop ex">proposal
148 <td class="X ex">not in vim