--- loncom/xml/londefdef.pm 2003/04/10 14:31:09 1.124 +++ loncom/xml/londefdef.pm 2003/06/19 20:14:13 1.143 @@ -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.143 2003/06/19 20:14:13 sakharuk Exp $ # # # Copyright Michigan State University Board of Trustees @@ -54,7 +54,7 @@ use Apache::lonmeta(); BEGIN { - &Apache::lonxml::register('Apache::londefdef',('a','abbr','acronym','accessrule','address','allow','applet','area','b','base','basefont','bgo','bgsound','big','blink','blockquote','blankspace','body','br','button','caption','center','cite','code','col','colgroup','dd','del','dfn','dir','div','dl','dt','em','embed','externallink','fieldset','font','form','frame','frameset','h1','h2','h3','h4','h5','h6','head','hr','html','i','iframe','img','input','ins','insert','isindex','kbd','keygen','label','layer','legend','li','link','m','map','marquee','menu','meta','multicol','nobr','noembed','noframes','nolayer','noscript','object','ol','optgroup','option','output','p','param','pre','q','s','samp','select','server','small','spacer','span','strike','strong','sub','sup','table','tbody','td','textarea','tfoot','th','thead','title','tr','tt','tthoption','u','ul','var','wbr')); + &Apache::lonxml::register('Apache::londefdef',('a','abbr','acronym','accessrule','address','allow','applet','area','b','base','basefont','bgo','bgsound','big','blink','blockquote','blankspace','body','br','button','caption','center','cite','code','col','colgroup','dd','del','dfn','dir','div','dl','dt','em','embed','externallink','fieldset','font','form','frame','frameset','h1','h2','h3','h4','h5','h6','head','hr','html','i','iframe','img','input','ins','insert','isindex','kbd','keygen','label','layer','legend','li','link','m','map','marquee','menu','meta','multicol','nobr','noembed','noframes','nolayer','noscript','object','ol','optgroup','option','output','p','param','pre','q','s','samp','select','server','small','spacer','span','strike','strong','sub','sup','table','tbody','td','textarea','tfoot','th','thead','title','tr','tt','tthoption','u','ul','var','wbr','hideweboutput')); } @@ -158,6 +158,7 @@ sub start_html { } elsif ($target eq 'tex') { @Apache::londefdef::table = (); $currentstring .= '\documentclass[letterpaper]{article} + \batchmode \newcommand{\keephidden}[1]{} \renewcommand{\deg}{$^{\circ}$} \usepackage{textcomp} @@ -354,8 +355,7 @@ sub start_meta { } else { $currentstring = $token->[4]; } - } - if ($target eq 'meta') { + } elsif ($target eq 'meta') { unless (&Apache::lonxml::get_param ('http-equiv',$parstack,$safeeval,undef,1)) { my $name=$token->[2]->{'name'}; @@ -366,9 +366,11 @@ sub start_meta { $currentstring='<'.$name.'>'. &Apache::lonxml::get_param ('content',$parstack,$safeeval,undef,1). - ''; + ''; } } + } elsif ($target eq 'tex') { + &Apache::lonxml::startredirection(); } return $currentstring; } @@ -382,7 +384,10 @@ sub end_meta { if ($args ne '') { $currentstring = $token->[4]; } - } + } elsif ($target eq 'tex') { + $currentstring=&Apache::lonxml::endredirection(); + $currentstring=''; + } return $currentstring; } @@ -573,12 +578,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 +603,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 +627,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; } @@ -1013,7 +1138,7 @@ sub start_big { if ($target eq 'web') { $currentstring .= $token->[4]; } elsif ($target eq 'tex') { - $currentstring .= '\large{'; + $currentstring .= '{\large '; } elsif ($target eq 'latexsource') { $currentstring .= '{\Large '; } @@ -1062,20 +1187,30 @@ sub end_small { #-- tag sub start_basefont { - my ($target,$token) = @_; + my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_; my $currentstring = ''; if ($target eq 'web') { $currentstring = $token->[4]; - } + } elsif ($target eq 'tex') { + my $basesize=&Apache::lonxml::get_param('TeXsize',$parstack,$safeeval); + if (defined $basesize) { + $currentstring = '{\\'.$basesize.' '; + } + } return $currentstring; } sub end_basefont { - my ($target,$token) = @_; + my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_; my $currentstring = ''; if ($target eq 'web') { $currentstring = $token->[4]; - } + } elsif ($target eq 'tex') { + my $basesize=&Apache::lonxml::get_param('TeXsize',$parstack,$safeeval); + if (defined $basesize) { + $currentstring = '}'; + } + } return $currentstring; } @@ -1087,7 +1222,12 @@ sub start_font { my $face=&Apache::lonxml::get_param('face',$parstack,$safeeval); if ($face=~/symbol/i) {$Apache::lonxml::prevent_entity_encode++;} $currentstring = $token->[4]; - } + } elsif ($target eq 'tex') { + my $fontsize=&Apache::lonxml::get_param('TeXsize',$parstack,$safeeval); + if (defined $fontsize) { + $currentstring = '{\\'.$fontsize.' '; + } + } return $currentstring; } @@ -1098,7 +1238,12 @@ sub end_font { my $face=&Apache::lonxml::get_param('face',$parstack,$safeeval); if ($face=~/symbol/i) {$Apache::lonxml::prevent_entity_encode--;} $currentstring = $token->[2]; - } + } elsif ($target eq 'tex') { + my $fontsize=&Apache::lonxml::get_param('TeXsize',$parstack,$safeeval); + if (defined $fontsize) { + $currentstring = '}'; + } + } return $currentstring; } @@ -1207,7 +1352,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 +1493,29 @@ sub end_u { #--