3 my $mode = $Request || 'vim';
4 my $include = 'digraphs' . ($mode ne 'vim' && "-$mode");
5 my $cmp = exists $get{cmp} ? ($get{cmp} // 1) : !!$Request;
7 my $di = eval { Data($include) } || {};
8 warn "error in $include: ", @{$@} if ref $@;
11 title => "$mode digraph cheat sheet",
13 description => $di->{description} // [
14 "Complete table of digraph characters from",
15 ($di->{title} // $mode) . ".",
17 keywords => [@{ $di->{keywords} // [] }, qw'
18 digraph mnemonic compose composition pair
19 character char glyph table unicode vim
21 stylesheet => [qw'light'],
22 data => ["data/$include.json"],
26 "Requested digraphs <q>$mode</q> not available",
27 '404 request not found',
30 say "<h1>$di->{title} Digraphs</h1>";
31 say "<p>$_</p>" for $di->{intro} // ();
34 # show characters for inverted mnemonics (vim alternatives)
35 $di->{key}->{ substr($_, 1, 1) . substr($_, 0, 1) } ||= [
36 $di->{key}->{$_}->[0], '', 'l0 ex', '', $di->{key}->{$_}->[4]
37 ] for grep { ref $di->{key}->{$_} } keys %{ $di->{key} };
41 [qw{! " % ' ( ) * + , - . /}],
42 ['0'..'9'], [qw{: ; < = > ?}],
43 ['A'..'M'], ['N'..'Z'],
44 ['a'..'m'], ['n'..'z'],
46 my @chars2 = (['_'], @chars); # trailing character (extended set)
47 my @columns = !exists $get{split} ? \@chars2 :
48 ([@chars2[0, 1, 3, 4, 6]], [@chars2[2, 5, 7]]);
50 if ($mode eq 'xorg') {
51 #TODO determine character usage from declared keys
52 $chars2[0] = [qw( # ^ _ ` ~ )];
56 for my $colchars (@columns) {
57 print '<table class="glyphs dimap"><col>';
58 print qq'<colgroup span="$_">' for map {scalar @$_} @{$colchars};
59 say '</colgroup><col>';
60 for my $section (qw{thead tfoot}) {
61 print "<$section><tr><th>↳";
62 print '<th>', EscapeHTML($_) for map {@$_} @{$colchars};
65 for my $c1group (@chars) {
67 for my $c1 (@$c1group) {
68 print '<tr><th>', EscapeHTML($c1);
69 for my $c2 (map {@$_} @$colchars) {
71 if (not defined $di->{key}->{$mnem}) {
75 if (ref $di->{key}->{$mnem} ne 'ARRAY') {
76 printf '<td class="X Xr" title="%s">', EscapeHTML($mnem);
79 my ($codepoint, $name, $support, $script, $string) =
80 @{ $di->{key}->{$mnem} };
82 my $glyph = $string || !!$codepoint && chr $codepoint;
83 utf8::upgrade($glyph); # prevent latin1 output
84 my $desc = $mnem . ($name && " ($name)");
85 my @class = ('X', grep {$_} $script);
86 push @class, $cmp ? $support :
87 $di->{flagclass}->{$support} // "u-$support" if $support;
89 $glyph = EscapeHTML($glyph);
90 $glyph = "<span>$glyph</span>" if $script =~ /\bZs\b/;
92 printf "\n".'<td class="%s" title="%s">%s',
93 join(' ', @class), EscapeHTML($desc), $glyph;
95 say "\n<th>", EscapeHTML($c1);
99 print '<hr>' if exists $get{split};
103 <div class="legend"><: unless ($cmp) { :>
104 <table class="glyphs"><tr>
105 <td class="X Cc">control
106 <td class="X Zs"><span>space</span>
107 <td class="X Mn">combining
108 <td class="X Sk">spacing modifier
109 <td class="X Pf">quote
110 <td class="X Po">punctuation
111 <td class="X So">symbol
112 <td class="X Sm">math
113 <td class="X Sc">currency
114 <td class="X No">numeric
115 <td class="X Greek">greek
116 <td class="X Cyrillic">cyrillic
117 <td class="X Latin">latin
118 <td class="X Hebrew">hebrew
119 <td class="X Arabic">arabic
120 <td class="X Hangul">korean
121 <td class="X Hiragana">japanese
122 <td class="X Bopomofo">chinese
125 <table class="glyphs"><tr><:
126 printf qq(\n\t<td class="X %s">%s), $cmp ? $_ : $di->{flagclass}{$_} // "u-$_", $di->{flag}->{$_}
127 for sort keys %{ $di->{flag} };