X-Git-Url: http://git.shiar.net/sheet.git/blobdiff_plain/96bfc3addc80d99f3b329cbb9ed9674c6f6c89b2..3e8ad856c4abe984396ab41295dcfc61e8d7d5c4:/Shiar_Sheet/FormatChar.pm?ds=sidebyside
diff --git a/Shiar_Sheet/FormatChar.pm b/Shiar_Sheet/FormatChar.pm
index 707fdc6..759ca85 100644
--- a/Shiar_Sheet/FormatChar.pm
+++ b/Shiar_Sheet/FormatChar.pm
@@ -81,6 +81,7 @@ sub cell {
push @class, 'ex'; # discouraged
}
+ $input =~ s/^\\//; # escaped char
($cell, $title, my $class, $mnem) = $self->glyphs_html($input);
if ($self->{style} = 'di') {
@@ -108,32 +109,40 @@ sub cell {
}
my $anno = '';
- for (@{ $self->{anno} }) {
- if ($_ eq 'html') {
- require HTML::Entities;
- if (my $_ = $HTML::Entities::char2entity{$cell}) {
- $anno = sprintf(' %s', 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(' %s', EscapeHTML($entity));
+ last;
+ }
}
- }
- elsif ($_ eq 'xml') {
- require HTML::Entities;
- $anno = sprintf(' %s',
- sprintf "&#%d;", ord($cell)
- );
- last;
- }
- elsif ($_ eq 'di') {
- if (defined $mnem and length $mnem) {
- $anno = sprintf(' %s', EscapeHTML($mnem));
+ elsif ($_ eq 'xml') {
+ $anno = sprintf(' %s',
+ sprintf '#%d', ord($cell)
+ );
last;
}
- }
- else {
- if ($_ eq 'hex' or $cell =~ /^[^a-zA-Z]$/) {
- $anno = sprintf(' %04X', 'value', ord $cell);
+ elsif ($_ eq '&xml') {
+ $anno = sprintf(' %s',
+ sprintf '&#%d;', ord($cell)
+ );
last;
}
+ elsif ($_ eq 'di') {
+ if (defined $mnem and length $mnem) {
+ $anno = sprintf(' %s', EscapeHTML($mnem));
+ last;
+ }
+ }
+ else {
+ if ($_ eq 'hex' or $cell =~ /^[^a-zA-Z]$/) {
+ $anno = sprintf(' %04X', 'value', ord $cell);
+ last;
+ }
+ }
}
}