--- loncom/xml/londefdef.pm 2004/02/19 19:57:48 1.199 +++ loncom/xml/londefdef.pm 2004/04/01 15:18:06 1.205 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Tags Default Definition Module # -# $Id: londefdef.pm,v 1.199 2004/02/19 19:57:48 albertel Exp $ +# $Id: londefdef.pm,v 1.205 2004/04/01 15:18:06 albertel Exp $ # # # Copyright Michigan State University Board of Trustees @@ -86,7 +86,6 @@ sub start_m { my $currentstring = ''; my $inside = &Apache::lonxml::get_all_text_unbalanced("/m",$parser); if ($target eq 'web' || $target eq 'analyze') { - $Apache::lonxml::prevent_entity_encode++; $inside ='\\documentstyle{article}'.$inside; &Apache::lonxml::debug("M is starting with:$inside:"); my $eval=&Apache::lonxml::get_param('eval',$parstack,$safeeval); @@ -117,11 +116,8 @@ sub start_m { sub end_m { my ($target,$token) = @_; my $currentstring = ''; - if ($target eq 'web') { - $Apache::lonxml::prevent_entity_encode--; - } elsif ($target eq 'tex') { + if ($target eq 'tex') { $currentstring = ""; - } elsif ($target eq 'meta') { } return $currentstring; } @@ -393,7 +389,7 @@ sub start_meta { my $display=&Apache::lonxml::get_param ('display',$parstack,$safeeval,undef,1); if ($display) { - $display=&HTML::Entities::encode($display); + $display=&HTML::Entities::encode($display,'<>&"'); $currentstring.='<'.$name.'.display>'.$display. ''; } @@ -535,12 +531,13 @@ sub start_body { if ($ENV{'request.state'} ne 'published') { $currentstring.=(< - + EDITBUTTON } else { $currentstring.=&Apache::lonmenu::menubuttons(undef,$target,1); } + $currentstring.=&Apache::lonxml::message_location(); } elsif ($target eq 'tex') { $currentstring = '\begin{document}'; } @@ -1246,9 +1243,7 @@ sub start_font { my $currentstring = ''; if ($target eq 'web') { my $face=&Apache::lonxml::get_param('face',$parstack,$safeeval); - if ($face=~/symbol/i) { - $Apache::lonxml::prevent_entity_encode++; - } else { + if ($face!~/symbol/i) { if (($ENV{'browser.fontenhance'} eq 'on') || ($ENV{'browser.blackwhite'} eq 'on')) { return ''; } } @@ -1266,8 +1261,6 @@ sub end_font { my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_; my $currentstring = ''; if ($target eq 'web') { - my $face=&Apache::lonxml::get_param('face',$parstack,$safeeval); - if ($face=~/symbol/i) {$Apache::lonxml::prevent_entity_encode--;} $currentstring = $token->[2]; } elsif ($target eq 'tex') { my $fontsize=&Apache::lonxml::get_param('TeXsize',$parstack,$safeeval); @@ -1337,7 +1330,7 @@ sub start_sub { if ($target eq 'web') { $currentstring .= $token->[4]; } elsif ($target eq 'tex') { - $currentstring .= "\$_{"; + $currentstring .= '\ensuremath{_{'; } return $currentstring; } @@ -1348,7 +1341,7 @@ sub end_sub { if ($target eq 'web') { $currentstring .= $token->[2]; } elsif ($target eq 'tex') { - $currentstring .= "}\$"; + $currentstring .= '}}'; } return $currentstring; } @@ -1360,7 +1353,7 @@ sub start_sup { if ($target eq 'web') { $currentstring .= $token->[4]; } elsif ($target eq 'tex') { - $currentstring .= "\$^{"; + $currentstring .= '\ensuremath{^{'; } return $currentstring; } @@ -1371,7 +1364,7 @@ sub end_sup { if ($target eq 'web') { $currentstring .= $token->[2]; } elsif ($target eq 'tex') { - $currentstring .= "}\$"; + $currentstring .= '}}'; } return $currentstring; } @@ -1794,13 +1787,14 @@ sub start_table { if (not defined $TeXwidth) { my $htmlwidth = &Apache::lonxml::get_param('width',$parstack,$safeeval,undef,1); if ($htmlwidth=~/%/) { + $Apache::londefdef::table[-1]{'percent'}=1; $htmlwidth=~/(\d+)/; - my $value=$1*$textwidth/100; - $Apache::londefdef::table[-1]{'width'}=$value; + $Apache::londefdef::table[-1]{'width'}=$1*$textwidth/100;; } else { $Apache::londefdef::table[-1]{'width'}=$textwidth; } } elsif ($TeXwidth=~/%/) { + $Apache::londefdef::table[-1]{'percent'}=1; $TeXwidth=~/(\d+)/; my $value=$1*$textwidth/100; $Apache::londefdef::table[-1]{'width'}=$value; @@ -1880,6 +1874,17 @@ sub end_table { $length_row_final[$jn]=0.9*$available_length/$needed; } } + #recalculation for the use of all available width if width is defined in % + if ($Apache::londefdef::table[-1]{'percent'}==1) { + my $current=0; + for (my $i=0;$i<=$#length_row_final;$i++) { + $current+=$length_row_final[$i]; + } + my $coef=$Apache::londefdef::table[-1]{'width'}/$current; + for (my $i=0;$i<=$#length_row_final;$i++) { + $length_row_final[$i]*=$coef; + } + } #fill the table for (my $in=0;$in<=$Apache::londefdef::table[-1]{'row_number'};$in++) { for (my $jn=0;$jn<=$#length_row_final;$jn++) {