--- loncom/xml/londefdef.pm 2003/04/16 19:20:51 1.127
+++ loncom/xml/londefdef.pm 2003/05/22 16:00:53 1.135
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Tags Default Definition Module
#
-# $Id: londefdef.pm,v 1.127 2003/04/16 19:20:51 sakharuk Exp $
+# $Id: londefdef.pm,v 1.135 2003/05/22 16:00:53 sakharuk Exp $
#
#
# Copyright Michigan State University Board of Trustees
@@ -54,7 +54,7 @@ use Apache::lonmeta();
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'));
+ &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'));
}
@@ -354,8 +354,7 @@ sub start_meta {
} else {
$currentstring = $token->[4];
}
- }
- if ($target eq 'meta') {
+ } elsif ($target eq 'meta') {
unless (&Apache::lonxml::get_param
('http-equiv',$parstack,$safeeval,undef,1)) {
my $name=$token->[2]->{'name'};
@@ -366,9 +365,11 @@ sub start_meta {
$currentstring='<'.$name.'>'.
&Apache::lonxml::get_param
('content',$parstack,$safeeval,undef,1).
- ''.$name.'>';
+ ''.$name.'>';
}
}
+ } elsif ($target eq 'tex') {
+ &Apache::lonxml::startredirection();
}
return $currentstring;
}
@@ -382,7 +383,10 @@ sub end_meta {
if ($args ne '') {
$currentstring = $token->[4];
}
- }
+ } elsif ($target eq 'tex') {
+ $currentstring=&Apache::lonxml::endredirection();
+ $currentstring='';
+ }
return $currentstring;
}
@@ -1697,7 +1701,7 @@ sub end_dd {
sub start_table {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
my $textwidth;
- if ($#Apache::londefdef::table==0) {
+ if (not defined @Apache::londefdef::table) {
$textwidth=&recalc($ENV{'form.textwidth'});
$textwidth=~/(\d+)/;
$textwidth=$1;
@@ -1742,6 +1746,7 @@ sub start_table {
$Apache::londefdef::table[-1]{'vvinc'} = '';
}
$Apache::londefdef::table[-1]{'output'} = ' \noindent \begin{tabular} ';
+ $currentstring = '\keephidden{NEW TABLE ENTRY '.$textwidth.'}';
}
return $currentstring;
}
@@ -1760,8 +1765,6 @@ sub end_table {
$header_of_table .= $Apache::londefdef::table[-1]{'columns'}[$in].$Apache::londefdef::table[-1]{'vvinc'};
}
$header_of_table .= '}';
-
-
#define the length of the table cells
#always starts with TeXwidth (if defined everything else is ignored)
my @length_row_final = split(/,/,$Apache::londefdef::table[-1]{'TeXlengthrow'}[0]);
@@ -1817,8 +1820,7 @@ sub end_table {
if ($#Apache::londefdef::table > 0) {
my $inmemory = $Apache::londefdef::table[-1]{'output'};
pop @Apache::londefdef::table;
- $Apache::londefdef::table[-1]{'rowdata'}[$Apache::londefdef::table[-1]{'row_number'}] .= $inmemory; ###Need to work with (wrong place to add)
-
+ push @{$Apache::londefdef::table[-1]{'include'}}, $inmemory;
} else {
$currentstring .= $Apache::londefdef::table[-1]{'output'};
pop @Apache::londefdef::table;
@@ -1896,7 +1898,7 @@ sub end_td {
} else {
if ($data=~m/width\s*=\s*(\d+\.?\d*\s*(mm|cm|in|pc|pt)*)/) {
my $current_length=&recalc($1);
- $current_length=~/(\d+)/;
+ $current_length=~/(\d+\.?\d*)/;
$Apache::londefdef::table[-1]{'TeXlength'} .= $1.',';
$Apache::londefdef::table[-1]{'length'} .= '0,';
} else {
@@ -1908,9 +1910,11 @@ sub end_td {
$Apache::londefdef::table[-1]{'length'} .= $current_length.',';
$Apache::londefdef::table[-1]{'TeXlength'} .= '0,';
}
- }
- $data='\parbox{TOBECHANGEDONNUMBER}{'.$data.'} '.$Apache::londefdef::table[-1]{'vinc'};
- @{ $Apache::londefdef::table[-1]{'rowdata'} }[$current_row] .= $data;
+ }
+ for (my $in=0; $in<=$#{$Apache::londefdef::table[-1]{'include'}};$in++) {
+ $data=~s/\\keephidden\{NEW TABLE ENTRY\}/$Apache::londefdef::table[-1]{'include'}[$in]/;
+ }
+ @{ $Apache::londefdef::table[-1]{'rowdata'} }[$current_row] .= '\parbox{TOBECHANGEDONNUMBER}{'.$data.'} '.$Apache::londefdef::table[-1]{'vinc'};
}
return $currentstring;
}
@@ -1929,29 +1933,48 @@ sub start_th {
push @{ $Apache::londefdef::table[-1]{'columns'} }, $what_to_push;
$Apache::londefdef::table[-1]{'counter_columns'}++;
&Apache::lonxml::startredirection();
- ;
}
return $currentstring;
-}
-
+}
+
sub end_th {
- my ($target,$token) = @_;
+ my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
my $currentstring = '';
if ($target eq 'web') {
$currentstring = $token->[2];
} elsif ($target eq 'tex') {
my $current_row = $Apache::londefdef::table[-1]{'row_number'};
my $data=&Apache::lonxml::endredirection();
- if ($data=~m/width\s*=\s*(\d+\.*\d*\s*(mm|cm))/) {
- $Apache::londefdef::table[-1]{'length'} .= $1.',';
+ my $TeXwidth=&Apache::lonxml::get_param('TeXwidth',$parstack,$safeeval,undef,0);
+ if (defined $TeXwidth) {
+ my $current_length=&recalc($TeXwidth);
+ $current_length=~/(\d+)/;
+ $Apache::londefdef::table[-1]{'TeXlength'} .= $1.',';
+ $Apache::londefdef::table[-1]{'length'} .= '0,';
} else {
- $Apache::londefdef::table[-1]{'length'} .= '0 mm,';
- }
- @{ $Apache::londefdef::table[-1]{'rowdata'} }[$current_row] .= '\parbox{'.$1.'}{\textbf{'.$data.'}} '.$Apache::londefdef::table[-1]{'vinc'};
+ if ($data=~m/width\s*=\s*(\d+\.?\d*\s*(mm|cm|in|pc|pt)*)/) {
+ my $current_length=&recalc($1);
+ $current_length=~/(\d+)/;
+ $Apache::londefdef::table[-1]{'TeXlength'} .= $1.',';
+ $Apache::londefdef::table[-1]{'length'} .= '0,';
+ } else {
+ $data=~/^\s*(\S.*)/;
+ $data=$1;
+ $data=~/(.*\S)\s*$/;
+ $data=$1;
+ my $current_length=2*length($data);
+ $Apache::londefdef::table[-1]{'length'} .= $current_length.',';
+ $Apache::londefdef::table[-1]{'TeXlength'} .= '0,';
+ }
+ }
+ for (my $in=0; $in<=$#{$Apache::londefdef::table[-1]{'include'}};$in++) {
+ $data=~s/\\keephidden\{NEW TABLE ENTRY\}/$Apache::londefdef::table[-1]{'include'}[$in]/;
+ }
+ $data='\textbf{'.$data.'}';
+ @{ $Apache::londefdef::table[-1]{'rowdata'} }[$current_row] .= '\parbox{TOBECHANGEDONNUMBER}{'.$data.'} '.$Apache::londefdef::table[-1]{'vinc'};
}
return $currentstring;
}
-
#-- tag
sub start_img {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
@@ -2205,7 +2228,29 @@ sub start_frameset {
$currentstring.='