--- loncom/xml/londefdef.pm 2005/05/18 16:34:03 1.272 +++ loncom/xml/londefdef.pm 2005/07/07 10:09:50 1.277 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Tags Default Definition Module # -# $Id: londefdef.pm,v 1.272 2005/05/18 16:34:03 albertel Exp $ +# $Id: londefdef.pm,v 1.277 2005/07/07 10:09:50 foxr Exp $ # # # Copyright Michigan State University Board of Trustees @@ -90,7 +90,8 @@ sub start_m { $inside=&Apache::run::evaluate($inside,$safeeval,$$parstack[-1]); #&Apache::lonxml::debug("M is evaulated to:$inside:"); } - $currentstring = &Apache::lontexconvert::converted(\$inside); + my $display=&Apache::lonxml::get_param('display',$parstack,$safeeval); + $currentstring = &Apache::lontexconvert::converted(\$inside,$display); if ($Apache::lontexconvert::errorstring) { &Apache::lonxml::warning("tth error: ". $Apache::lontexconvert::errorstring); @@ -564,11 +565,11 @@ EDITBUTTON sub end_body { my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_; - my $currentstring = ''; + my $currentstring = &end_p; # Close off unclosed
if ($target eq 'web') { - $currentstring = &Apache::lonxml::xmlend($target,$parser); + $currentstring .= &Apache::lonxml::xmlend($target,$parser); } elsif ($target eq 'tex') { - $currentstring = '\strut\newline\noindent\makebox[\textwidth/$number_of_columns][b]{\hrulefill}\newline\noindent \end{document}'; + $currentstring .= '\strut\newline\noindent\makebox[\textwidth/$number_of_columns][b]{\hrulefill}\newline\noindent \end{document}'; } return $currentstring; } @@ -576,11 +577,11 @@ sub end_body { #--
is a bit strange since it does not require a closing
+# However in latex, we must often output closing stuff to end +# environments and {}'s etc. Therefore we do all the work +# of figuring out the ending strings in the start tag processing, +# and provide a mechanism to output the stop text external +# to tag processing. +# +{ + + my $closing_string = ''; # String required to close+ #--
tag (end tag optional) #optional attribute - align="center|left|right" sub start_p { my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_; - my $currentstring = ''; + my $currentstring = &end_p; # close off prior para if in progress. if ($target eq 'web') { $currentstring .= $token->[4]; + $closing_string = '
'; # Not sure this is correct. } elsif ($target eq 'tex') { my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1); if ($align eq 'center') { - $currentstring='\begin{center}\par'; + $currentstring .='\begin{center}\par'; + $closing_string = '\end{center}'; } elsif ($align eq 'right') { - $currentstring='\makebox['.$env{'form.textwidth'}.']{\hfill\llap{'; + $currentstring.='\makebox['.$env{'form.textwidth'}.']{\hfill\llap{'; + $closing_string= '}}'; } elsif ($align eq 'left') { - $currentstring='\noindent\makebox['.$env{'form.textwidth'}.']{\rlap{'; + $currentstring.='\noindent\makebox['.$env{'form.textwidth'}.']{\rlap{'; + $closing_string = '}\hfill}'; } else { - $currentstring='\par '; + $currentstring.='\par '; + $closing_string = '\strut\\\\\strut'; } my $signal=1;# does not work inside ...
- foreach my $tag (@$tagstack) {if (lc($tag) eq 'b') {$signal=0;}
- if (!$signal) {$currentstring = '';}
+ foreach my $tag (@$tagstack) {
+ if (lc($tag) eq 'b') {
+ $signal=0;
+ }
+ }
+ if (!$signal) {
+ $currentstring = &end_p; # Just close the prior? Not sure this is correct
+ $closing_string = ''; # Probably correct?
}
- }
- return $currentstring;
-}
-sub end_p {
- my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
- my $currentstring = '';
- if ($target eq 'web') {
- $currentstring .= $token->[2];
- } elsif ($target eq 'tex') {
- my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1);
- if (not defined $align) {
- $currentstring.='\strut\\\\\strut ';
- } elsif ($align eq 'center') {
- $currentstring .= '\end{center}';
- } elsif ($align eq 'right') {
- $currentstring .= '}}';
- } elsif ($align eq 'left') {
- $currentstring .= '}\hfill}';
- }
}
return $currentstring;
}
+#
+# End paragraph processing just requires that we output the
+# closing string that was saved and blank it.
+sub end_p {
+ my $current_string = $closing_string;
+ $closing_string = ''; # Not in a para anymore.
+ return $current_string;
+}
+}
#--
tag (end tag forbidden)
sub start_br {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
@@ -1404,7 +1417,7 @@ sub end_sup {
#--
in the
prior to the list. if ($target eq 'web') { - $currentstring = $token->[4]; + $currentstring .= $token->[4]; } elsif ($target eq 'tex') { - $currentstring = " \\begin{itemize} "; + $currentstring .= " \\begin{itemize} "; } return $currentstring; } @@ -1652,9 +1665,9 @@ sub end_dir { #--
prior to the list. if ($target eq 'web') { - $currentstring = $token->[4]; + $currentstring .= $token->[4]; } elsif ($target eq 'tex') { $Apache::londefdef::list_index=0; my $type=&Apache::lonxml::get_param('type',$parstack,$safeeval,undef,0); @@ -1706,11 +1719,11 @@ sub end_ol { #--
unclosed prior to the list. if ($target eq 'web') { - $currentstring = $token->[4]; + $currentstring .= $token->[4]; } elsif ($target eq 'tex') { - $currentstring = '\begin{description}'; + $currentstring .= '\begin{description}'; $Apache::londefdef::DL++; push(@Apache::londefdef::description,[]); $Apache::londefdef::DD[$Apache::londefdef::DL]=0; @@ -1813,12 +1826,18 @@ sub end_dd { } #--
bodies
+#
#list of supported attributes: border,width,TeXwidth
sub start_table {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
- my ($textwidth,$currentstring)=('','');
+ my $textwidth = '';
+ my $currentstring = &end_p;
if ($target eq 'web') {
- $currentstring = $token->[4];
+ $currentstring .= $token->[4];
} elsif ($target eq 'tex') {
my $aa = {};
push @Apache::londefdef::table, $aa;
@@ -1882,7 +1901,7 @@ sub start_table {
$Apache::londefdef::table[-1]{'minlen'}=[];
$Apache::londefdef::table[-1]{'content'}=[];
$Apache::londefdef::table[-1]{'align'}=[];
- $currentstring='\keephidden{NEW TABLE ENTRY}';
+ $currentstring.='\keephidden{NEW TABLE ENTRY}';
}
return $currentstring;
}
@@ -2136,9 +2155,9 @@ sub start_tr {
sub end_tr {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
- my $currentstring = '';
+ my $currentstring = &end_p; # Close any pending in the row. if ($target eq 'web') { - $currentstring = $token->[2]; + $currentstring .= $token->[2]; } elsif ($target eq 'tex') { if ($Apache::londefdef::TD_redirection) { &end_td_tex($parstack,$parser,$safeeval); @@ -2413,9 +2432,9 @@ sub end_th_tex { sub end_th { my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_; - my $currentstring = ''; + my $currentstring = &end_p; # Close any open in the row. if ($target eq 'web') { - $currentstring = $token->[2]; + $currentstring .= $token->[2]; } elsif ($target eq 'tex') { $Apache::londefdef::TD_redirection =0; &end_th_tex($parstack,$parser,$safeeval); @@ -2794,7 +2813,7 @@ sub end_allow { #-- |
---|