Diff for /loncom/interface/entities.pm between versions 1.9 and 1.12

version 1.9, 2008/04/28 10:33:35 version 1.12, 2008/10/10 10:16:53
Line 711  my %entities = ( Line 711  my %entities = (
     8733     => '\ensuremath{\propto}',      8733     => '\ensuremath{\propto}',
     'infin'  => '\ensuremath{\infty}',      'infin'  => '\ensuremath{\infty}',
     8734     => '\ensuremath{\infty}',      8734     => '\ensuremath{\infty}',
   #
   #   The items below require the isoent latex package which I can't find at least for FC5.
   #   Temporarily commented out.
   #
 #    'ang90'  => '\ensuremath{\sqangle}',  #    'ang90'  => '\ensuremath{\sqangle}',
 #    8735     => '\ensuremath{\sqangle}',  #    8735     => '\ensuremath{\sqangle}',
     'ang'    => '\ensuremath{\angle}',      'ang'    => '\ensuremath{\angle}',
Line 921  my %entities = ( Line 925  my %entities = (
           
 );  );
   
   #  There are some named entities that don't have a good
   #  latex equivalent, these are converted to utf-8 via this table
   #  of entity name -> unicode number.
   
   my  %utf_table = (
       'THORN'  => 222,
       'thorn'  => 254,
       'eth'    => 240,
       'hearts' => 9829
   );
   
 #   # 
 #  Convert a numerical entity (that does not exist in our hash)  #  Convert a numerical entity (that does not exist in our hash)
 #  to its UTF-8 equivalent representation.  #  to its UTF-8 equivalent representation.
Line 935  my %entities = ( Line 950  my %entities = (
 #  #
 sub entity_to_utf8 {  sub entity_to_utf8 {
     my ($unicode) = @_;      my ($unicode) = @_;
       my $result =  pack("U", $unicode);
     return pack("U", $unicode);      return $result;
 }  }
   
   
Line 964  sub entity_to_latex { Line 979  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"};      my $latex = $entities{"$entity"};
     if (defined $latex) {      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:
       # Otherwise there are a few textual entities that don't have good latex
     if ($entity =~ /^\d$/) {      # which can be converted to unicode:
       #
       if ($entity =~ /^\d+$/) {
  return &entity_to_utf8($entity);   return &entity_to_utf8($entity);
       } else {
    my $result = $utf_table{"$entity"};
    if (defined $result) {
       return &entity_to_utf8($result);
    }
     }      }
     #  Can't do the conversion`< ...      #  Can't do the conversion`< ...
   
Line 1009  sub replace_entities { Line 1032  sub replace_entities {
  $latex = &entity_to_latex($entity);   $latex = &entity_to_latex($entity);
  substr($input, $start, $end-$start) = $latex;   substr($input, $start, $end-$start) = $latex;
     }      }
   
       # Hexadecimal entities:
   
       while ($input =~ /&\#x(\d|[a-f,A-f])+;/) {
    ($start) = @-;
    ($end)   = @+;
    $entity  = "0" . substr($input, $start+2, $end-$start-3); # 0xhexnumber
    $latex = &entity_to_latex(hex($entity));
    substr($input, $start, $end-$start) = $latex;
       }
   
   
     # Now the &text; entites;      # Now the &text; entites;
           
     while ($input =~/(&\w+;)/) {      while ($input =~/(&\w+;)/) {

Removed from v.1.9  
changed lines
  Added in v.1.12


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