--- loncom/xml/londefdef.pm 2003/09/05 19:35:40 1.171 +++ loncom/xml/londefdef.pm 2004/05/11 18:41:24 1.213 @@ -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.213 2004/05/11 18:41:24 sakharuk Exp $ # # # Copyright Michigan State University Board of Trustees @@ -50,8 +50,8 @@ use Apache::File(); use Image::Magick; use Apache::lonmenu(); use Apache::lonmeta(); +use Apache::Constants qw(:common); -$Apache::londefdef::TD_redirection=0; BEGIN { @@ -59,6 +59,15 @@ BEGIN { } +sub initialize_londefdef { + $Apache::londefdef::TD_redirection=0; + @Apache::londefdef::table = (); + $Apache::londefdef::select=0; + @Apache::londefdef::description=(); + $Apache::londefdef::DD_redirection=0; + $Apache::londefdef::DT_redirection=0; +} + #======================= TAG SUBROUTINES ===================== #-- sub start_output { @@ -73,11 +82,10 @@ sub end_output { } #-- tag sub start_m { - my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_; + my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style) = @_; my $currentstring = ''; - if ($target eq 'web') { - $Apache::lonxml::prevent_entity_encode++; - my $inside = &Apache::lonxml::get_all_text_unbalanced("/m",$parser); + my $inside = &Apache::lonxml::get_all_text_unbalanced("/m",$parser); + if ($target eq 'web' || $target eq 'analyze') { $inside ='\\documentstyle{article}'.$inside; &Apache::lonxml::debug("M is starting with:$inside:"); my $eval=&Apache::lonxml::get_param('eval',$parstack,$safeeval); @@ -92,11 +100,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); + $currentstring = $inside; + 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 ';} - } else { - my $inside = &Apache::lonxml::get_all_text_unbalanced("/m",$parser); + $Apache::lonxml::post_evaluate=0; } return $currentstring; } @@ -104,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; } @@ -134,26 +143,13 @@ sub end_tthoption { return $result; } -#-- tag +#-- tag (end tag optional) sub start_html { my ($target,$token) = @_; my $currentstring = ''; - if ($ENV{'browser.mathml'}) { - &tth::ttminit(); - if ($ENV{'browser.unicode'}) { - &tth::ttmoptions('-L -u1'); - } else { - &tth::ttmoptions('-L -u0'); - } - } else { - &tth::tthinit(); - if ($ENV{'browser.unicode'}) { - &tth::tthoptions('-L -u1'); - } else { - &tth::tthoptions('-L -u0'); - } - } - if ($target eq 'web') { + my $options=$ENV{'course.'.$ENV{'request.course.id'}.'.tthoptions'}; + &Apache::lontexconvert::init_tth(); + if ($target eq 'web' || $target eq 'edit') { $currentstring = &Apache::lonxml::xmlbegin(). &Apache::lonxml::fontsettings(); } elsif ($target eq 'tex') { @@ -182,7 +178,7 @@ sub end_html { return $currentstring; } -#-- tag +#-- tag (end tag optional) sub start_head { my ($target,$token) = @_; my $currentstring = ''; @@ -195,14 +191,14 @@ sub start_head { sub end_head { my ($target,$token) = @_; my $currentstring = ''; - if ($target eq 'web') { + if ($target eq 'web' && $ENV{'request.state'} eq 'published') { $currentstring = &Apache::lonmenu::registerurl(undef,$target). $token->[2]; } return $currentstring; } -#-- tag +#-- tag (end tag required) sub start_map { my ($target,$token) = @_; my $currentstring = ''; @@ -221,13 +217,15 @@ sub end_map { return $currentstring; } -#-- tag (end tag required) sub start_select { my ($target,$token) = @_; my $currentstring = ''; if ($target eq 'web') { $currentstring = $token->[4]; - } + } elsif ($target eq 'tex') { + $Apache::londefdef::select=0; + } return $currentstring; } @@ -240,13 +238,20 @@ sub end_select { return $currentstring; } -#--