--- loncom/xml/londefdef.pm 2003/08/27 15:00:43 1.158.4.3 +++ loncom/xml/londefdef.pm 2003/11/15 12:46:41 1.191 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Tags Default Definition Module # -# $Id: londefdef.pm,v 1.158.4.3 2003/08/27 15:00:43 albertel Exp $ +# $Id: londefdef.pm,v 1.191 2003/11/15 12:46:41 albertel Exp $ # # # Copyright Michigan State University Board of Trustees @@ -50,6 +50,8 @@ use Apache::File(); use Image::Magick; use Apache::lonmenu(); use Apache::lonmeta(); +use Apache::Constants qw(:common); + BEGIN { @@ -57,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 { @@ -71,11 +82,12 @@ 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') { + my $inside = &Apache::lonxml::get_all_text("/m",$parser,$style); + $inside=~s---g; + if ($target eq 'web' || $target eq 'analyze') { $Apache::lonxml::prevent_entity_encode++; - my $inside = &Apache::lonxml::get_all_text_unbalanced("/m",$parser); $inside ='\\documentstyle{article}'.$inside; &Apache::lonxml::debug("M is starting with:$inside:"); my $eval=&Apache::lonxml::get_param('eval',$parstack,$safeeval); @@ -90,11 +102,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; } @@ -132,7 +148,7 @@ sub end_tthoption { return $result; } -#-- tag +#-- tag (end tag optional) sub start_html { my ($target,$token) = @_; my $currentstring = ''; @@ -151,7 +167,7 @@ sub start_html { &tth::tthoptions('-L -u0'); } } - if ($target eq 'web') { + if ($target eq 'web' || $target eq 'edit') { $currentstring = &Apache::lonxml::xmlbegin(). &Apache::lonxml::fontsettings(); } elsif ($target eq 'tex') { @@ -162,9 +178,11 @@ sub start_html { \renewcommand{\deg}{$^{\circ}$} \usepackage{longtable} \usepackage{textcomp} + \usepackage{makeidx} \usepackage[dvips]{graphicx} \usepackage{epsfig}\usepackage{calc} -\newenvironment{choicelist}{\begin{list}{}{\setlength{\rightmargin}{0in}\setlength{\leftmargin}{0.13in}\setlength{\topsep}{0.05in}\setlength{\itemsep}{0.022in}\setlength{\parsep}{0in}\setlength{\belowdisplayskip}{0.04in}\setlength{\abovedisplayskip}{0.05in}\setlength{\abovedisplayshortskip}{-0.04in}\setlength{\belowdisplayshortskip}{0.04in}}}{\end{list}}'; +\newenvironment{choicelist}{\begin{list}{}{\setlength{\rightmargin}{0in}\setlength{\leftmargin}{0.13in}\setlength{\topsep}{0.05in}\setlength{\itemsep}{0.022in}\setlength{\parsep}{0in}\setlength{\belowdisplayskip}{0.04in}\setlength{\abovedisplayskip}{0.05in}\setlength{\abovedisplayshortskip}{-0.04in}\setlength{\belowdisplayshortskip}{0.04in}}}{\end{list}} +\renewenvironment{theindex}{\begin{list}{}{{\vskip 1mm \noindent \large\textbf{Index}} \newline \setlength{\rightmargin}{0in}\setlength{\leftmargin}{0.13in}\setlength{\topsep}{0.01in}\setlength{\itemsep}{0.1in}\setlength{\parsep}{-0.02in}\setlength{\belowdisplayskip}{0.01in}\setlength{\abovedisplayskip}{0.01in}\setlength{\abovedisplayshortskip}{-0.04in}\setlength{\belowdisplayshortskip}{0.01in}}}{\end{list}}'; } return $currentstring; } @@ -178,7 +196,7 @@ sub end_html { return $currentstring; } -#-- tag +#-- tag (end tag optional) sub start_head { my ($target,$token) = @_; my $currentstring = ''; @@ -191,14 +209,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 = ''; @@ -217,13 +235,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; } @@ -236,13 +256,20 @@ sub end_select { return $currentstring; } -#--