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

foxr lon-capa-cvs@mail.lon-capa.org
Sat, 04 Feb 2006 22:11:42 -0000


foxr		Sat Feb  4 17:11:42 2006 EDT

  Modified files:              
    /loncom/xml	londefdef.pm lonxml.pm 
  Log:
  defect 4520: When printing a <pre></pre> section latex symbol substitution
  must be turned off or else output can look funny e.g.
  %  -> \%  <  -> \ensuremath{<} etc.
   ----------------------------------------------------------------------
  
  
Index: loncom/xml/londefdef.pm
diff -u loncom/xml/londefdef.pm:1.317 loncom/xml/londefdef.pm:1.318
--- loncom/xml/londefdef.pm:1.317	Fri Jan 27 18:56:55 2006
+++ loncom/xml/londefdef.pm	Sat Feb  4 17:11:42 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Tags Default Definition Module 
 #
-# $Id: londefdef.pm,v 1.317 2006/01/27 23:56:55 albertel Exp $
+# $Id: londefdef.pm,v 1.318 2006/02/04 22:11:42 foxr Exp $
 # 
 #
 # Copyright Michigan State University Board of Trustees
@@ -3179,6 +3179,7 @@
 	$currentstring .= $token->[4];
     } elsif ($target eq 'tex') {
 	$currentstring .= '\begin{verbatim}';
+	&Apache::lonxml::disable_LaTeX_substitutions;
     } 
     return $currentstring;
 }
@@ -3190,6 +3191,7 @@
 	$currentstring .= $token->[2];
     } elsif ($target eq 'tex') {
 	$currentstring .= '\end{verbatim}';
+	&Apache::lonxml::enable_LaTeX_substitutions;
     }
     return $currentstring;
 }
Index: loncom/xml/lonxml.pm
diff -u loncom/xml/lonxml.pm:1.395 loncom/xml/lonxml.pm:1.396
--- loncom/xml/lonxml.pm:1.395	Fri Jan 13 05:33:25 2006
+++ loncom/xml/lonxml.pm	Sat Feb  4 17:11:42 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # XML Parser Module 
 #
-# $Id: lonxml.pm,v 1.395 2006/01/13 10:33:25 albertel Exp $
+# $Id: lonxml.pm,v 1.396 2006/02/04 22:11:42 foxr Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -149,6 +149,19 @@
 #a header message to emit in the case of any generated warning or errors
 $Apache::lonxml::warnings_error_header='';
 
+#  Control whether or not LaTeX symbols should be substituted for their
+#  \ style equivalents...this may be turned off e.g. in an verbatim
+#  environment.
+
+$Apache::lonxml::substitute_LaTeX_symbols = 1; # Starts out on.
+
+sub enable_LaTeX_substitutions {
+    $Apache::lonxml::substitute_LaTeX_symbols = 1;
+}
+sub disable_LaTeX_substitutions {
+    $Apache::lonxml::substitute_LaTeX_symbols = 0;
+}
+
 sub xmlbegin {
     my ($style)=@_;
     my $output='';
@@ -382,6 +395,13 @@
 
 sub latex_special_symbols {
     my ($string,$where)=@_;
+    #
+    #  If e.g. in verbatim mode, then don't substitute.
+    #  but return original string.
+    #
+    if (!($Apache::lonxml::substitute_LaTeX_symbols)) {
+	return $string;
+    }
     if ($where eq 'header') {
 	$string =~ s/(\\|_|\^)/ /g;
 	$string =~ s/(\$|%|\{|\})/\\$1/g;