use Data::Dump 'pp';
use PLP::Functions 'EscapeHTML';
-our $VERSION = '1.04';
+our $VERSION = '1.05';
our $diinfo = do 'digraphs.inc.pl';
our %di = map { $diinfo->{$_}->[0] => $_ } grep { ref $diinfo->{$_} }
push @class, 'ex'; # discouraged
}
+ $input =~ s/^\\//; # escaped char
($cell, $title, my $class, $mnem) = $self->glyphs_html($input);
if ($self->{style} = 'di') {
}
my $anno = '';
- for (@{ $self->{anno} }) {
- if ($_ eq 'html') {
- require HTML::Entities;
- if (my $_ = $HTML::Entities::char2entity{$cell}) {
- $anno = sprintf(' <small class="digraph">%s</small>', EscapeHTML($_));
- last;
+ if ($cell ne '') {
+ for (@{ $self->{anno} }) {
+ if (/html$/) {
+ require HTML::Entities;
+ if (my $entity = $HTML::Entities::char2entity{$cell}) {
+ $entity = substr($entity, 1, -1) unless /^&/;
+ $anno = sprintf(' <small class="digraph">%s</small>', EscapeHTML($entity));
+ last;
+ }
}
- }
- elsif ($_ eq 'xml') {
- require HTML::Entities;
- $anno = sprintf(' <small class="digraph">%s</small>',
- sprintf "&#%d;", ord($cell)
- );
- last;
- }
- elsif ($_ eq 'di') {
- if (defined $mnem and length $mnem) {
- $anno = sprintf(' <small class="digraph">%s</small>', EscapeHTML($mnem));
+ elsif ($_ eq 'xml') {
+ $anno = sprintf(' <small class="digraph">%s</small>',
+ sprintf '#%d', ord($cell)
+ );
last;
}
- }
- else {
- if ($_ eq 'hex' or $cell =~ /^[^a-zA-Z]$/) {
- $anno = sprintf(' <small class="%s">%04X</small>', 'value', ord $cell);
+ elsif ($_ eq '&xml') {
+ $anno = sprintf(' <small class="digraph">%s</small>',
+ sprintf '&#%d;', ord($cell)
+ );
last;
}
+ elsif ($_ eq 'di') {
+ if (defined $mnem and length $mnem) {
+ $anno = sprintf(' <small class="digraph">%s</small>', EscapeHTML($mnem));
+ last;
+ }
+ }
+ else {
+ if ($_ eq 'hex' or $cell =~ /^[^a-zA-Z]$/) {
+ $anno = sprintf(' <small class="%s">%04X</small>', 'value', ord $cell);
+ last;
+ }
+ }
}
}
sub print {
my $self = shift;
while (@_) {
- printf '<div class="section"><h2>%s</h2>'."\n\n", shift;
+ print '<div class="section">';
+ printf '<h2>%s</h2>', shift unless ref $_[0];
+ print "\n\n";
while (ref $_[0] and $_ = shift) {
print $self->table($_);
}
- print '</div>';
+ print "\n</div>";
}
}