X-Git-Url: http://git.shiar.nl/sheet.git/blobdiff_plain/9cabbcb99510ce7c9256d085d1c9de6c0b5fc8ce..082d363b562650988d2d57c73497801a4f8794ed:/Shiar_Sheet/FormatChar.pm diff --git a/Shiar_Sheet/FormatChar.pm b/Shiar_Sheet/FormatChar.pm index 647280e..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,18 +109,40 @@ sub cell { } my $anno = ''; - for (@{ $self->{anno} }) { - if ($_ eq 'di') { - if (defined $mnem and length $mnem) { - $anno = sprintf(' %s', EscapeHTML($mnem)); + 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') { + $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; + } + } } }