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

albertel lon-capa-cvs@mail.lon-capa.org
Thu, 16 May 2002 00:56:46 -0000


albertel		Wed May 15 20:56:46 2002 EDT

  Modified files:              
    /loncom/xml	londefdef.pm lonxml.pm 
  Log:
  - added global $Apache::lonxml::prevent_entity_encode that turns off the High ASCII -> HTML entity encoding
  - <font>  uses this if the face is set to symbol, and the <m> tag uses thisin web mode
  - should fix BUG#68
  
  
  
Index: loncom/xml/londefdef.pm
diff -u loncom/xml/londefdef.pm:1.60 loncom/xml/londefdef.pm:1.61
--- loncom/xml/londefdef.pm:1.60	Wed May 15 11:21:21 2002
+++ loncom/xml/londefdef.pm	Wed May 15 20:56:46 2002
@@ -2,7 +2,7 @@
 # The LearningOnline Network with CAPA
 # Tags Default Definition Module 
 #
-# $Id: londefdef.pm,v 1.60 2002/05/15 15:21:21 sakharuk Exp $
+# $Id: londefdef.pm,v 1.61 2002/05/16 00:56:46 albertel Exp $
 # 
 #
 # Copyright Michigan State University Board of Trustees
@@ -73,6 +73,7 @@
   my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
   my $currentstring = '';
   if ($target eq 'web') {
+    $Apache::lonxml::prevent_entity_encode++;
     my $inside = &Apache::lonxml::get_all_text("/m",$$parser[-1]);
     $inside ='\\documentstyle{article}'.$inside;
     &Apache::lonxml::debug("M is starting with:$inside:");
@@ -97,6 +98,7 @@
   my ($target,$token) = @_;
   my $currentstring = '';
   if ($target eq 'web') {
+    $Apache::lonxml::prevent_entity_encode--;
   } elsif ($target eq 'tex') {
     $currentstring = "";
   } elsif ($target eq 'meta') {
@@ -921,17 +923,21 @@
       }
 #-- <font> tag
          sub start_font {
-	    my ($target,$token) = @_;
+	    my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
             my $currentstring = '';
             if ($target eq 'web') {
+	      my $face=&Apache::lonxml::get_param('face',$parstack,$safeeval);
+	      if ($face=~/symbol/i) {$Apache::lonxml::prevent_entity_encode++;}
               $currentstring = $token->[4];     
 	    } 
 	   return $currentstring;
 	}
         sub end_font {
-	    my ($target,$token) = @_;
+	    my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
             my $currentstring = '';
             if ($target eq 'web') {
+	      my $face=&Apache::lonxml::get_param('face',$parstack,$safeeval);
+	      if ($face=~/symbol/i) {$Apache::lonxml::prevent_entity_encode--;}
               $currentstring = $token->[2];    
             } 
 	   return $currentstring;
Index: loncom/xml/lonxml.pm
diff -u loncom/xml/lonxml.pm:1.168 loncom/xml/lonxml.pm:1.169
--- loncom/xml/lonxml.pm:1.168	Wed May  1 17:40:25 2002
+++ loncom/xml/lonxml.pm	Wed May 15 20:56:46 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # XML Parser Module 
 #
-# $Id: lonxml.pm,v 1.168 2002/05/01 21:40:25 albertel Exp $
+# $Id: lonxml.pm,v 1.169 2002/05/16 00:56:46 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -60,7 +60,7 @@
 
 package Apache::lonxml; 
 use vars 
-qw(@pwd @outputstack $redirection $import @extlinks $metamode $evaluate %insertlist @namespace);
+qw(@pwd @outputstack $redirection $import @extlinks $metamode $evaluate %insertlist @namespace $prevent_entity_encode);
 use strict;
 use HTML::LCParser();
 use HTML::TreeBuilder();
@@ -129,6 +129,9 @@
 # stores the list of active tag namespaces
 @namespace=();
 
+# if 0 all high ASCII characters will be encoded into HTML Entities
+$prevent_entity_encode=0;
+
 # has the dynamic menu been updated to know about this resource
 $Apache::lonxml::registered=0;
 
@@ -624,18 +627,22 @@
       #evaluate variable refs in result
       if ($result ne "") {
 	if ( $#$parstack > -1 ) {
-	  if ($Apache::lonxml::redirection) {
-	    $Apache::lonxml::outputstack['-1'] .= 
-	      &Apache::run::evaluate($result,$safeeval,$$parstack['-1']);
-	  } else {
-	    $finaloutput .= &Apache::run::evaluate($result,$safeeval,
-						   $$parstack['-1']);
-	  }
+	  $result=&Apache::run::evaluate($result,$safeeval,$$parstack[-1]);
 	} else {
-	  $finaloutput .= &Apache::run::evaluate($result,$safeeval,'');
+	  $result= &Apache::run::evaluate($result,$safeeval,'');
 	}
-	$result = '';
       }
+      # Encode any high ASCII characters
+      if (!$Apache::lonxml::prevent_entity_encode) {
+	$result=&HTML::Entities::encode($result,"\200-\377");
+      }
+      if ($Apache::lonxml::redirection) {
+	$Apache::lonxml::outputstack['-1'] .= $result;
+      } else {
+	$finaloutput.=$result;
+      }
+      $result = '';
+
       if ($token->[0] eq 'E') { 
 	&end_tag($stack,$parstack,$token);
       }
@@ -648,8 +655,7 @@
   #   $finaloutput.=&endredirection;
   # }
 
-  # Encode any high ASCII characters
-  $finaloutput=&HTML::Entities::encode($finaloutput,"\200-\377");
+
   if (($ENV{'QUERY_STRING'}) && ($target eq 'web')) {
     $finaloutput=&afterburn($finaloutput);
   }