-my $diinfo = do 'digraphs.inc.pl';
-my %di = map { $diinfo->{$_}->[0] => $_ } grep { ref $diinfo->{$_} }
- sort { length $a <=> length $b } keys %$diinfo;
-
-sub glyph_table {
- my ($digraphs) = @_;
-
- my @rows;
-
- my @colheads;
- while ($digraphs->[0] !~ /^\./) {
- my $cell = shift @$digraphs or last;
- push @colheads, sprintf(
- '<%s%s>%s',
- $cell =~ s/^-// ? 'td' : 'th',
- $cell =~ s/:(.*)// ? qq{ title="$1"} : '',
- $cell eq '_' ? ' ' : $cell
- );
- }
- push @rows, sprintf '<thead><tr>%s<tbody>', join '', @colheads if @colheads;
-
- my $colspan = 1;
- for my $cell (@$digraphs) {
- if ($cell =~ s/^\.//) {
- # dot indicates start of a new row
- push @rows, '';
- if ($cell =~ s/^>//) {
- # header cell text follows
- $cell =~ s/_/ /g; # underscores may be used instead of whitespace (for qw//ability)
- $rows[-1] .= '<th>'.($cell || ' ');
- }
- next;
- }
- elsif ($cell eq '>') {
- # merge this cell to the next column
- $colspan++;
- next;
- }
-
- my ($code, $name);
-
- # determine display class
- my @class;
- if ($cell eq '-') {
- $cell = '';
- }
- elsif ($cell eq '=') {
- push @class, 'di-invalid';
- $cell = '';
- }
- else {
- if ($cell =~ s/^-//) {
- push @class, 'di-rare'; # discouraged
- }
-
- $code = join '', map { $di{ord $_} || '' } split //, $cell;
- $name = $diinfo->{$code}->[1];
- length $code == 2 or undef $code;
-
- if (defined $code) {
- push @class, 'di-d'; # digraph
- push @class, 'di-prop' # unofficial
- if $diinfo->{$code}->[2] =~ /\bXz\b/;
- }
- elsif (defined $name) {
- push @class, 'X';
- }