--- loncom/xml/londefdef.pm 2003/09/05 19:35:40 1.171 +++ loncom/xml/londefdef.pm 2003/10/01 21:13:50 1.178 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Tags Default Definition Module # -# $Id: londefdef.pm,v 1.171 2003/09/05 19:35:40 sakharuk Exp $ +# $Id: londefdef.pm,v 1.178 2003/10/01 21:13:50 albertel Exp $ # # # Copyright Michigan State University Board of Trustees @@ -92,9 +92,15 @@ sub start_m { $Apache::lontexconvert::errorstring=''; } #&Apache::lonxml::debug("M is ends with:$currentstring:"); + $Apache::lonxml::post_evaluate=0; } elsif ($target eq 'tex') { $currentstring = &Apache::lonxml::get_all_text_unbalanced("/m",$parser); + my $eval=&Apache::lonxml::get_param('eval',$parstack,$safeeval); + if ($eval eq 'on') { + $currentstring=&Apache::run::evaluate($currentstring,$safeeval,$$parstack[-1]); + } if ($currentstring=~/^(\s*\\\\\s*)*$/) {$currentstring = ' \vskip 0 mm ';} + $Apache::lonxml::post_evaluate=0; } else { my $inside = &Apache::lonxml::get_all_text_unbalanced("/m",$parser); } @@ -1638,45 +1644,77 @@ sub start_dl { 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; } -#--
tag +#--
tag (end tag optional) sub start_dt { - my ($target,$token) = @_; - my $currentstring = ''; + my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_; + my $currentstring=''; if ($target eq 'web') { $currentstring = $token->[4]; } elsif ($target eq 'tex') { - $currentstring = '\item['; + 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; } sub end_dt { - my ($target,$token) = @_; + my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_; my $currentstring = ''; if ($target eq 'web') { $currentstring = $token->[2]; } elsif ($target eq 'tex') { - $currentstring = ']'; + my $data=&item_cleanup; + push @Apache::londefdef::description,'\item['.$data.']'; + $Apache::londefdef::DT_redirection=0; } return $currentstring; } +sub item_cleanup { + my $item=&Apache::lonxml::endredirection(); + $item=~s/\\begin{center}//g; + $item=~s/\\end{center}//g; + return $item; +} + #--
tag sub start_dd { my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_; @@ -1684,21 +1722,26 @@ sub start_dd { if ($target eq 'web') { $currentstring = $token->[4]; } elsif ($target eq 'tex') { - if ($$tagstack[-2] eq 'dl') { - $currentstring = ' \item [] '; - } elsif ($$tagstack[-2] eq 'dt') { - $currentstring = ']'; + if ($Apache::londefdef::DT_redirection) { + my $data=&item_cleanup; + 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; } @@ -2165,7 +2208,16 @@ sub start_applet { $currentstring='[APPLET: '.$alttag.']'; } } elsif ($target eq 'tex') { - $currentstring = " \\begin{figure} "; + my $alttag= &Apache::lonxml::get_param('alt',$parstack, + $safeeval,undef,1); + unless ($alttag) { + my $code=&Apache::lonxml::get_param('code',$parstack,$safeeval, + undef,1); + $alttag=&Apache::lonmeta::alttag($Apache::lonxml::pwd[-1], + $code); + } + $currentstring.='\begin{center} \fbox{Java Applet: '.$alttag. + '.}\end{center}'; } return $currentstring; } @@ -2176,7 +2228,6 @@ sub end_applet { if ($target eq 'web') { $currentstring = $token->[2]; } elsif ($target eq 'tex') { - $currentstring = " \\end{figure}"; } return $currentstring; } @@ -2199,7 +2250,6 @@ sub start_embed { $currentstring='[EMBED: '.$alttag.']'; } } elsif ($target eq 'tex') { - $currentstring = " \\begin{figure} "; } return $currentstring; } @@ -2209,8 +2259,7 @@ sub end_embed { my $currentstring = ''; if ($target eq 'web') { $currentstring = $token->[2]; - } elsif ($target eq 'tex') { - $currentstring = " \\end{figure}"; + } elsif ($target eq 'tex') { } return $currentstring; } @@ -2229,7 +2278,6 @@ sub start_param { if ($target eq 'web') { $currentstring = $token->[4]; } elsif ($target eq 'tex') { - $currentstring = " \\begin{figure} "; } return $currentstring; } @@ -2240,7 +2288,6 @@ sub end_param { if ($target eq 'web') { $currentstring = $token->[2]; } elsif ($target eq 'tex') { - $currentstring = " \\end{figure}"; } return $currentstring; }