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

sakharuk lon-capa-cvs@mail.lon-capa.org
Fri, 26 Sep 2003 18:59:59 -0000


sakharuk		Fri Sep 26 14:59:59 2003 EDT

  Modified files:              
    /loncom/xml	londefdef.pm 
  Log:
  New (very updated) version for set of description list tags. It now works in the case where <dd> tag is omitted (Guy's critical note). I want to generalize this set of tags to take into account nested description lists - this is why I defined a few globals. Latter on they will go in one global array as in the case of table environment.
  
  
Index: loncom/xml/londefdef.pm
diff -u loncom/xml/londefdef.pm:1.173 loncom/xml/londefdef.pm:1.174
--- loncom/xml/londefdef.pm:1.173	Thu Sep 25 12:09:14 2003
+++ loncom/xml/londefdef.pm	Fri Sep 26 14:59:59 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Tags Default Definition Module 
 #
-# $Id: londefdef.pm,v 1.173 2003/09/25 16:09:14 sakharuk Exp $
+# $Id: londefdef.pm,v 1.174 2003/09/26 18:59:59 sakharuk Exp $
 # 
 #
 # Copyright Michigan State University Board of Trustees
@@ -1638,18 +1638,32 @@
     if ($target eq 'web') {
 	$currentstring = $token->[4];     
     } elsif ($target eq 'tex') {
-	$currentstring = '\begin{description}';  
+	$currentstring = '\begin{description}';
+	@Apache::londefdef::description=();
+	$Apache::londefdef::DD_redirection=0;
+	$Apache::londefdef::DT_redirection=0;
     } 
     return $currentstring;
 }
 
 sub end_dl {
-    my ($target,$token) = @_;
+    my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
     my $currentstring = '';
     if ($target eq 'web') {
 	$currentstring = $token->[2];     
     } elsif ($target eq 'tex') {
-	$currentstring = '\end{description}';  
+	if ($Apache::londefdef::DT_redirection) {
+	    my $data=&item_cleanup;
+	    push @Apache::londefdef::description,'\item['.$data.']';
+	    $Apache::londefdef::DT_redirection=0;
+	} elsif ($Apache::londefdef::DD_redirection) {
+	    $Apache::londefdef::description[-1].=&Apache::lonxml::endredirection();
+	}
+	foreach my $element (@Apache::londefdef::description) {
+	    $currentstring.=' '.$element.' ';
+	}
+	@Apache::londefdef::description=();
+	$currentstring.='\end{description}';  
     } 
     return $currentstring;
 }
@@ -1661,7 +1675,16 @@
     if ($target eq 'web') {
 	$currentstring = $token->[4];     
     } elsif ($target eq 'tex') {
-	&Apache::lonxml::startredirection();; 
+	if ($Apache::londefdef::DT_redirection) {
+	    my $data=&item_cleanup;
+	    push @Apache::londefdef::description,'\item['.$data.']';
+	    $Apache::londefdef::DT_redirection=0;
+	} elsif ($Apache::londefdef::DD_redirection) {
+	    $Apache::londefdef::description[-1].=&Apache::lonxml::endredirection();
+	    $Apache::londefdef::DD_redirection=0;
+	}
+	&Apache::lonxml::startredirection();
+	$Apache::londefdef::DT_redirection=1;
     } 
     return $currentstring;
 }
@@ -1673,13 +1696,14 @@
 	$currentstring = $token->[2];    
     } elsif ($target eq 'tex') {
 	my $data=&item_cleanup;
-	$currentstring.='\item['.$data.']';
+	push @Apache::londefdef::description,'\item['.$data.']';
+	$Apache::londefdef::DT_redirection=0;
     } 
     return $currentstring;
 }
 
 sub item_cleanup {
-    my $item=&Apache::lonxml::endredirection();;
+    my $item=&Apache::lonxml::endredirection();
     $item=~s/\\begin{center}//g;
     $item=~s/\\end{center}//g;
     return $item;
@@ -1692,20 +1716,26 @@
     if ($target eq 'web') {
 	$currentstring = $token->[4];     
     } elsif ($target eq 'tex') {
-	if ($$tagstack[-2] eq 'dt') {
+	if ($Apache::londefdef::DT_redirection) {
 	    my $data=&item_cleanup;
-	    $currentstring.='\item['.$data.']';
+	    push @Apache::londefdef::description,'\item['.$data.']';
+	    $Apache::londefdef::DT_redirection=0;
 	}
+	$Apache::londefdef::DD_redirection=1;
+	&Apache::lonxml::startredirection();
     } 
     return $currentstring;
 }
 
 sub end_dd {
-    my ($target,$token) = @_;
+    my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
     my $currentstring = '';
     if ($target eq 'web') {
 	$currentstring = $token->[2];    
-    } 
+    }  elsif ($target eq 'tex') {
+	$Apache::londefdef::description[-1].=&Apache::lonxml::endredirection();
+	$Apache::londefdef::DD_redirection=0;
+    }
     return $currentstring;
 }