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

sakharuk lon-capa-cvs@mail.lon-capa.org
Tue, 26 Aug 2003 14:40:03 -0000


sakharuk		Tue Aug 26 10:40:03 2003 EDT

  Modified files:              
    /loncom/xml	londefdef.pm 
  Log:
  The length of the table cell can be correctly calculated for the case when somebody uses <br /> in this cell. This makes table looking more pretty. 
  
  
Index: loncom/xml/londefdef.pm
diff -u loncom/xml/londefdef.pm:1.165 loncom/xml/londefdef.pm:1.166
--- loncom/xml/londefdef.pm:1.165	Fri Aug 22 12:44:47 2003
+++ loncom/xml/londefdef.pm	Tue Aug 26 10:40:03 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Tags Default Definition Module 
 #
-# $Id: londefdef.pm,v 1.165 2003/08/22 16:44:47 albertel Exp $
+# $Id: londefdef.pm,v 1.166 2003/08/26 14:40:03 sakharuk Exp $
 # 
 #
 # Copyright Michigan State University Board of Trustees
@@ -323,7 +323,7 @@
     if ($target eq 'web') {
 	$currentstring = $token->[4];     
     } elsif ($target eq 'tex') {
-	$currentstring .= '\keephidden{' 
+	$currentstring .= '\keephidden{Title of the document:  ' 
     }
     if ($target eq 'meta') {
 	$currentstring='<title>';
@@ -1776,9 +1776,11 @@
 	    }
 	}
 	#continues trying estimate the width of raw data
+#	$currentstring.=' SSS '.$Apache::londefdef::table[-1]{'lengthrow'}[0].' FFF '; ####for test only
 	my @length_raw_row = split(/,/,$Apache::londefdef::table[-1]{'lengthrow'}[0]);
 	for (my $in=1;$in<=$Apache::londefdef::table[-1]{'row_number'};$in++) {
 	    my @length_row = split(/,/,$Apache::londefdef::table[-1]{'lengthrow'}[$in]);
+#	    $currentstring.=' SSS '.$Apache::londefdef::table[-1]{'lengthrow'}[$in].' FFF '; ####for test only
 	    for (my $jn=0;$jn<=$#length_row;$jn++) {
 		if ($length_raw_row[$jn]<$length_row[$jn]) {$length_raw_row[$jn]=$length_row[$jn];}
 	    }
@@ -1831,7 +1833,7 @@
     return $currentstring;
 }
 
-#-- <tr> tag
+#-- <tr> tag (end tag optional)
 sub start_tr {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
     my $currentstring = '';
@@ -1868,7 +1870,7 @@
     return $currentstring;
 }
 
-#-- <td> tag
+#-- <td> tag (end tag optional)
 sub start_td {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
     my $currentstring = '';
@@ -1927,9 +1929,24 @@
 	    $Apache::londefdef::table[-1]{'TeXlength'} .= $1.',';
 	    $Apache::londefdef::table[-1]{'length'} .= '0,';
 	} else {  
-	    $data=~s/^\s+(\S.*)/$1/;
+	    $data=~s/^\s+(\S.*)/$1/; 
 	    $data=~s/(.*\S)\s+$/$1/;
-	    my $current_length=2*length($data);
+	    $data=~s/(\s)+/$1/;
+	    my $current_length=0;
+	    if ($data=~/\\vskip/) {
+                my $newdata=$data;
+		$newdata=~s/\\vskip \d*\.?\d*\s*mm/THISISJUSTTEMPORARYSEPARATOR/g;
+		my @newdata=split(/THISISJUSTTEMPORARYSEPARATOR/,$newdata);
+		foreach my $elementdata (@newdata) {
+		    $elementdata=~s/^\s+(\S.*)/$1/; 
+		    $elementdata=~s/(.*\S)\s+$/$1/;
+		    $elementdata=~s/(\s)+/$1/;
+		    my $lengthnewdata=1.8*length($elementdata);
+		    if ($lengthnewdata>$current_length) {$current_length=$lengthnewdata;}
+		}
+	    } else {
+		$current_length=1.8*length($data);
+	    }
 	    $Apache::londefdef::table[-1]{'length'} .= $current_length.',';
 	    $Apache::londefdef::table[-1]{'TeXlength'} .= '0,';
 	}        
@@ -1953,7 +1970,7 @@
     return $currentstring;
 }
 
-#-- <th> tag
+#-- <th> tag (end tag optional)
 sub start_th {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
     my $currentstring = '';
@@ -3107,7 +3124,7 @@
     return $currentstring;
 }
 
-#-- <tfoot> tag
+#-- <tfoot> tag (end tag optional)
 sub start_tfoot {
     my ($target,$token) = @_;
     my $currentstring = '';
@@ -3126,7 +3143,7 @@
     return $currentstring;
 }
 
-#-- <thead> tag
+#-- <thead> tag (end tag optional)
 sub start_thead {
     my ($target,$token) = @_;
     my $currentstring = '';