use Data::Dump 'pp';
use PLP::Functions 'EscapeHTML';
-our $VERSION = '1.00';
+our $VERSION = '1.01';
our $diinfo = do 'digraphs.inc.pl';
our %di = map { $diinfo->{$_}->[0] => $_ } grep { ref $diinfo->{$_} }
sub new {
my ($class) = @_;
- bless {}, $class;
+ bless { digraph => 1, unicode => 0 }, $class;
}
sub glyph_info {
my $title = sprintf 'U+%04X%s', $codepoint, $name && " ($name)";
my @class = ('X', grep {$_} $prop, $script);
- $cell = "<span>$cell</span>" if $prop eq 'Zs';
+ $cell = "<span>$cell</span>" if $prop and $prop eq 'Zs';
$cell = ' ' if $cell eq '';
return ($cell, EscapeHTML($title), join(' ', @class), $mnem);
@class ? sprintf(' class="%s"', join ' ', @class) : '',
$html || '',
$cell eq '' ? ' ' : $cell,
- defined $mnem && length $mnem
+ $self->{digraph} && defined $mnem && length $mnem
? sprintf(' <small class="digraph">%s</small>', EscapeHTML($mnem))
- : $cell =~ /^[^a-zA-Z]$/
+ : $self->{unicode} + $cell =~ /^[^a-zA-Z]$/ > 0
? sprintf(' <small class="%s">%04X</small>', 'value', ord $cell)
: '',
);
$colspan = 1;
}
- return sprintf qq{<table class="glyphs dilabel">\n%s</table>\n},
+ return sprintf qq{<table class="glyphs%s">\n%s</table>\n},
+ $self->{digraph} || $self->{unicode} >= 0 ? ' dilabel' : '',
join '', map {"<tr>$_\n"} @rows;
}
+sub print {
+ my $self = shift;
+ while (@_) {
+ printf '<div class="section"><h2>%s</h2>'."\n\n", shift;
+ while (ref $_[0] and $_ = shift) {
+ print $self->table($_);
+ }
+ print '</div>';
+ }
+}
+
1;