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

sakharuk lon-capa-cvs@mail.lon-capa.org
Fri, 08 Aug 2003 17:48:40 -0000


sakharuk		Fri Aug  8 13:48:40 2003 EDT

  Modified files:              
    /loncom/xml	londefdef.pm 
  Log:
  You can use unbalanced <td> tag (widthout optional </td>) even at the very end of the raw: <tr><td>.....</tr>. It works fine though the implementation looks crude.
  
  
Index: loncom/xml/londefdef.pm
diff -u loncom/xml/londefdef.pm:1.159 loncom/xml/londefdef.pm:1.160
--- loncom/xml/londefdef.pm:1.159	Thu Aug  7 16:12:40 2003
+++ loncom/xml/londefdef.pm	Fri Aug  8 13:48:40 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Tags Default Definition Module 
 #
-# $Id: londefdef.pm,v 1.159 2003/08/07 20:12:40 sakharuk Exp $
+# $Id: londefdef.pm,v 1.160 2003/08/08 17:48:40 sakharuk Exp $
 # 
 #
 # Copyright Michigan State University Board of Trustees
@@ -51,6 +51,8 @@
 use Apache::lonmenu();
 use Apache::lonmeta();
 
+$Apache::londefdef::TD_redirection=0;
+
 BEGIN {
 
     &Apache::lonxml::register('Apache::londefdef',('a','abbr','acronym','accessrule','address','allow','applet','area','b','base','basefont','bgo','bgsound','big','blink','blockquote','blankspace','body','br','button','caption','center','cite','code','col','colgroup','dd','del','dfn','dir','div','dl','dt','em','embed','externallink','fieldset','font','form','frame','frameset','h1','h2','h3','h4','h5','h6','head','hr','html','i','iframe','img','input','ins','insert','isindex','kbd','keygen','label','layer','legend','li','link','m','map','marquee','menu','meta','multicol','nobr','noembed','noframes','nolayer','noscript','object','ol','optgroup','option','output','p','param','pre','q','s','samp','select','server','small','spacer','span','strike','strong','sub','sup','table','tbody','td','textarea','tfoot','th','thead','title','tr','tt','tthoption','u','ul','var','wbr','hideweboutput'));
@@ -1840,11 +1842,14 @@
 }
         
 sub end_tr {
-    my ($target,$token) = @_;
+    my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
     my $currentstring = '';
     if ($target eq 'web') {
 	$currentstring = $token->[2];     
     } elsif ($target eq 'tex') {
+	if ($Apache::londefdef::TD_redirection) {
+	    &end_td_tex($parstack,$parser,$safeeval);    
+	}
 	push @{ $Apache::londefdef::table[-1]{'TeXlengthrow'} },$Apache::londefdef::table[-1]{'TeXlength'};
 	push @{ $Apache::londefdef::table[-1]{'lengthrow'} },$Apache::londefdef::table[-1]{'length'};
     }
@@ -1858,37 +1863,26 @@
     if ($target eq 'web') {
 	$currentstring = $token->[4];     
     } elsif ($target eq 'tex') {
+	$Apache::londefdef::TD_redirection = 1;
 	&tag_check('tr','td',$tagstack,$parstack,$parser,$safeeval);
-#	my @ar=@$parstack; 
-#	for (my $i=$#ar-1;$i>=0;$i--) {
-#	    if (lc($$tagstack[$i]) eq 'tr') {
-#		&start_td_tex($parstack,$parser,$safeeval);
-#		last;
-#	    } elsif (lc($$tagstack[$i]) eq 'td') {
-#                splice @ar, $i+1;
-#		&end_td_tex(\@ar,$parser,$safeeval);
-#		&start_td_tex($parstack,$parser,$safeeval);
-#		last;
-#	    }
-#	}
     } 
     return $currentstring;
 }   
     
 sub tag_check {
     my ($good_tag,$bad_tag,$tagstack,$parstack,$parser,$safeeval) = @_;
-	my @ar=@$parstack; 
-	for (my $i=$#ar-1;$i>=0;$i--) {
-	    if (lc($$tagstack[$i]) eq $good_tag) {
-		&start_td_tex($parstack,$parser,$safeeval);
-		last;
-	    } elsif (lc($$tagstack[$i]) eq $bad_tag) {
-                splice @ar, $i+1;
-		&end_td_tex(\@ar,$parser,$safeeval);
-		&start_td_tex($parstack,$parser,$safeeval);
-		last;
-	    }
+    my @ar=@$parstack; 
+    for (my $i=$#ar-1;$i>=0;$i--) {
+	if (lc($$tagstack[$i]) eq $good_tag) {
+	    &start_td_tex($parstack,$parser,$safeeval);
+	    last;
+	} elsif (lc($$tagstack[$i]) eq $bad_tag) {
+	    splice @ar, $i+1;
+	    &end_td_tex(\@ar,$parser,$safeeval);
+	    &start_td_tex($parstack,$parser,$safeeval);
+	    last;
 	}
+    }
     return '';
 }
  
@@ -1941,6 +1935,7 @@
     if ($target eq 'web') {
 	$currentstring = $token->[2];     
     } elsif ($target eq 'tex') {
+        $Apache::londefdef::TD_redirection =0;
 	&end_td_tex($parstack,$parser,$safeeval);
     }
     return $currentstring;