--- loncom/xml/londefdef.pm 2004/01/30 17:31:06 1.197 +++ loncom/xml/londefdef.pm 2004/03/12 15:21:49 1.202 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Tags Default Definition Module # -# $Id: londefdef.pm,v 1.197 2004/01/30 17:31:06 sakharuk Exp $ +# $Id: londefdef.pm,v 1.202 2004/03/12 15:21:49 sakharuk Exp $ # # # Copyright Michigan State University Board of Trustees @@ -535,12 +535,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}'; } @@ -635,7 +636,7 @@ sub start_h1 { $currentstring .= $token->[4]; } elsif ($target eq 'tex') { my $pre; - my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1); + my $align=lc(&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1)); if (($align eq 'center') || (not defined $align)) { $pre='\begin{center}'; } elsif ($align eq 'left') { @@ -1099,24 +1100,45 @@ sub end_q { } #--

tag (end tag optional) +#optional attribute - align="center|left|right" sub start_p { my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_; my $currentstring = ''; if ($target eq 'web') { $currentstring .= $token->[4]; } elsif ($target eq 'tex') { - my $signal=1; - foreach my $tag (@$tagstack) {if (lc($tag) eq 'b') {$signal=0;}} - if ($signal) {$currentstring .= '\par ';} + my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1); + if ($align eq 'center') { + $currentstring='\begin{center}\par'; + } elsif ($align eq 'right') { + $currentstring='\makebox['.$ENV{'form.textwidth'}.']{\hfill\llap{'; + } elsif ($align eq 'left') { + $currentstring='\noindent\makebox['.$ENV{'form.textwidth'}.']{\rlap{'; + } + my $signal=1;#

does not work inside ... + foreach my $tag (@$tagstack) {if (lc($tag) eq 'b') {$signal=0;} + if (!$signal) {$currentstring = '';} + } } return $currentstring; } sub end_p { - my ($target,$token) = @_; + my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_; my $currentstring = ''; if ($target eq 'web') { $currentstring .= $token->[2]; + } elsif ($target eq 'tex') { + if ($$tagstack[-1] eq 'p') { + my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1); + if ($align eq 'center') { + $currentstring .= '\end{center}'; + } elsif ($align eq 'right') { + $currentstring .= '}}'; + } elsif ($align eq 'left') { + $currentstring .= '}\hfill}'; + } + } } return $currentstring; } @@ -1316,7 +1338,7 @@ sub start_sub { if ($target eq 'web') { $currentstring .= $token->[4]; } elsif ($target eq 'tex') { - $currentstring .= "\$_{"; + $currentstring .= '\ensuremath{_{'; } return $currentstring; } @@ -1327,7 +1349,7 @@ sub end_sub { if ($target eq 'web') { $currentstring .= $token->[2]; } elsif ($target eq 'tex') { - $currentstring .= "}\$"; + $currentstring .= '}}'; } return $currentstring; } @@ -1339,7 +1361,7 @@ sub start_sup { if ($target eq 'web') { $currentstring .= $token->[4]; } elsif ($target eq 'tex') { - $currentstring .= "\$^{"; + $currentstring .= '\ensuremath{^{'; } return $currentstring; } @@ -1350,7 +1372,7 @@ sub end_sup { if ($target eq 'web') { $currentstring .= $token->[2]; } elsif ($target eq 'tex') { - $currentstring .= "}\$"; + $currentstring .= '}}'; } return $currentstring; }