-
-sub table {
- my ($width, $digraphs, $rowheads, $colheads) = @_;
-
- my @rows;
-
- my $colspan = 1;
- for my $cell (@$digraphs) {
- my $class;
- if ($cell eq '.') {
- push @rows, '';
- $rows[-1] .= '<th>'.(shift @$rowheads || ' ') if $rowheads;
- next;
- }
- elsif ($cell eq '>') {
- $colspan++;
- next;
- }
-
- my $code = join '', map { $di{ord $_} || '' } split //, $cell;
- my $name = $diinfo->{$code}->[1];
-
- if ($cell =~ s/^-//) {
-# $class = 'Empty';
- }
- elsif ($cell eq '=') {
- $class = 'Reserved';
- $cell = '';
- }
- elsif ($cell =~ /[ -~]/) {
- $class = 'Ascii';
- }
- elsif (not $code) {
- $class = 'DiNone';
- }
- elsif ($diinfo->{$code}->[2] =~ /\bXz\b/) {
- $class = 'DiProp';
- }
- else {
- $class = 'Di';
- }
-
- $rows[-1] .= sprintf('<td%s%s%s>%s%s',
- defined $name ? qq{ title="$name"} : '',
- defined $class ? qq{ class="$class"} : '',
- $colspan > 1 && qq{ colspan="$colspan"},
- $cell eq '' ? ' ' : quote($cell),
- $code ne '' ? sprintf(' <small class="digraph">%s</small>', quote($code))
- : length($cell) == 1 && $cell !~ /[a-z]/
- ? sprintf(' <small class="%s">%04X</small>', 'value', ord $cell)
- : '',
- );
-
- $colspan = 1;
- }
-
- if ($colheads) {
- unshift @rows, sprintf '<thead><tr><td>%s<tbody>', join '',
- map { sprintf '<th title="%2$s">%s', split(/:/, $_, 2), '', '' }
- @$colheads
- }
-
- return sprintf qq{<table class="glyphs dilabel">\n%s</table>\n},
- join '', map {"<tr>$_\n"} @rows;