[LON-CAPA-cvs] cvs: loncom /xml londefdef.pm

sakharuk lon-capa-cvs@mail.lon-capa.org
Fri, 11 Apr 2003 18:25:03 -0000


This is a MIME encoded message

--sakharuk1050085503
Content-Type: text/plain

sakharuk		Fri Apr 11 14:25:03 2003 EDT

  Modified files:              
    /loncom/xml	londefdef.pm 
  Log:
  1. Added atribute align in <hN> tags.
  2. Added attribute TeXsize in all <hN> tags to customize size in the LaTeX output. Possible values of TeXsize coincide with standard LaTeX ones (for example "Large", "small", ...).
  3. Added atribute type in <ol> tag. Now all standard possible types of html attributes are supported: 1, A, a, I, i. In addition they are work rather well in nested lists (by default up to depth=4, as in LaTeX itself).
  4. Added atribute type to <ul> tag. Now all standard possible types of html attributes are supported: disk, circle, and square (instead square I've used diamond in the LaTeX output - it looks better and supported more easily). Again, nested structures are supported up to standard LaTeX depth=4. More correctly, you can use as many nested structures as you want but system will care automatically (without definition of type attribute) only about 4 nested structures.   
  
  
--sakharuk1050085503
Content-Type: text/plain
Content-Disposition: attachment; filename="sakharuk-20030411142503.txt"

Index: loncom/xml/londefdef.pm
diff -u loncom/xml/londefdef.pm:1.124 loncom/xml/londefdef.pm:1.125
--- loncom/xml/londefdef.pm:1.124	Thu Apr 10 10:31:09 2003
+++ loncom/xml/londefdef.pm	Fri Apr 11 14:25:03 2003
@@ -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 @@
 
 #-- <h1> 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='<subject>';
 	&start_output();
@@ -587,12 +598,21 @@
 }
 
 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='</subject>';
@@ -602,115 +622,215 @@
 
 #-- <h2> 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;
 }
 
 #-- <h3> 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;
 }
 
 #-- <h4> 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;
 }
 
 #-- <h5> 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;
 }
 
 #-- <h6> 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 @@
     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 @@
 
 #-- <ul> 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 @@
     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 @@
 
 #-- <ol> 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 @@
     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;
 }

--sakharuk1050085503--