+ 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;
+ }
+ elsif ($cell =~ s/^-//) {
+ $class = 'empty';
+ }
+ elsif ($cell eq '=') {
+ $class = 'reserved';
+ $cell = '';
+ }
+
+ my $code = join '', map { $di{ord $_} || '' } split //, $cell;
+ my $name = $diinfo->{$code}->[1];
+
+ $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 "<table>\n%s</table>\n", join '', map {"<tr>$_\n"} @rows;