formatchar: common &; optional for html entity annotation
[sheet.git] / Shiar_Sheet / FormatChar.pm
index 647280e8b878bca433512dad57c2e9d062bd44df..62f6791ba9f1e1d72332c87b30cc56b498d7dfe0 100644 (file)
@@ -109,7 +109,27 @@ sub cell {
 
        my $anno = '';
        for (@{ $self->{anno} }) {
-               if ($_ eq 'di') {
+               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') {
+                       $anno = sprintf(' <small class="digraph">%s</small>',
+                               sprintf '#%d', ord($cell)
+                       );
+                       last;
+               }
+               elsif ($_ eq '&xml') {
+                       $anno = sprintf(' <small class="digraph">%s</small>',
+                               sprintf '&amp;#%d;', ord($cell)
+                       );
+                       last;
+               }
+               elsif ($_ eq 'di') {
                        if (defined $mnem and length $mnem) {
                                $anno = sprintf(' <small class="digraph">%s</small>', EscapeHTML($mnem));
                                last;