[LON-CAPA-cvs] cvs: loncom /xml lonxml.pm

albertel lon-capa-cvs@mail.lon-capa.org
Fri, 19 Mar 2004 22:01:13 -0000


albertel		Fri Mar 19 17:01:13 2004 EDT

  Modified files:              
    /loncom/xml	lonxml.pm 
  Log:
  - Fixes the order in which things get escaped, with the old order things like ° broke
    now it 
     a) escapes individually the special characters except for & and #
     b) converts HTML entity references to correct TeX
     c) escapes any & or # that aren't preceded by \
   
  
  
Index: loncom/xml/lonxml.pm
diff -u loncom/xml/lonxml.pm:1.310 loncom/xml/lonxml.pm:1.311
--- loncom/xml/lonxml.pm:1.310	Fri Mar 12 12:26:29 2004
+++ loncom/xml/lonxml.pm	Fri Mar 19 17:01:13 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # XML Parser Module 
 #
-# $Id: lonxml.pm,v 1.310 2004/03/12 17:26:29 sakharuk Exp $
+# $Id: lonxml.pm,v 1.311 2004/03/19 22:01:13 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -401,17 +401,23 @@
     my ($string,$where)=@_;
     if ($where eq 'header') {
 	$string =~ s/(\\|_|\^)/ /g;
-	$string =~ s/(\$|%|\#|&|\{|\})/\\$1/g;
+	$string =~ s/(\$|%|\{|\})/\\$1/g;
 	$string =~ s/_/ /g;
+	$string=&Apache::lonprintout::character_chart($string);
+	# any & or # leftover should be safe to just escape
+        $string=~s/([^\\])\&/$1\\\&/g;
+        $string=~s/([^\\])\#/$1\\\#/g;
     } else {
 	$string=~s/([^\\])\%/$1\\\%/g;
 	$string=~s/([^\\])(\$|_)/$1\\$2/g;
 	$string=~s/\$\$/\$\\\$/g;
-        $string=~s/([^\\])\&/$1\\\&/g;
-        $string=~s/([^\\])\#/$1\\\#/g;
 	$string=~s/\#\#/\#\\\#/g;
         $string=~s/([^\\])(\~|\^)/$1\\$2\\strut /g;
 	$string=~s/(>|<)/\\ensuremath\{$1\}/g; #more or less
+	$string=&Apache::lonprintout::character_chart($string);
+	# any & or # leftover should be safe to just escape
+        $string=~s/([^\\])\&/$1\\\&/g;
+        $string=~s/([^\\])\#/$1\\\#/g;
 #single { or } How to escape?
     }
     return $string;
@@ -506,7 +512,7 @@
       if (($token->[0] eq 'T') || ($token->[0] eq 'C') || ($token->[0] eq 'D') ) {
 	  #Style file definitions should be correct
 	  if ($target eq 'tex' && ($Apache::lonxml::usestyle)) {
-	      $result=&latex_special_symbols(&Apache::lonprintout::character_chart($result));
+	      $result=&latex_special_symbols($result);
 	  }
       }
 
@@ -746,6 +752,7 @@
   $safehole->wrap(\&Math::Random::random_get_seed,$safeeval,'&random_get_seed');
   $safehole->wrap(\&Math::Random::random_set_seed,$safeeval,'&random_set_seed');
   $safehole->wrap(\&Apache::lonxml::error,$safeeval,'&LONCAPA_INTERNAL_ERROR');
+  $safehole->wrap(\&Apache::lonxml::debug,$safeeval,'&LONCAPA_INTERNAL_DEBUG');
 
 #need to inspect this class of ops
 # $safeeval->deny(":base_orig");