[LON-CAPA-cvs] cvs: loncom /interface entities.pm

foxr lon-capa-cvs-allow@mail.lon-capa.org
Tue, 15 Apr 2008 10:10:13 -0000


foxr		Tue Apr 15 06:10:13 2008 EDT

  Modified files:              
    /loncom/interface	entities.pm 
  Log:
  Correct errors in code logic and table.
  
  
Index: loncom/interface/entities.pm
diff -u loncom/interface/entities.pm:1.6 loncom/interface/entities.pm:1.7
--- loncom/interface/entities.pm:1.6	Mon Apr 14 05:33:39 2008
+++ loncom/interface/entities.pm	Tue Apr 15 06:10:10 2008
@@ -61,7 +61,9 @@
 
 #  Note numerical entities are essentially unicode character codes.
 #
-my %entities = {
+package Apache::entities;
+
+my %entities = (
 
     #  ---- ASCII code page: ----------------
 
@@ -181,7 +183,7 @@
     130     => ',',
     131     => '\\textflorin ',
     132     => ',,',		# Low double left quotes.
-    133     => '\\ensuremat\{\\ldots\}',
+    133     => '\\ensuremath\{\\ldots\}',
     134     => '\\ensuremath\{\\dagger\}',
     135     => '\\ensuremath\{\\ddagger\}',
     136     => '\\ensuremath\{\\wedge\}',
@@ -922,7 +924,7 @@
     'diams'  => '\\ensuremath\{\\blacklozenge\}',
     9830     => '\\ensuremath\{\\blacklozenge\}'
     
-};
+);
 
 # 
 #  Convert a numerical entity (that does not exist in our hash)
@@ -966,8 +968,9 @@
 
     # 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;
     }
     # If the text is purely numeric we can do the UTF-8 conversion:
@@ -975,7 +978,7 @@
     if ($entity =~ /^\d$/) {
 	return &entity_to_utf8($entity);
     }
-    #  Can't do the conversion ...
+    #  Can't do the conversion`< ...
 
     return " ";
 }
@@ -1013,12 +1016,17 @@
     }
     # 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;
+    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__