--- loncom/xml/londefdef.pm 2003/04/10 14:31:09 1.124
+++ loncom/xml/londefdef.pm 2003/04/11 18:25:03 1.125
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Tags Default Definition Module
#
-# $Id: londefdef.pm,v 1.124 2003/04/10 14:31:09 sakharuk Exp $
+# $Id: londefdef.pm,v 1.125 2003/04/11 18:25:03 sakharuk Exp $
#
#
# Copyright Michigan State University Board of Trustees
@@ -573,12 +573,23 @@ sub end_strong {
#--
tag
sub start_h1 {
- my ($target,$token) = @_;
+ my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
my $currentstring = '';
if ($target eq 'web') {
$currentstring .= $token->[4];
} elsif ($target eq 'tex') {
- $currentstring .= '{\large \textbf{';
+ my $pre;
+ my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1);
+ if (($align eq 'center') || (not defined $align)) {
+ $pre='\begin{center}';
+ } elsif ($align eq 'left') {
+ $pre='\rlap{';
+ } elsif ($align eq 'right') {
+ $pre=' \hfill \llap{';
+ }
+ my $TeXsize=&Apache::lonxml::get_param('TeXsize',$parstack,$safeeval,undef,0);
+ if (not defined $TeXsize) {$TeXsize="large";}
+ $currentstring .= $pre.'{\\'.$TeXsize.' \textbf{';
} elsif ($target eq 'meta') {
$currentstring='';
&start_output();
@@ -587,12 +598,21 @@ sub start_h1 {
}
sub end_h1 {
- 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 $post;
+ my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1);
+ if (($align eq 'center') || (not defined $align)) {
+ $post='\end{center}';
+ } elsif ($align eq 'left') {
+ $post='} \hfill'.'\vskip 0 mm ';
+ } elsif ($align eq 'right') {
+ $post='}'.'\vskip 0 mm ';
+ }
+ $currentstring .= '}}'.$post;
} elsif ($target eq 'meta') {
&end_output();
$currentstring='';
@@ -602,115 +622,215 @@ sub end_h1 {
#-- tag
sub start_h2 {
- my ($target,$token) = @_;
+ my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
my $currentstring = '';
if ($target eq 'web') {
$currentstring .= $token->[4];
} elsif ($target eq 'tex') {
- $currentstring .= '{\large \textbf{';
+ my $pre;
+ my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1);
+ if (($align eq 'center') || (not defined $align)) {
+ $pre='\begin{center}';
+ } elsif ($align eq 'left') {
+ $pre='\rlap{';
+ } elsif ($align eq 'right') {
+ $pre=' \hfill \llap{';
+ }
+ my $TeXsize=&Apache::lonxml::get_param('TeXsize',$parstack,$safeeval,undef,0);
+ if (not defined $TeXsize) {$TeXsize="large";}
+ $currentstring .= $pre.'{\\'.$TeXsize.' \textbf{';
}
return $currentstring;
}
sub end_h2 {
- 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 $post;
+ my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1);
+ if (($align eq 'center') || (not defined $align)) {
+ $post='\end{center}';
+ } elsif ($align eq 'left') {
+ $post='} \hfill'.'\vskip 0 mm ';
+ } elsif ($align eq 'right') {
+ $post='}'.'\vskip 0 mm ';
+ }
+ $currentstring .= '}}'.$post;
}
return $currentstring;
}
#-- tag
sub start_h3 {
- my ($target,$token) = @_;
+ my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
my $currentstring = '';
if ($target eq 'web') {
$currentstring .= $token->[4];
} elsif ($target eq 'tex') {
- $currentstring .= '{\large \textbf{';
+ my $pre;
+ my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1);
+ if (($align eq 'center') || (not defined $align)) {
+ $pre='\begin{center}';
+ } elsif ($align eq 'left') {
+ $pre='\rlap{';
+ } elsif ($align eq 'right') {
+ $pre=' \hfill \llap{';
+ }
+ my $TeXsize=&Apache::lonxml::get_param('TeXsize',$parstack,$safeeval,undef,0);
+ if (not defined $TeXsize) {$TeXsize="large";}
+ $currentstring .= $pre.'{\\'.$TeXsize.' \textbf{';
}
return $currentstring;
}
sub end_h3 {
- 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 $post;
+ my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1);
+ if (($align eq 'center') || (not defined $align)) {
+ $post='\end{center}';
+ } elsif ($align eq 'left') {
+ $post='} \hfill'.'\vskip 0 mm ';
+ } elsif ($align eq 'right') {
+ $post='}'.'\vskip 0 mm ';
+ }
+ $currentstring .= '}}'.$post;
}
return $currentstring;
}
#-- tag
sub start_h4 {
- my ($target,$token) = @_;
+ my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
my $currentstring = '';
if ($target eq 'web') {
$currentstring .= $token->[4];
} elsif ($target eq 'tex') {
- $currentstring .= '{\large \textbf{';
+ my $pre;
+ my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1);
+ if (($align eq 'center') || (not defined $align)) {
+ $pre='\begin{center}';
+ } elsif ($align eq 'left') {
+ $pre='\rlap{';
+ } elsif ($align eq 'right') {
+ $pre=' \hfill \llap{';
+ }
+ my $TeXsize=&Apache::lonxml::get_param('TeXsize',$parstack,$safeeval,undef,0);
+ if (not defined $TeXsize) {$TeXsize="large";}
+ $currentstring .= $pre.'{\\'.$TeXsize.' \textbf{';
}
return $currentstring;
}
sub end_h4 {
- 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 $post;
+ my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1);
+ if (($align eq 'center') || (not defined $align)) {
+ $post='\end{center}';
+ } elsif ($align eq 'left') {
+ $post='} \hfill'.'\vskip 0 mm ';
+ } elsif ($align eq 'right') {
+ $post='}'.'\vskip 0 mm ';
+ }
+ $currentstring .= '}}'.$post;
}
return $currentstring;
}
#-- tag
sub start_h5 {
- my ($target,$token) = @_;
+ my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
my $currentstring = '';
if ($target eq 'web') {
$currentstring .= $token->[4];
} elsif ($target eq 'tex') {
- $currentstring .= '{\large \textbf{';
+ my $pre;
+ my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1);
+ if (($align eq 'center') || (not defined $align)) {
+ $pre='\begin{center}';
+ } elsif ($align eq 'left') {
+ $pre='\rlap{';
+ } elsif ($align eq 'right') {
+ $pre=' \hfill \llap{';
+ }
+ my $TeXsize=&Apache::lonxml::get_param('TeXsize',$parstack,$safeeval,undef,0);
+ if (not defined $TeXsize) {$TeXsize="large";}
+ $currentstring .= $pre.'{\\'.$TeXsize.' \textbf{';
}
return $currentstring;
}
sub end_h5 {
- 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 $post;
+ my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1);
+ if (($align eq 'center') || (not defined $align)) {
+ $post='\end{center}';
+ } elsif ($align eq 'left') {
+ $post='} \hfill'.'\vskip 0 mm ';
+ } elsif ($align eq 'right') {
+ $post='}'.'\vskip 0 mm ';
+ }
+ $currentstring .= '}}'.$post;
}
return $currentstring;
}
#-- tag
sub start_h6 {
- my ($target,$token) = @_;
+ my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
my $currentstring = '';
if ($target eq 'web') {
$currentstring .= $token->[4];
} elsif ($target eq 'tex') {
- $currentstring .= '{\large \textbf{';
+ my $pre;
+ my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1);
+ if (($align eq 'center') || (not defined $align)) {
+ $pre='\begin{center}';
+ } elsif ($align eq 'left') {
+ $pre='\rlap{';
+ } elsif ($align eq 'right') {
+ $pre=' \hfill \llap{';
+ }
+ my $TeXsize=&Apache::lonxml::get_param('TeXsize',$parstack,$safeeval,undef,0);
+ if (not defined $TeXsize) {$TeXsize="large";}
+ $currentstring .= $pre.'{\\'.$TeXsize.' \textbf{';
}
return $currentstring;
}
sub end_h6 {
- 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 $post;
+ my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1);
+ if (($align eq 'center') || (not defined $align)) {
+ $post='\end{center}';
+ } elsif ($align eq 'left') {
+ $post='} \hfill'.'\vskip 0 mm ';
+ } elsif ($align eq 'right') {
+ $post='}'.'\vskip 0 mm ';
+ }
+ $currentstring .= '}}'.$post;
}
return $currentstring;
}
@@ -1207,7 +1327,7 @@ sub start_hr {
if ($target eq 'web') {
$currentstring .= $token->[4];
} elsif ($target eq 'tex') {
- my $LaTeXwidth = &Apache::lonxml::get_param('TeXwidth',$parstack,$safeeval);
+ my $LaTeXwidth = &Apache::lonxml::get_param('TeXwidth',$parstack,$safeeval,0);
if (defined $LaTeXwidth) {
if ($LaTeXwidth=~/^%/) {
substr($LaTeXwidth,0,1)='';
@@ -1348,12 +1468,29 @@ sub end_u {
#-- tag
sub start_ul {
- my ($target,$token) = @_;
+ my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
my $currentstring = '';
if ($target eq 'web') {
$currentstring = $token->[4];
} elsif ($target eq 'tex') {
- $currentstring = '\begin{itemize}';
+ my $TeXtype=&Apache::lonxml::get_param('type',$parstack,$safeeval,undef,0);
+ if ($TeXtype eq 'disc') {
+ $currentstring .= ' \renewcommand{\labelitemi}{$\bullet$}
+ \renewcommand{\labelitemii}{$\bullet$}
+ \renewcommand{\labelitemiii}{$\bullet$}
+ \renewcommand{\labelitemiv}{$\bullet$}';
+ } elsif ($TeXtype eq 'circle') {
+ $currentstring .= ' \renewcommand{\labelitemi}{$\circ$}
+ \renewcommand{\labelitemii}{$\circ$}
+ \renewcommand{\labelitemiii}{$\circ$}
+ \renewcommand{\labelitemiv}{$\circ$}';
+ } elsif ($TeXtype eq 'square') {
+ $currentstring .= ' \renewcommand{\labelitemi}{$\diamond$}
+ \renewcommand{\labelitemii}{$\diamond$}
+ \renewcommand{\labelitemiii}{$\diamond$}
+ \renewcommand{\labelitemiv}{$\diamond$}';
+ }
+ $currentstring .= '\begin{itemize}';
}
return $currentstring;
}
@@ -1364,7 +1501,10 @@ sub end_ul {
if ($target eq 'web') {
$currentstring = $token->[2];
} elsif ($target eq 'tex') {
- $currentstring = '\end{itemize}';
+ $currentstring = '\end{itemize} \renewcommand{\labelitemi}{$\bullet$}
+ \renewcommand{\labelitemii}{$\bullet$}
+ \renewcommand{\labelitemiii}{$\bullet$}
+ \renewcommand{\labelitemiv}{$\bullet$}';
}
return $currentstring;
}
@@ -1417,12 +1557,39 @@ sub end_dir {
#-- tag
sub start_ol {
- my ($target,$token) = @_;
+ my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
my $currentstring = '';
if ($target eq 'web') {
$currentstring = $token->[4];
} elsif ($target eq 'tex') {
- $currentstring = '\begin{enumerate}';
+ my $type=&Apache::lonxml::get_param('type',$parstack,$safeeval,undef,0);
+ if ($type eq '1') {
+ $currentstring .= ' \renewcommand{\labelenumi}{\arabic{enumi}.}
+ \renewcommand{\labelenumii}{\arabic{enumii}.}
+ \renewcommand{\labelenumiii}{\arabic{enumiii}.}
+ \renewcommand{\labelenumiv}{\arabic{enumiv}.}';
+ } elsif ($type eq 'A') {
+ $currentstring .= ' \renewcommand{\labelenumi}{\Alph{enumi}.}
+ \renewcommand{\labelenumii}{\Alph{enumii}.}
+ \renewcommand{\labelenumiii}{\Alph{enumiii}.}
+ \renewcommand{\labelenumiv}{\Alph{enumiv}.}';
+ } elsif ($type eq 'a') {
+ $currentstring .= ' \renewcommand{\labelenumi}{\alph{enumi}.}
+ \renewcommand{\labelenumii}{\alph{enumii}.}
+ \renewcommand{\labelenumiii}{\alph{enumiii}.}
+ \renewcommand{\labelenumiv}{\alph{enumiv}.} ';
+ } elsif ($type eq 'i') {
+ $currentstring .= ' \renewcommand{\labelenumi}{\roman{enumi}.}
+ \renewcommand{\labelenumii}{\roman{enumii}.}
+ \renewcommand{\labelenumiii}{\roman{enumiii}.}
+ \renewcommand{\labelenumiv}{\roman{enumiv}.} ';
+ } elsif ($type eq 'I') {
+ $currentstring .= ' \renewcommand{\labelenumi}{\Roman{enumi}.}
+ \renewcommand{\labelenumii}{\Roman{enumii}.}
+ \renewcommand{\labelenumiii}{\Roman{enumiii}.}
+ \renewcommand{\labelenumiv}{\Roman{enumiv}.} ';
+ }
+ $currentstring .= '\begin{enumerate}';
}
return $currentstring;
}
@@ -1433,7 +1600,10 @@ sub end_ol {
if ($target eq 'web') {
$currentstring = $token->[2];
} elsif ($target eq 'tex') {
- $currentstring = '\end{enumerate}';
+ $currentstring = '\end{enumerate} \renewcommand{\labelenumi}{\arabic{enumi}.}
+ \renewcommand{\labelenumii}{\arabic{enumii}.}
+ \renewcommand{\labelenumiii}{\arabic{enumiii}.}
+ \renewcommand{\labelenumiv}{\arabic{enumiv}.}';
}
return $currentstring;
}