Diff for /loncom/interface/entities.pm between versions 1.5 and 1.7

version 1.5, 2008/04/09 10:24:32 version 1.7, 2008/04/15 10:10:10
Line 61  use strict; Line 61  use strict;
   
 #  Note numerical entities are essentially unicode character codes.  #  Note numerical entities are essentially unicode character codes.
 #  #
 my %entities = {  package Apache::entities;
   
   my %entities = (
   
     #  ---- ASCII code page: ----------------      #  ---- ASCII code page: ----------------
   
Line 181  my %entities = { Line 183  my %entities = {
     130     => ',',      130     => ',',
     131     => '\\textflorin ',      131     => '\\textflorin ',
     132     => ',,', # Low double left quotes.      132     => ',,', # Low double left quotes.
     133     => '\\ensuremat\{\\ldots\}',      133     => '\\ensuremath\{\\ldots\}',
     134     => '\\ensuremath\{\\dagger\}',      134     => '\\ensuremath\{\\dagger\}',
     135     => '\\ensuremath\{\\ddagger\}',      135     => '\\ensuremath\{\\ddagger\}',
     136     => '\\ensuremath\{\\wedge\}',      136     => '\\ensuremath\{\\wedge\}',
Line 922  my %entities = { Line 924  my %entities = {
     'diams'  => '\\ensuremath\{\\blacklozenge\}',      'diams'  => '\\ensuremath\{\\blacklozenge\}',
     9830     => '\\ensuremath\{\\blacklozenge\}'      9830     => '\\ensuremath\{\\blacklozenge\}'
           
 };  );
   
 #   # 
 #  Convert a numerical entity (that does not exist in our hash)  #  Convert a numerical entity (that does not exist in our hash)
Line 966  sub entity_to_latex { Line 968  sub entity_to_latex {
   
     # Try to look up the entity (text or numeric) in the hash:      # Try to look up the entity (text or numeric) in the hash:
   
     my $latex = $entities{$entity};  
     if ($latex) {      my $latex = $entities{"$entity"};
       if (defined $latex) {
  return $latex;   return $latex;
     }      }
     # If the text is purely numeric we can do the UTF-8 conversion:      # If the text is purely numeric we can do the UTF-8 conversion:
Line 975  sub entity_to_latex { Line 978  sub entity_to_latex {
     if ($entity =~ /^\d$/) {      if ($entity =~ /^\d$/) {
  return &entity_to_utf8($entity);   return &entity_to_utf8($entity);
     }      }
     #  Can't do the conversion ...      #  Can't do the conversion`< ...
   
     return " ";      return " ";
 }  }
Line 997  sub entity_to_latex { Line 1000  sub entity_to_latex {
 #  #
 sub replace_entities {  sub replace_entities {
     my ($input)  = @_;      my ($input)  = @_;
       my $start;
       my $end;
       my $entity;
       my $latex;
       
       # First the &#nnn; entities:
   
       while ($input =~ /(&\#\d+;)/) {
    ($start) = @-;
    ($end)   = @+;
    $entity  = substr($input, $start+2, $end-$start-3);
    $latex = &entity_to_latex($entity);
    substr($input, $start, $end-$start) = $latex;
       }
       # Now the &text; entites;
       
       while ($input =~/(&\w+;)/) {
    ($start) = @-;
    ($end)   = @+;
    $entity   = substr($input, $start+1, $end-$start-2);
    $latex    = &entity_to_latex($entity);
    substr($input, $start, $end-$start) = $latex;
   
      }
       return $input;
 }  }
   
   1; 
   
   __END__

Removed from v.1.5  
changed lines
  Added in v.1.7


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>