3 my $mode = ($Request // '') eq 'xorg' || exists $get{xorg};
4 my $modename = $mode ? 'X.Org' : 'RFC-1345';
5 my $cmp = exists $get{cmp} ? ($get{cmp} // 1) : !!$Request;
8 title => 'digraph cheat sheet',
11 "Complete table of digraph characters from $modename.",
14 digraph mnemonic compose composition pair
15 character char glyph table unicode vim xorg x11 x
17 stylesheet => [qw'light'],
18 data => [qw( data/digraphs.inc.pl )],
22 <h1><:= $modename :> Digraphs</h1>
24 <p>Character mnemonics following compose key ⎄<:
27 ' in the X Window System (Shift+AltGr by default).',
28 'Differences from <a href="/digraphs">RFC-1345</a> are indicated.',
30 'i^k in <a href="/vi">Vim</a>,',
31 '^u^\ in <a href="/readline">Emacs</a>,',
32 '^a^v in <a href="/screen">Screen</a>.',
33 'Similar but different from <a href="/digraphs/xorg">X.Org</a>.',
35 'Also see <a href="/unicode">common Unicode</a>.</p>',
37 say '<p class="aside">Unofficial <span class="u-l2">proposals</span>',
38 ' are available as <a href="/digraphs.vim">ex commands</a>.' if not $mode;
42 my $di = Data('digraphs');
45 # show characters for inverted mnemonics (vim alternatives)
46 $di->{key}->{ substr($_, 1, 1) . substr($_, 0, 1) } ||= [
47 $di->{key}->{$_}->[0], '', 'l0 ex', '', $di->{key}->{$_}->[4]
48 ] for grep { ref $di->{key}->{$_} } keys %{ $di->{key} };
52 [qw{! " % ' ( ) * + , - . /}],
53 ['0'..'9'], [qw{: ; < = > ?}],
54 ['A'..'M'], ['N'..'Z'],
55 ['a'..'m'], ['n'..'z'],
57 my @chars2 = (['_'], @chars); # trailing character (extended set)
58 my @columns = !exists $get{split} ? \@chars2 :
59 ([@chars2[0, 1, 3, 4, 6]], [@chars2[2, 5, 7]]);
62 $di = Data('digraphs-xorg');
63 $chars2[0] = [qw( # ^ _ ` ~ )];
67 for my $colchars (@columns) {
68 print '<table class="glyphs dimap"><col>';
69 print qq'<colgroup span="$_">' for map {scalar @$_} @{$colchars};
70 say '</colgroup><col>';
71 for my $section (qw{thead tfoot}) {
72 print "<$section><tr><th>↳";
73 print '<th>', EscapeHTML($_) for map {@$_} @{$colchars};
76 for my $c1group (@chars) {
78 for my $c1 (@$c1group) {
79 print '<tr><th>', EscapeHTML($c1);
80 for my $c2 (map {@$_} @$colchars) {
82 if (not defined $di->{key}->{$mnem}) {
86 if (ref $di->{key}->{$mnem} ne 'ARRAY') {
87 printf '<td class="X Xr" title="%s">', EscapeHTML($mnem);
90 my ($codepoint, $name, $support, $script, $string) =
91 @{ $di->{key}->{$mnem} };
93 my $glyph = $string || chr $codepoint;
94 utf8::upgrade($glyph); # prevent latin1 output
95 my $desc = $mnem . ($name && " ($name)");
96 my @class = ('X', grep {$_} $script);
97 push @class, $cmp ? $support : "u-$support" if $support;
99 $glyph = EscapeHTML($glyph);
100 $glyph = "<span>$glyph</span>" if $script =~ /\bZs\b/;
102 printf "\n".'<td class="%s" title="%s">%s',
103 join(' ', @class), EscapeHTML($desc), $glyph;
105 say "\n<th>", EscapeHTML($c1);
109 print '<hr>' if exists $get{split};
113 <div class="legend"><: unless ($cmp) { :>
114 <table class="glyphs"><tr>
115 <td class="X Cc">control
116 <td class="X Zs"><span>space</span>
117 <td class="X Mn">combining
118 <td class="X Sk">spacing modifier
119 <td class="X Pf">quote
120 <td class="X Po">punctuation
121 <td class="X So">symbol
122 <td class="X Sm">math
123 <td class="X Sc">currency
124 <td class="X No">numeric
125 <td class="X Greek">greek
126 <td class="X Cyrillic">cyrillic
127 <td class="X Latin">latin
128 <td class="X Hebrew">hebrew
129 <td class="X Arabic">arabic
130 <td class="X Hangul">korean
131 <td class="X Hiragana">japanese
132 <td class="X Bopomofo">chinese
135 <table class="glyphs"><tr><:
136 printf qq(\n\t<td class="X %s">%s), (!$cmp && 'u-').$_, $di->{flag}->{$_}
137 for sort keys %{ $di->{flag} };