--- loncom/xml/londefdef.pm 2002/04/05 18:11:11 1.51 +++ loncom/xml/londefdef.pm 2002/04/08 15:17:01 1.52 @@ -2,7 +2,7 @@ # The LearningOnline Network with CAPA # Tags Default Definition Module # -# $Id: londefdef.pm,v 1.51 2002/04/05 18:11:11 sakharuk Exp $ +# $Id: londefdef.pm,v 1.52 2002/04/08 15:17:01 sakharuk Exp $ # # # Copyright Michigan State University Board of Trustees @@ -1264,19 +1264,16 @@ EDITBUTTON if ($target eq 'web') { $currentstring = $token->[4]; } elsif ($target eq 'tex') { - &Apache::lonxml::startredirection; my $border = &Apache::lonxml::get_param('border',$parstack,$safeeval); unless (defined $border) { $border = 0; } - @Apache::londefdef::rows = (); - @Apache::londefdef::columns = (); - $Apache::londefdef::counter_columns = 0; - $Apache::londefdef::hinc = ''; - $Apache::londefdef::vinc = ''; - $Apache::londefdef::vvinc = ''; if ($border) { - $Apache::londefdef::hinc = '\hline '; - $Apache::londefdef::vinc = '&'; - $Apache::londefdef::vvinc = '|'; + $Apache::londefdef::table{'hinc'} = '\hline '; + $Apache::londefdef::table{'vinc'} = '&'; + $Apache::londefdef::table{'vvinc'} = '|'; + } else { + $Apache::londefdef::table{'hinc'} = ''; + $Apache::londefdef::table{'vinc'} = ''; + $Apache::londefdef::table{'vvinc'} = ''; } } return $currentstring; @@ -1287,17 +1284,17 @@ EDITBUTTON if ($target eq 'web') { $currentstring = $token->[2]; } elsif ($target eq 'tex') { - my $output=&Apache::lonxml::endredirection; - $output =~ s/<\/td>\s*]*)>/$Apache::londefdef::vinc/g; - $output =~ s/]*)>//g; - $output =~ s/<\/td>//g; - my $header_of_table = '{'.$Apache::londefdef::vvinc; + my $output = ''; + my $header_of_table = '{'.$Apache::londefdef::table{'vvinc'}; my $in; - for ($in=0;$in<$Apache::londefdef::counter_columns;$in++) { - $header_of_table .= $Apache::londefdef::columns[$in].$Apache::londefdef::vvinc; + for ($in=0;$in<$Apache::londefdef::table{'counter_columns'};$in++) { + $header_of_table .= @{ $Apache::londefdef::table{'columns'} }[$in].$Apache::londefdef::table{'vvinc'}; + $output .= $Apache::londefdef::table{'rowdata'}[$in]; + chop $output; + $output .= ' \\\\ '; } $header_of_table .= '}'; - $currentstring .= '\begin{tabular}'.$header_of_table.$output.$Apache::londefdef::hinc.'\end{tabular}'; + $currentstring .= '\begin{tabular}'.$header_of_table.$output.$Apache::londefdef::table{'hinc'}.'\end{tabular}'; } return $currentstring; } @@ -1309,12 +1306,13 @@ EDITBUTTON $currentstring = $token->[4]; } elsif ($target eq 'tex') { if (substr(&Apache::lonxml::get_param('align',$parstack,$safeeval),0,1) ne '') { - push @Apache::londefdef::rows, substr(&Apache::lonxml::get_param('align',$parstack,$safeeval),0,1); + push @ {$Apache::londefdef::table{'rows'} }, substr(&Apache::lonxml::get_param('align',$parstack,$safeeval),0,1); } else { - push @Apache::londefdef::rows, 'c'; + push @ {$Apache::londefdef::table{'rows'} }, 'c'; } - $currentstring = '\hline '; - $Apache::londefdef::counter_columns = 0; + push ( @{ $Apache::londefdef::table{'rowdata'} }, $Apache::londefdef::table{'hinc'}); + $Apache::londefdef::table{'counter_columns'} = 0; + } return $currentstring; } @@ -1324,7 +1322,6 @@ EDITBUTTON if ($target eq 'web') { $currentstring = $token->[2]; } elsif ($target eq 'tex') { - $currentstring = '\\\\'; } return $currentstring; } @@ -1337,11 +1334,12 @@ EDITBUTTON } elsif ($target eq 'tex') { my $what_to_push = substr(&Apache::lonxml::get_param('align',$parstack,$safeeval),0,1); if ($what_to_push eq '') { - $what_to_push = substr($Apache::londefdef::rows[0],0,1); + $what_to_push = substr($Apache::londefdef::table{'rows'}[0],0,1);; } - push @Apache::londefdef::columns, $what_to_push; - $Apache::londefdef::counter_columns++; - $currentstring = $token->[4];; + push @{ $Apache::londefdef::table{'columns'} }, $what_to_push; + $Apache::londefdef::table{'counter_columns'}++; + &Apache::lonxml::startredirection(); +; } return $currentstring; } @@ -1351,7 +1349,9 @@ EDITBUTTON if ($target eq 'web') { $currentstring = $token->[2]; } elsif ($target eq 'tex') { - $currentstring = $token->[2];; + my $current_row = $#{ $Apache::londedef::table{'rows'} }; + my $data=&Apache::lonxml::endredirection(); + @{ $Apache::londefdef::table{'rowdata'} }[$current_row] .= $data.' '.$Apache::londefdef::table{'vinc'}; } return $currentstring; }