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

albertel lon-capa-cvs@mail.lon-capa.org
Wed, 28 May 2003 21:05:33 -0000


albertel		Wed May 28 17:05:33 2003 EDT

  Modified files:              
    /loncom/xml	scripttag.pm lonxml.pm 
  Log:
  - should no longer generate warning on properly constructed stylefiles
  - end tag styles register the tag name with the <LONCAPA_INTERNAL_TURN_STYLE_ON />
    callback. In the end tag we do an extra &Apache::lonxml::end_tag() that actually clears
    out the </LONCAPA_INTERNAL_TURN_STYLE_ON> tag, but that causes the normal &end_tag call
    in the inner_xmlparse routine to clear out the now finished off style definition
  
  
Index: loncom/xml/scripttag.pm
diff -u loncom/xml/scripttag.pm:1.90 loncom/xml/scripttag.pm:1.91
--- loncom/xml/scripttag.pm:1.90	Fri May 23 12:26:28 2003
+++ loncom/xml/scripttag.pm	Wed May 28 17:05:33 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # <script> definiton
 #
-# $Id: scripttag.pm,v 1.90 2003/05/23 16:26:28 albertel Exp $
+# $Id: scripttag.pm,v 1.91 2003/05/28 21:05:33 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -55,6 +55,11 @@
 }
 
 sub end_LONCAPA_INTERNAL_TURN_STYLE_ON {
+    my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
+    my $end=&Apache::lonxml::get_param('end',$parstack,$safeeval);
+    if (defined($end)) {
+	&Apache::lonxml::end_tag($tagstack,$parstack,$token);
+    }
     return ('','no');
 }
 
Index: loncom/xml/lonxml.pm
diff -u loncom/xml/lonxml.pm:1.257 loncom/xml/lonxml.pm:1.258
--- loncom/xml/lonxml.pm:1.257	Thu May 22 17:05:01 2003
+++ loncom/xml/lonxml.pm	Wed May 28 17:05:33 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # XML Parser Module 
 #
-# $Id: lonxml.pm,v 1.257 2003/05/22 21:05:01 albertel Exp $
+# $Id: lonxml.pm,v 1.258 2003/05/28 21:05:33 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -494,6 +494,7 @@
   my $finaloutput = '';
   my $result;
   my $token;
+  my $dontpop=0;
   while ( $#$pars > -1 ) {
     while ($token = $$pars['-1']->get_token) {
       if (($token->[0] eq 'T') || ($token->[0] eq 'C') || ($token->[0] eq 'D') ) {
@@ -527,28 +528,28 @@
 			     $parstack, $pars, $safeeval, $style_for_target);
 	}
       } elsif ($token->[0] eq 'E') {
-	#clear out any tags that didn't end
-	while ($token->[1] ne $$stack['-1'] && ($#$stack > -1)) {
-	  my $lasttag=$$stack[-1];
-	  if ($token->[1] =~ /^$lasttag$/i) {
-	    &Apache::lonxml::warning('Using tag &lt;/'.$token->[1].'&gt; on line '.$token->[3].' as end tag to &lt;'.$$stack[-1].'&gt;');
-	    last;
-	  } else {
-	    &Apache::lonxml::warning('Found tag &lt;/'.$token->[1].'&gt; on line '.$token->[3].' when looking for &lt;/'.$$stack[-1].'&gt; in file');
-	    &end_tag($stack,$parstack,$token);
-	  }
-	}
-
 	if ($Apache::lonxml::usestyle &&
 	    exists($$style_for_target{'/'."$token->[1]"})) {
 	    $Apache::lonxml::usestyle=0;
 	    my $string=$$style_for_target{'/'.$token->[1]}.
-	      '<LONCAPA_INTERNAL_TURN_STYLE_ON />';
+	      '<LONCAPA_INTERNAL_TURN_STYLE_ON end="'.$token->[1].'" />';
 	    &Apache::lonxml::newparser($pars,\$string);
 	    $Apache::lonxml::style_values=$$parstack[-1];
+	    $dontpop=1;
 	} else {
-	  $result = &callsub("end_$token->[1]", $target, $token, $stack,
-			     $parstack, $pars,$safeeval, $style_for_target);
+	    #clear out any tags that didn't end
+	    while ($token->[1] ne $$stack['-1'] && ($#$stack > -1)) {
+		my $lasttag=$$stack[-1];
+		if ($token->[1] =~ /^$lasttag$/i) {
+		    &Apache::lonxml::warning('Using tag &lt;/'.$token->[1].'&gt; on line '.$token->[3].' as end tag to &lt;'.$$stack[-1].'&gt;');
+		    last;
+		} else {
+		    &Apache::lonxml::warning('Found tag &lt;/'.$token->[1].'&gt; on line '.$token->[3].' when looking for &lt;/'.$$stack[-1].'&gt; in file');
+		    &end_tag($stack,$parstack,$token);
+		}
+	    }
+	    $result = &callsub("end_$token->[1]", $target, $token, $stack,
+			       $parstack, $pars,$safeeval, $style_for_target);
 	}
       } else {
 	&Apache::lonxml::error("Unknown token event :$token->[0]:$token->[1]:");
@@ -583,9 +584,10 @@
       }
       $result = '';
 
-      if ($token->[0] eq 'E') { 
+      if ($token->[0] eq 'E' && !$dontpop) {
 	&end_tag($stack,$parstack,$token);
       }
+      $dontpop=0;
     }	
     if ($#$pars > -1) {
 	pop @$pars;
@@ -1023,8 +1025,6 @@
   } else {
     push (@Apache::lonxml::pwd, $dir);
   } 
-#  &Apache::lonxml::debug("pwd:$#Apache::lonxml::pwd");
-#  &Apache::lonxml::debug("pwd:$Apache::lonxml::pwd[$#Apache::lonxml::pwd]");
 }
 
 sub parstring {
@@ -1192,7 +1192,7 @@
     
     my $target=&get_target();
     
-    $Apache::lonxml::debug=0;
+    $Apache::lonxml::debug=$ENV{'user.debug'};
     
     if ($ENV{'browser.mathml'}) {
 	$request->content_type('text/xml');