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

sakharuk lon-capa-cvs@mail.lon-capa.org
Fri, 12 Mar 2004 17:26:29 -0000


sakharuk		Fri Mar 12 12:26:29 2004 EDT

  Modified files:              
    /loncom/xml	lonxml.pm 
  Log:
  Cleanup has been done for latex_special_symbols. Now you can print carets, ~, $, $$$, #, ###, %, and ... correctly
  
  
Index: loncom/xml/lonxml.pm
diff -u loncom/xml/lonxml.pm:1.309 loncom/xml/lonxml.pm:1.310
--- loncom/xml/lonxml.pm:1.309	Tue Mar  9 15:37:58 2004
+++ loncom/xml/lonxml.pm	Fri Mar 12 12:26:29 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # XML Parser Module 
 #
-# $Id: lonxml.pm,v 1.309 2004/03/09 20:37:58 albertel Exp $
+# $Id: lonxml.pm,v 1.310 2004/03/12 17:26:29 sakharuk Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -404,20 +404,15 @@
 	$string =~ s/(\$|%|\#|&|\{|\})/\\$1/g;
 	$string =~ s/_/ /g;
     } else {
-	$string=~s/\\ /\\char92 /g;
-	$string=~s/\^/\\\^\\strut /g;
-	$string=~s/\~/\\char126 /g;
-	#fixup & if it doesn't look like
-        # { or α
-	$string=~s/(&(?!((\#[0-9]+)|([a-z][a-z0-9]*));))/\\$1/gi;
-        $string=~s/([^&\\])\#/$1\\#/g;
-	$string=~s/\#\#/\#\\#/g;
-	$string=~s/(\$|_|{|})/\\$1/g;
-	$string=~s/\\char92 /\\texttt{\\char92}/g;
-	$string=~s/(>|<)/\$$1\$/g; #more or less
-	if ($string=~m/\d%/) {$string =~ s/(\d)%/$1\\%/g;} #percent after digit
-	if ($string=~m/\s%/) {$string =~ s/(\s)%/$1\\%/g;} #percent after space
-	if ($string eq '%.') {$string = '\%.';} #percent at the end of statement
+	$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
+#single { or } How to escape?
     }
     return $string;
 }
@@ -511,7 +506,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($result);
+	      $result=&latex_special_symbols(&Apache::lonprintout::character_chart($result));
 	  }
       }