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

foxr lon-capa-cvs-allow@mail.lon-capa.org
Fri, 10 Oct 2008 10:16:53 -0000


foxr		Fri Oct 10 06:16:53 2008 EDT

  Modified files:              
    /loncom/interface	entities.pm 
  Log:
  Get hex entities (of the form &#xnnn; to work properly.
  
  
  
Index: loncom/interface/entities.pm
diff -u loncom/interface/entities.pm:1.11 loncom/interface/entities.pm:1.12
--- loncom/interface/entities.pm:1.11	Mon May  5 06:46:19 2008
+++ loncom/interface/entities.pm	Fri Oct 10 06:16:53 2008
@@ -979,6 +979,7 @@
     # Try to look up the entity (text or numeric) in the hash:
 
 
+
     my $latex = $entities{"$entity"};
     if (defined $latex) {
 	return $latex;
@@ -1031,6 +1032,18 @@
 	$latex = &entity_to_latex($entity);
 	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;
     
     while ($input =~/(&\w+;)/) {