File:  [LON-CAPA] / loncom / xml / londefdef.pm
Revision 1.139: download - view: text, annotated - select for diffs
Thu Jun 19 14:58:39 2003 UTC (20 years, 10 months ago) by sakharuk
Branches: MAIN
CVS tags: HEAD
Very important change in the calculation of the table width. Till now I used only integer number (in mm) and the use of any fraction lead to unpredictable result. After this correction the final output for the tables has to be better. Nevertheless I stillhave to find the better way for taking into account the "internal" size of any table's element (any vertical line for the separation of columns -no matter real or not shown).

    1: # The LearningOnline Network with CAPA
    2: # Tags Default Definition Module 
    3: #
    4: # $Id: londefdef.pm,v 1.139 2003/06/19 14:58:39 sakharuk Exp $
    5: # 
    6: #
    7: # Copyright Michigan State University Board of Trustees
    8: #
    9: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
   10: #
   11: # LON-CAPA is free software; you can redistribute it and/or modify
   12: # it under the terms of the GNU General Public License as published by
   13: # the Free Software Foundation; either version 2 of the License, or
   14: # (at your option) any later version.
   15: #
   16: # LON-CAPA is distributed in the hope that it will be useful,
   17: # but WITHOUT ANY WARRANTY; without even the implied warranty of
   18: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   19: # GNU General Public License for more details.
   20: #
   21: # You should have received a copy of the GNU General Public License
   22: # along with LON-CAPA; if not, write to the Free Software
   23: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   24: #
   25: # /home/httpd/html/adm/gpl.txt
   26: #
   27: # http://www.lon-capa.org/
   28: #
   29: # Copyright for TtHfunc and TtMfunc by Ian Hutchinson. 
   30: # TtHfunc and TtMfunc (the "Code") may be compiled and linked into 
   31: # binary executable programs or libraries distributed by the 
   32: # Michigan State University (the "Licensee"), but any binaries so 
   33: # distributed are hereby licensed only for use in the context
   34: # of a program or computational system for which the Licensee is the 
   35: # primary author or distributor, and which performs substantial 
   36: # additional tasks beyond the translation of (La)TeX into HTML.
   37: # The C source of the Code may not be distributed by the Licensee
   38: # to any other parties under any circumstances.
   39: #
   40: #
   41: # last modified 06/26/00 by Alexander Sakharuk
   42: # 11/6,11/30,02/01/01,5/4 Gerd Kortemeyer
   43: # 01/18 Alex Sakharuk
   44: 
   45: package Apache::londefdef; 
   46: 
   47: use Apache::lonnet();
   48: use strict;
   49: use Apache::lonxml;
   50: use Apache::File();
   51: use Image::Magick;
   52: use Apache::lonmenu();
   53: use Apache::lonmeta();
   54: 
   55: BEGIN {
   56: 
   57:     &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'));
   58: 
   59: }
   60: 
   61: #======================= TAG SUBROUTINES =====================
   62: #-- <output>
   63: sub start_output {
   64:     my ($target) = @_;
   65:     if ($target eq 'meta') { $Apache::lonxml::metamode--; }
   66:     return '';
   67: }
   68: sub end_output {
   69:     my ($target) = @_;
   70:     if ($target eq 'meta') { $Apache::lonxml::metamode++; }
   71:     return '';
   72: }
   73: #-- <m> tag
   74: sub start_m {
   75:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
   76:     my $currentstring = '';
   77:     if ($target eq 'web') {
   78: 	$Apache::lonxml::prevent_entity_encode++;
   79: 	my $inside = &Apache::lonxml::get_all_text_unbalanced("/m",$parser);
   80: 	$inside ='\\documentstyle{article}'.$inside;
   81: 	&Apache::lonxml::debug("M is starting with:$inside:");
   82: 	my $eval=&Apache::lonxml::get_param('eval',$parstack,$safeeval);
   83: 	if ($eval eq 'on') {
   84: 	    $inside=&Apache::run::evaluate($inside,$safeeval,$$parstack[-1]);
   85: 	    #&Apache::lonxml::debug("M is evaulated to:$inside:");
   86: 	}
   87: 	$currentstring = &Apache::lontexconvert::converted(\$inside);
   88: 	if ($Apache::lontexconvert::errorstring) {
   89: 	    &Apache::lonxml::warning("tth error: ".
   90: 				     $Apache::lontexconvert::errorstring);
   91: 	    $Apache::lontexconvert::errorstring='';
   92: 	}
   93: 	#&Apache::lonxml::debug("M is ends with:$currentstring:");
   94:     } elsif ($target eq 'tex') {
   95: 	$currentstring = &Apache::lonxml::get_all_text_unbalanced("/m",$parser);
   96: 	if ($currentstring=~/^(\s*\\\\\s*)*$/) {$currentstring = ' \vskip 0 mm ';}
   97:     } else {
   98: 	my $inside = &Apache::lonxml::get_all_text_unbalanced("/m",$parser);
   99:     }
  100:     return $currentstring;
  101: }
  102: 
  103: sub end_m {
  104:     my ($target,$token) = @_;
  105:     my $currentstring = '';
  106:     if ($target eq 'web') {
  107: 	$Apache::lonxml::prevent_entity_encode--;
  108:     } elsif ($target eq 'tex') {
  109: 	$currentstring = "";
  110:     } elsif ($target eq 'meta') {
  111:     }
  112:     return $currentstring;
  113: }
  114: 
  115: sub start_tthoption {
  116:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
  117:     my $result;
  118:     if ($target eq 'web') {
  119: 	my $inside = &Apache::lonxml::get_all_text("/tthoption",$parser);
  120: 	$inside=~s/^\s*//;
  121: 	if ($ENV{'browser.mathml'}) {
  122: 	    &tth::ttmoptions($inside);
  123: 	} else {
  124: 	    &tth::tthoptions($inside);
  125: 	}
  126:     }
  127:     return $result;
  128: }
  129: 
  130: sub end_tthoption {
  131:     my ($target,$token) = @_;
  132:     my $result;
  133:     return $result;
  134: }
  135: 
  136: #-- <html> tag    
  137: sub start_html {
  138:     my ($target,$token) = @_;
  139:     my $currentstring = '';
  140:     if ($ENV{'browser.mathml'}) {
  141: 	&tth::ttminit();
  142: 	if ($ENV{'browser.unicode'}) {
  143: 	    &tth::ttmoptions('-L -u1');
  144: 	} else {
  145: 	    &tth::ttmoptions('-L -u0');
  146: 	}
  147:     } else {
  148: 	&tth::tthinit();
  149: 	if ($ENV{'browser.unicode'}) {
  150: 	    &tth::tthoptions('-L -u1');
  151: 	} else {
  152: 	    &tth::tthoptions('-L -u0');
  153: 	}
  154:     }
  155:     if ($target eq 'web') {
  156: 	$currentstring = &Apache::lonxml::xmlbegin().
  157: 	    &Apache::lonxml::fontsettings();     
  158:     } elsif ($target eq 'tex') {
  159: 	@Apache::londefdef::table = ();
  160: 	$currentstring .= '\documentclass[letterpaper]{article}
  161:                            \newcommand{\keephidden}[1]{}
  162:                            \renewcommand{\deg}{$^{\circ}$}
  163:                            \usepackage{textcomp}
  164:                            \usepackage[dvips]{graphicx}
  165:                            \usepackage{epsfig}\usepackage{calc}
  166: \newenvironment{choicelist}{\begin{list}{}{\setlength{\rightmargin}{0in}\setlength{\leftmargin}{0.13in}\setlength{\topsep}{0.05in}\setlength{\itemsep}{0.022in}\setlength{\parsep}{0in}\setlength{\belowdisplayskip}{0.04in}\setlength{\abovedisplayskip}{0.05in}\setlength{\abovedisplayshortskip}{-0.04in}\setlength{\belowdisplayshortskip}{0.04in}}}{\end{list}}';
  167:     }
  168:     return $currentstring;
  169: }
  170: 
  171: sub end_html {
  172:     my ($target,$token) = @_;
  173:     my $currentstring = '';
  174:     if ($target eq 'web') {
  175: 	$currentstring = &Apache::lonxml::xmlend();
  176:     }
  177:     return $currentstring;
  178: }
  179: 
  180: #-- <head> tag
  181: sub start_head {
  182:     my ($target,$token) = @_;
  183:     my $currentstring = '';
  184:     if ($target eq 'web') {
  185: 	$currentstring = $token->[4];     
  186:     } 
  187:     return $currentstring;
  188: }
  189: 
  190: sub end_head {
  191:     my ($target,$token) = @_;
  192:     my $currentstring = '';
  193:     if ($target eq 'web') {
  194: 	$currentstring = &Apache::lonmenu::registerurl(undef,$target).
  195: 	    $token->[2];    
  196:     } 
  197:     return $currentstring;
  198: }
  199: 
  200: #-- <map> tag
  201: sub start_map {
  202:     my ($target,$token) = @_;
  203:     my $currentstring = '';
  204:     if ($target eq 'web') {
  205: 	$currentstring = $token->[4];     
  206:     } 
  207:     return $currentstring;
  208: }
  209: 
  210: sub end_map {
  211:     my ($target,$token) = @_;
  212:     my $currentstring = '';
  213:     if ($target eq 'web') {
  214: 	$currentstring = $token->[2];    
  215:     } 
  216:     return $currentstring;
  217: }
  218: 
  219: #-- <select> tag
  220: sub start_select {
  221:     my ($target,$token) = @_;
  222:     my $currentstring = '';
  223:     if ($target eq 'web') {
  224: 	$currentstring = $token->[4];     
  225:     } 
  226:     return $currentstring;
  227: }
  228: 
  229: sub end_select {
  230:     my ($target,$token) = @_;
  231:     my $currentstring = '';
  232:     if ($target eq 'web') {
  233: 	$currentstring = $token->[2];    
  234:     } 
  235:     return $currentstring;
  236: }
  237: 
  238: #-- <option> tag
  239: sub start_option {
  240:     my ($target,$token) = @_;
  241:     my $currentstring = '';
  242:     if ($target eq 'web') {
  243: 	$currentstring = $token->[4];     
  244:     } 
  245:     return $currentstring;
  246: }
  247: 
  248: sub end_option {
  249:     my ($target,$token) = @_;
  250:     my $currentstring = '';
  251:     if ($target eq 'web') {
  252: 	$currentstring = $token->[2];    
  253:     } 
  254:     return $currentstring;
  255: }
  256: 
  257: #-- <input> tag
  258: sub start_input {
  259:     my ($target,$token) = @_;
  260:     my $currentstring = '';
  261:     if ($target eq 'web') {
  262: 	$currentstring = $token->[4];     
  263:     } 
  264:     return $currentstring;
  265: }
  266: 
  267: sub end_input {
  268:     my ($target,$token) = @_;
  269:     my $currentstring = '';
  270:     if ($target eq 'web') {
  271: 	$currentstring = $token->[2];    
  272:     } 
  273:     return $currentstring;
  274: }
  275: 
  276: #-- <textarea> tag
  277: sub start_textarea {
  278:     my ($target,$token) = @_;
  279:     my $currentstring = '';
  280:     if ($target eq 'web') {
  281: 	$currentstring = $token->[4];     
  282:     } 
  283:     return $currentstring;
  284: }
  285: 
  286: sub end_textarea {
  287:     my ($target,$token) = @_;
  288:     my $currentstring = '';
  289:     if ($target eq 'web') {
  290: 	$currentstring = $token->[2];    
  291:     } 
  292:     return $currentstring;
  293: }
  294: 
  295: #-- <form> tag
  296: sub start_form {
  297:     my ($target,$token) = @_;
  298:     my $currentstring = '';
  299:     if ($target eq 'web') {
  300: 	$currentstring = $token->[4];     
  301:     } 
  302:     return $currentstring;
  303: }
  304: 
  305: sub end_form {
  306:     my ($target,$token) = @_;
  307:     my $currentstring = '';
  308:     if ($target eq 'web') {
  309: 	$currentstring = $token->[2];    
  310:     } 
  311:     return $currentstring;
  312: }
  313: 
  314: #-- <title> tag
  315: sub start_title {
  316:     my ($target,$token) = @_;
  317:     my $currentstring = '';
  318:     if ($target eq 'web') {
  319: 	$currentstring = $token->[4];     
  320:     } elsif ($target eq 'tex') {
  321: 	$currentstring .= '\keephidden{' 
  322:     }
  323:     if ($target eq 'meta') {
  324: 	$currentstring='<title>';
  325: 	&start_output();
  326:     }
  327:     return $currentstring;
  328: }
  329: 
  330: sub end_title {
  331:     my ($target,$token) = @_;
  332:     my $currentstring = '';
  333:     if ($target eq 'web') {
  334: 	$currentstring = $token->[2];    
  335:     } elsif ($target eq 'tex') {
  336: 	$currentstring .= '}';
  337:     }  
  338:     if ($target eq 'meta') {
  339: 	&end_output();
  340: 	$currentstring='</title>';
  341:     } 
  342:     return $currentstring;
  343: }
  344: 
  345: #-- <meta> tag
  346: sub start_meta {
  347:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
  348:     my $currentstring = '';
  349:     if ($target eq 'web') {
  350: 	my $args='';
  351: 	if ( $#$parstack > -1 ) { $args=$$parstack[$#$parstack]; }
  352: 	if ($args eq '') {
  353: 	    &Apache::lonxml::get_all_text("/meta",$parser);
  354: 	} else {
  355: 	    $currentstring = $token->[4];
  356: 	}
  357:     } elsif ($target eq 'meta') {
  358: 	unless (&Apache::lonxml::get_param
  359: 		('http-equiv',$parstack,$safeeval,undef,1)) {
  360: 	    my $name=$token->[2]->{'name'};
  361: 	    $name=~tr/A-Z/a-z/;
  362: 	    $name=~s/\s/\_/gs;
  363: 	    $name=~s/\W//gs;
  364: 	    if ($name) {
  365: 		$currentstring='<'.$name.'>'.
  366: 		    &Apache::lonxml::get_param
  367: 			('content',$parstack,$safeeval,undef,1).
  368: 			'</'.$name.'>';
  369: 	    }
  370: 	}
  371:     } elsif ($target eq 'tex') {
  372: 	&Apache::lonxml::startredirection();
  373:     }
  374:     return $currentstring;
  375: }
  376: 
  377: sub end_meta {
  378:     my ($target,$token,$tagstack,$parstack,$parser) = @_;
  379:     my $currentstring = '';
  380:     if ($target eq 'web') {
  381: 	my $args='';
  382: 	if ( $#$parstack > -1 ) { $args=$$parstack[$#$parstack]; }
  383: 	if ($args ne '') {
  384: 	    $currentstring = $token->[4];
  385: 	}
  386:     } elsif ($target eq 'tex') {
  387: 	$currentstring=&Apache::lonxml::endredirection();
  388: 	$currentstring='';
  389:     }
  390:     return $currentstring;
  391: }
  392: 
  393: # accessrule
  394: sub start_accessrule {
  395:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
  396:     my $currentstring = '';
  397:     my $eff=&Apache::lonxml::get_param
  398: 	('effect',$parstack,$safeeval,undef,1);
  399:     my $realm=&Apache::lonxml::get_param
  400: 	('realm',$parstack,$safeeval,undef,1);
  401:     my $role=&Apache::lonxml::get_param
  402: 	('role',$parstack,$safeeval,undef,1);
  403:     $realm=~s/\s+//g;
  404:     $realm=~s/\//\_/g;
  405:     $realm=~s/^\_//;
  406:     $realm=~s/\W/\;/g;
  407:     $role=~s/\s+//g;
  408:     $role=~s/\//\_/g;
  409:     $role=~s/\W/\;/g;
  410:     if ($target eq 'web') {
  411: 	my $args='';
  412: 	if ( $#$parstack > -1 ) { $args=$$parstack[$#$parstack]; }
  413: 	if ($args eq '') {
  414: 	    &Apache::lonxml::get_all_text("/accessrule",$parser);
  415: 	} else {
  416: 	    $currentstring = $token->[4];
  417: 	}
  418:     }
  419:     if ($target eq 'meta') {
  420: 	$currentstring='<rule>'.$eff.':'.$realm.':'.$role.'</rule>';
  421:     }
  422:     return $currentstring;
  423: }
  424: 
  425: sub end_accessrule {
  426:     my ($target,$token,$tagstack,$parstack,$parser) = @_;
  427:     my $currentstring = '';
  428:     if ($target eq 'web') {
  429: 	my $args='';
  430: 	if ( $#$parstack > -1 ) { $args=$$parstack[$#$parstack]; }
  431: 	if ($args ne '') {
  432: 	    $currentstring = $token->[4];
  433: 	}
  434:     } 
  435:     return $currentstring;
  436: }
  437: 
  438: #-- <body> tag
  439: sub start_body {
  440:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
  441:     my $currentstring = '';
  442:     if ($target eq 'web') {
  443: 	if (!$Apache::lonxml::registered) {
  444: 	    $currentstring.='<head>'.
  445: 		&Apache::lonmenu::registerurl(undef,$target).'</head>';
  446: 	}
  447: 	my $onLoad='';
  448: 	foreach my $key (keys(%{$token->[2]})) {
  449: 	    if ($key =~ /^onload$/i) {
  450: 		$onLoad.=$token->[2]->{$key}.';';
  451: 		delete($token->[2]->{$key});
  452: 	    }
  453: 	}
  454: 	$token->[2]->{'onload'}=&Apache::lonmenu::loadevents().';'.$onLoad;
  455: 	my $onUnload='';
  456: 	foreach my $key (keys(%{$token->[2]})) {
  457: 	    if ($key =~ /^onunload$/i) {
  458: 		$onUnload.=$token->[2]->{$key}.';';
  459: 		delete($token->[2]->{$key});
  460: 	    }
  461: 	}
  462: 	$token->[2]->{'onunload'}=&Apache::lonmenu::unloadevents().
  463: 	    ';'.$onUnload;
  464: 	
  465: 	$currentstring .= '<'.$token->[1];
  466: 	foreach (keys %{$token->[2]}) {
  467: 	    $currentstring.=' '.$_.'="'.$token->[2]->{$_}.'"';
  468: 	}
  469: 	$currentstring.='>';
  470: 	if ($ENV{'request.state'} ne 'published') {
  471: 	    $currentstring.=(<<EDITBUTTON);
  472: 		<form method="post">
  473: 		<input type="submit" name="editmode" value="Edit" />
  474: 		</form>
  475: EDITBUTTON
  476: 	} else {
  477: 	    $currentstring.=&Apache::lonmenu::menubuttons(undef,$target,1);
  478: 	}
  479:     } elsif ($target eq 'tex') {
  480: 	$currentstring = '\begin{document}';  
  481:     } 
  482:     return $currentstring;
  483: }
  484: 
  485: sub end_body {
  486:     my ($target,$token) = @_;
  487:     my $currentstring = '';
  488:     if ($target eq 'web') {
  489: 	$currentstring = $token->[2];     
  490:     } elsif ($target eq 'tex') {
  491: 	$currentstring = '\end{document}';  
  492:     } 
  493:     return $currentstring;
  494: }
  495: 
  496: #-- <center> tag
  497: sub start_center {
  498:     my ($target,$token) = @_;
  499:     my $currentstring = '';
  500:     if ($target eq 'web') {
  501: 	$currentstring = $token->[4];     
  502:     } elsif ($target eq 'tex') {
  503: 	$currentstring = '\begin{center}';  
  504:     }  elsif ($target eq 'latexsource') {
  505: 	$currentstring = '\begin{center}';  
  506:     } 
  507:     return $currentstring;
  508: }
  509: 
  510: sub end_center {
  511:     my ($target,$token) = @_;
  512:     my $currentstring = '';
  513:     if ($target eq 'web') {
  514: 	$currentstring = $token->[2];     
  515:     } elsif ($target eq 'tex') {
  516: 	$currentstring = '\end{center}';  
  517:     }  elsif ($target eq 'latexsource') {
  518: 	$currentstring = '\end{center}';  
  519:     } 
  520:     return $currentstring;
  521: }
  522: 
  523: #-- <b> tag
  524: sub start_b {
  525:     my ($target,$token) = @_;
  526:     my $currentstring = '';
  527:     if ($target eq 'web') {
  528: 	$currentstring = $token->[4];     
  529:     } elsif ($target eq 'tex') {
  530: 	$currentstring = '\textbf{';  
  531:     }  elsif ($target eq 'latexsource') {
  532: 	$currentstring = '\textbf{';  
  533:     } 
  534:     return $currentstring;
  535: }
  536: 
  537: sub end_b {
  538:     my ($target,$token) = @_;
  539:     my $currentstring = '';
  540:     if ($target eq 'web') {
  541: 	$currentstring = $token->[2];     
  542:     } elsif ($target eq 'tex') {
  543: 	$currentstring = '}';  
  544:     } elsif ($target eq 'latexsource') {
  545: 	$currentstring = '}';  
  546:     } 
  547:     return $currentstring;
  548: }
  549: 
  550: #-- <strong> tag
  551: sub start_strong {
  552:     my ($target,$token) = @_;
  553:     my $currentstring = '';
  554:     if ($target eq 'web') {
  555: 	$currentstring = $token->[4];     
  556:     } elsif ($target eq 'tex') {
  557: 	$currentstring = '\textbf{';  
  558:     } elsif ($target eq 'latexsource') {
  559: 	$currentstring = '\textbf{';  
  560:     } 
  561:     return $currentstring;
  562: }
  563: 
  564: sub end_strong {
  565:     my ($target,$token) = @_;
  566:     my $currentstring = '';
  567:     if ($target eq 'web') {
  568: 	
  569: 	$currentstring = $token->[2];     
  570:     } elsif ($target eq 'tex') {
  571: 	$currentstring = '}';  
  572:     }  elsif ($target eq 'latexsource') {
  573: 	$currentstring = '}';  
  574:     } 
  575:     return $currentstring;
  576: }
  577: 
  578: #-- <h1> tag
  579: sub start_h1 {
  580:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
  581:     my $currentstring = '';
  582:     if ($target eq 'web') {
  583: 	$currentstring .= $token->[4];
  584:     } elsif ($target eq 'tex') {
  585: 	my $pre;
  586: 	my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1);
  587: 	if (($align eq 'center') || (not defined $align)) {
  588: 	    $pre='\begin{center}';
  589: 	} elsif ($align eq 'left') {
  590: 	    $pre='\rlap{';
  591: 	} elsif ($align eq 'right') {
  592: 	    $pre=' \hfill \llap{';
  593: 	}
  594: 	my $TeXsize=&Apache::lonxml::get_param('TeXsize',$parstack,$safeeval,undef,0);
  595: 	if (not defined $TeXsize) {$TeXsize="large";}
  596: 	$currentstring .= $pre.'{\\'.$TeXsize.' \textbf{'; 
  597:     } elsif ($target eq 'meta') {
  598: 	$currentstring='<subject>';
  599: 	&start_output();
  600:     }
  601:     return $currentstring;
  602: }
  603: 
  604: sub end_h1 {
  605:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
  606:     my $currentstring = '';
  607:     if ($target eq 'web') {
  608: 	$currentstring .= $token->[2];
  609:     } elsif ($target eq 'tex') {
  610: 	my $post;
  611: 	my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1);
  612: 	if (($align eq 'center') || (not defined $align)) {
  613: 	    $post='\end{center}';
  614: 	} elsif ($align eq 'left') {
  615: 	    $post='} \hfill'.'\vskip 0 mm ';
  616: 	} elsif ($align eq 'right') {
  617: 	    $post='}'.'\vskip 0 mm ';
  618: 	}
  619: 	$currentstring .= '}}'.$post;
  620:     } elsif ($target eq 'meta') {
  621: 	&end_output();
  622: 	$currentstring='</subject>';
  623:     } 
  624:     return $currentstring;
  625: }
  626: 
  627: #-- <h2> tag
  628: sub start_h2 {
  629:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
  630:     my $currentstring = '';
  631:     if ($target eq 'web') {
  632: 	$currentstring .= $token->[4];
  633:     } elsif ($target eq 'tex') {
  634: 	my $pre;
  635: 	my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1);
  636: 	if (($align eq 'center') || (not defined $align)) {
  637: 	    $pre='\begin{center}';
  638: 	} elsif ($align eq 'left') {
  639: 	    $pre='\rlap{';
  640: 	} elsif ($align eq 'right') {
  641: 	    $pre=' \hfill \llap{';
  642: 	}
  643: 	my $TeXsize=&Apache::lonxml::get_param('TeXsize',$parstack,$safeeval,undef,0);
  644: 	if (not defined $TeXsize) {$TeXsize="large";}
  645: 	$currentstring .= $pre.'{\\'.$TeXsize.' \textbf{'; 
  646:     } 
  647:     return $currentstring;
  648: }
  649: 
  650: sub end_h2 {
  651:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
  652:     my $currentstring = '';
  653:     if ($target eq 'web') {
  654: 	$currentstring .= $token->[2];
  655:     } elsif ($target eq 'tex') {
  656: 	my $post;
  657: 	my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1);
  658: 	if (($align eq 'center') || (not defined $align)) {
  659: 	    $post='\end{center}';
  660: 	} elsif ($align eq 'left') {
  661: 	    $post='} \hfill'.'\vskip 0 mm ';
  662: 	} elsif ($align eq 'right') {
  663: 	    $post='}'.'\vskip 0 mm ';
  664: 	}
  665: 	$currentstring .= '}}'.$post;
  666:     } 
  667:     return $currentstring;
  668: }
  669: 
  670: #-- <h3> tag
  671: sub start_h3 {
  672:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
  673:     my $currentstring = '';
  674:     if ($target eq 'web') {
  675: 	$currentstring .= $token->[4];
  676:     } elsif ($target eq 'tex') {
  677: 	my $pre;
  678: 	my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1);
  679: 	if (($align eq 'center') || (not defined $align)) {
  680: 	    $pre='\begin{center}';
  681: 	} elsif ($align eq 'left') {
  682: 	    $pre='\rlap{';
  683: 	} elsif ($align eq 'right') {
  684: 	    $pre=' \hfill \llap{';
  685: 	}
  686: 	my $TeXsize=&Apache::lonxml::get_param('TeXsize',$parstack,$safeeval,undef,0);
  687: 	if (not defined $TeXsize) {$TeXsize="large";}
  688: 	$currentstring .= $pre.'{\\'.$TeXsize.' \textbf{'; 
  689:     } 
  690:     return $currentstring;
  691: }
  692: 
  693: sub end_h3 {
  694:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
  695:     my $currentstring = '';
  696:     if ($target eq 'web') {
  697: 	$currentstring .= $token->[2];
  698:     } elsif ($target eq 'tex') {
  699: 	my $post;
  700: 	my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1);
  701: 	if (($align eq 'center') || (not defined $align)) {
  702: 	    $post='\end{center}';
  703: 	} elsif ($align eq 'left') {
  704: 	    $post='} \hfill'.'\vskip 0 mm ';
  705: 	} elsif ($align eq 'right') {
  706: 	    $post='}'.'\vskip 0 mm ';
  707: 	}
  708: 	$currentstring .= '}}'.$post;
  709:     } 
  710:     return $currentstring;
  711: }
  712: 
  713: #-- <h4> tag
  714: sub start_h4 {
  715:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
  716:     my $currentstring = '';
  717:     if ($target eq 'web') {
  718: 	$currentstring .= $token->[4];
  719:     } elsif ($target eq 'tex') {
  720: 	my $pre;
  721: 	my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1);
  722: 	if (($align eq 'center') || (not defined $align)) {
  723: 	    $pre='\begin{center}';
  724: 	} elsif ($align eq 'left') {
  725: 	    $pre='\rlap{';
  726: 	} elsif ($align eq 'right') {
  727: 	    $pre=' \hfill \llap{';
  728: 	}
  729: 	my $TeXsize=&Apache::lonxml::get_param('TeXsize',$parstack,$safeeval,undef,0);
  730: 	if (not defined $TeXsize) {$TeXsize="large";}
  731: 	$currentstring .= $pre.'{\\'.$TeXsize.' \textbf{'; 
  732:     } 
  733:     return $currentstring;
  734: }
  735: 
  736: sub end_h4 {
  737:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
  738:     my $currentstring = '';
  739:     if ($target eq 'web') {
  740: 	$currentstring .= $token->[2];
  741:     } elsif ($target eq 'tex') {
  742: 	my $post;
  743: 	my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1);
  744: 	if (($align eq 'center') || (not defined $align)) {
  745: 	    $post='\end{center}';
  746: 	} elsif ($align eq 'left') {
  747: 	    $post='} \hfill'.'\vskip 0 mm ';
  748: 	} elsif ($align eq 'right') {
  749: 	    $post='}'.'\vskip 0 mm ';
  750: 	}
  751: 	$currentstring .= '}}'.$post;
  752:     } 
  753:     return $currentstring;
  754: }
  755: 
  756: #-- <h5> tag
  757: sub start_h5 {
  758:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
  759:     my $currentstring = '';
  760:     if ($target eq 'web') {
  761: 	$currentstring .= $token->[4];
  762:     } elsif ($target eq 'tex') {
  763: 	my $pre;
  764: 	my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1);
  765: 	if (($align eq 'center') || (not defined $align)) {
  766: 	    $pre='\begin{center}';
  767: 	} elsif ($align eq 'left') {
  768: 	    $pre='\rlap{';
  769: 	} elsif ($align eq 'right') {
  770: 	    $pre=' \hfill \llap{';
  771: 	}
  772: 	my $TeXsize=&Apache::lonxml::get_param('TeXsize',$parstack,$safeeval,undef,0);
  773: 	if (not defined $TeXsize) {$TeXsize="large";}
  774: 	$currentstring .= $pre.'{\\'.$TeXsize.' \textbf{'; 
  775:     } 
  776:     return $currentstring;
  777: }
  778: 
  779: sub end_h5 {
  780:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
  781:     my $currentstring = '';
  782:     if ($target eq 'web') {
  783: 	$currentstring .= $token->[2];
  784:     } elsif ($target eq 'tex') {
  785: 	my $post;
  786: 	my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1);
  787: 	if (($align eq 'center') || (not defined $align)) {
  788: 	    $post='\end{center}';
  789: 	} elsif ($align eq 'left') {
  790: 	    $post='} \hfill'.'\vskip 0 mm ';
  791: 	} elsif ($align eq 'right') {
  792: 	    $post='}'.'\vskip 0 mm ';
  793: 	}
  794: 	$currentstring .= '}}'.$post;
  795:     } 
  796:     return $currentstring;
  797: }
  798: 
  799: #-- <h6> tag
  800: sub start_h6 {
  801:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
  802:     my $currentstring = '';
  803:     if ($target eq 'web') {
  804: 	$currentstring .= $token->[4];
  805:     } elsif ($target eq 'tex') {
  806: 	my $pre;
  807: 	my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1);
  808: 	if (($align eq 'center') || (not defined $align)) {
  809: 	    $pre='\begin{center}';
  810: 	} elsif ($align eq 'left') {
  811: 	    $pre='\rlap{';
  812: 	} elsif ($align eq 'right') {
  813: 	    $pre=' \hfill \llap{';
  814: 	}
  815: 	my $TeXsize=&Apache::lonxml::get_param('TeXsize',$parstack,$safeeval,undef,0);
  816: 	if (not defined $TeXsize) {$TeXsize="large";}
  817: 	$currentstring .= $pre.'{\\'.$TeXsize.' \textbf{'; 
  818:     } 
  819:     return $currentstring;
  820: }
  821: 
  822: sub end_h6 {
  823:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
  824:     my $currentstring = '';
  825:     if ($target eq 'web') {
  826: 	$currentstring .= $token->[2];
  827:     } elsif ($target eq 'tex') {
  828: 	my $post;
  829: 	my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1);
  830: 	if (($align eq 'center') || (not defined $align)) {
  831: 	    $post='\end{center}';
  832: 	} elsif ($align eq 'left') {
  833: 	    $post='} \hfill'.'\vskip 0 mm ';
  834: 	} elsif ($align eq 'right') {
  835: 	    $post='}'.'\vskip 0 mm ';
  836: 	}
  837: 	$currentstring .= '}}'.$post;
  838:     } 
  839:     return $currentstring;
  840: }
  841: 
  842: #--- <cite> tag
  843: sub start_cite {
  844:     my ($target,$token) = @_;
  845:     my $currentstring = '';
  846:     if ($target eq 'web') {
  847: 	$currentstring .= $token->[4];
  848:     } elsif ($target eq 'tex') {
  849: 	$currentstring .= "\\textit{";
  850:     }  elsif ($target eq 'latexsource') {
  851: 	$currentstring .= "\\textit{";
  852:     } 
  853:     return $currentstring;
  854: }
  855: 
  856: sub end_cite {
  857:     my ($target,$token) = @_;
  858:     my $currentstring = '';
  859:     if ($target eq 'web') {
  860: 	$currentstring .= $token->[2];
  861:     } elsif ($target eq 'tex') {
  862: 	$currentstring .= "}";
  863:     }  elsif ($target eq 'latexsource') {
  864: 	$currentstring .= "}";
  865:     } 
  866:     return $currentstring;
  867: }
  868: 
  869: #-- <i> tag
  870: sub start_i {
  871:     my ($target,$token) = @_;
  872:     my $currentstring = '';
  873:     if ($target eq 'web') {
  874: 	$currentstring .= $token->[4];
  875:     } elsif ($target eq 'tex') {
  876: 	$currentstring .= '\textit{';
  877:     }  elsif ($target eq 'latexsource') {
  878: 	$currentstring .= '\textit{';
  879:     } 
  880:     return $currentstring;
  881: }
  882: 
  883: sub end_i {
  884:     my ($target,$token) = @_;
  885:     my $currentstring = '';
  886:     if ($target eq 'web') {
  887: 	$currentstring .= $token->[2];
  888:     } elsif ($target eq 'tex') {
  889: 	$currentstring .= '}';
  890:     } elsif ($target eq 'latexsource') {
  891: 	$currentstring .= '}';
  892:     } 
  893:     return $currentstring;
  894: }
  895: 
  896: #-- <address> tag
  897: sub start_address {
  898:     my ($target,$token) = @_;
  899:     my $currentstring = '';
  900:     if ($target eq 'web') {
  901: 	$currentstring .= $token->[4];
  902:     } elsif ($target eq 'tex') {
  903: 	$currentstring .= "\\textit{";
  904:     } elsif ($target eq 'latexsource') {
  905: 	$currentstring .= "\\textit{";
  906:     } 
  907:     return $currentstring;
  908: }
  909: 
  910: sub end_address {
  911:     my ($target,$token) = @_;
  912:     my $currentstring = '';
  913:     if ($target eq 'web') {
  914: 	$currentstring .= $token->[2];
  915:     } elsif ($target eq 'tex') {
  916: 	$currentstring .= "}";
  917:     } elsif ($target eq 'latexsource') {
  918: 	$currentstring .= "}";
  919:     }
  920:     return $currentstring;
  921: }
  922: 
  923: #-- <dfn> tag
  924: sub start_dfn {
  925:     my ($target,$token) = @_;
  926:     my $currentstring = '';
  927:     if ($target eq 'web') {
  928: 	$currentstring .= $token->[4];
  929:     } elsif ($target eq 'tex') {
  930: 	$currentstring .= "\\textit{";
  931:     } elsif ($target eq 'latexsource') {
  932: 	$currentstring .= "\\textit{";
  933:     } 
  934:     return $currentstring;
  935: }
  936: 
  937: sub end_dfn {
  938:     my ($target,$token) = @_;
  939:     my $currentstring = '';
  940:     if ($target eq 'web') {
  941: 	$currentstring .= $token->[2];
  942:     } elsif ($target eq 'tex') {
  943: 	$currentstring .= "}";
  944:     } elsif ($target eq 'latexsource') {
  945: 	$currentstring .= "}";
  946:     } 
  947:     return $currentstring;
  948: }
  949: 
  950: #-- <tt> tag
  951: sub start_tt {
  952:     my ($target,$token) = @_;
  953:     my $currentstring = '';
  954:     if ($target eq 'web') {
  955: 	$currentstring .= $token->[4];
  956:     } elsif ($target eq 'tex') {
  957: 	$currentstring .= '\texttt{';
  958:     } elsif ($target eq 'latexsource') {
  959: 	$currentstring .= '\texttt{';
  960:     } 
  961:     return $currentstring;
  962: }
  963: 
  964: sub end_tt {
  965:     my ($target,$token) = @_;
  966:     my $currentstring = '';
  967:     if ($target eq 'web') {
  968: 	$currentstring .= $token->[2];
  969:     } elsif ($target eq 'tex') {
  970: 	$currentstring .= '}';
  971:     } elsif ($target eq 'latexsource') {
  972: 	$currentstring .= '}';
  973:     }
  974:     return $currentstring;
  975: }
  976: 
  977: #-- <kbd> tag
  978: sub start_kbd {
  979:     my ($target,$token) = @_;
  980:     my $currentstring = '';
  981:     if ($target eq 'web') {
  982: 	$currentstring .= $token->[4];
  983:     } elsif ($target eq 'tex') {
  984: 	$currentstring .= "\\texttt";
  985:     } elsif ($target eq 'latexsource') {
  986: 	$currentstring .= "\\texttt{";
  987:     } 
  988:     return $currentstring;
  989: }
  990: 
  991: sub end_kbd {
  992:     my ($target,$token) = @_;
  993:     my $currentstring = '';
  994:     if ($target eq 'web') {
  995: 	$currentstring .= $token->[2];
  996:     } elsif ($target eq 'tex') {
  997: 	$currentstring .= "}";
  998:     } elsif ($target eq 'latexsource') {
  999: 	$currentstring .= "}";
 1000:     } 
 1001:     return $currentstring;
 1002: }
 1003: 
 1004: #-- <code> tag
 1005: sub start_code {
 1006:     my ($target,$token) = @_;
 1007:     my $currentstring = '';
 1008:     if ($target eq 'web') {
 1009: 	$currentstring .= $token->[4];
 1010:     } elsif ($target eq 'tex') {
 1011: 	$currentstring .= '\texttt{';
 1012:     } 
 1013:     return $currentstring;
 1014: }
 1015: 
 1016: sub end_code {
 1017:     my ($target,$token) = @_;
 1018:     my $currentstring = '';
 1019:     if ($target eq 'web') {
 1020: 	$currentstring .= $token->[2];
 1021:     } elsif ($target eq 'tex') {
 1022: 	$currentstring .= '}';
 1023:     } 
 1024:     return $currentstring;
 1025: }
 1026: 
 1027: #-- <em> tag
 1028: sub start_em {
 1029:     my ($target,$token) = @_;
 1030:     my $currentstring = '';
 1031:     if ($target eq 'web') {
 1032: 	$currentstring .= $token->[4];
 1033:     } elsif ($target eq 'tex') {
 1034: 	$currentstring .= '\emph{';
 1035:     } elsif ($target eq 'latexsource') {
 1036: 	$currentstring .= '\emph{';
 1037:     } 
 1038:     return $currentstring;
 1039: }
 1040: 
 1041: sub end_em {
 1042:     my ($target,$token) = @_;
 1043:     my $currentstring = '';
 1044:     if ($target eq 'web') {
 1045: 	$currentstring .= $token->[2];
 1046:     } elsif ($target eq 'tex') {
 1047: 	$currentstring .= '}';
 1048:     } elsif ($target eq 'latexsource') {
 1049: 	$currentstring .= '}';
 1050:     }  
 1051:     return $currentstring;
 1052: }
 1053: 
 1054: #-- <q> tag
 1055: sub start_q {
 1056:     my ($target,$token) = @_;
 1057:     my $currentstring = '';
 1058:     if ($target eq 'web') {
 1059: 	$currentstring .= $token->[4];
 1060:     } elsif ($target eq 'tex') {
 1061: 	$currentstring .= "\\emph{";
 1062:     }  elsif ($target eq 'latexsource') {
 1063: 	$currentstring .= "\\emph{";
 1064:     }
 1065:     return $currentstring;
 1066: }
 1067: 
 1068: sub end_q {
 1069:     my ($target,$token) = @_;
 1070:     my $currentstring = '';
 1071:     if ($target eq 'web') {
 1072: 	$currentstring .= $token->[2];
 1073:     } elsif ($target eq 'tex') {
 1074: 	$currentstring .= "}";
 1075:     } elsif ($target eq 'latexsource') {
 1076: 	$currentstring .= "}";
 1077:     }  
 1078:     return $currentstring;
 1079: }
 1080: 
 1081: #-- <p> tag
 1082: sub start_p {
 1083:     my ($target,$token) = @_;
 1084:     my $currentstring = '';
 1085:     if ($target eq 'web') {
 1086: 	$currentstring .= $token->[4];
 1087:     } elsif ($target eq 'tex') {
 1088: 	$currentstring .= '{\par ';
 1089:     } elsif ($target eq 'latexsource') {
 1090: 	$currentstring .= '{\par ';
 1091:     } 
 1092:     return $currentstring;
 1093: }
 1094: 
 1095: sub end_p {
 1096:     my ($target,$token) = @_;
 1097:     my $currentstring = '';
 1098:     if ($target eq 'web') {
 1099: 	$currentstring .= $token->[2];
 1100:     } elsif ($target eq 'tex') {
 1101: 	$currentstring .= '}';
 1102:     } elsif ($target eq 'latexsource') {
 1103: 	$currentstring .= '}';
 1104:     }
 1105:     return $currentstring;
 1106: }
 1107: 
 1108: #-- <br> tag
 1109: sub start_br {
 1110:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
 1111:     my $currentstring = '';
 1112:     if ($target eq 'web') {
 1113: 	$currentstring .= $token->[4];
 1114:     } elsif ($target eq 'tex') {
 1115: 	if ($$tagstack[-2] ne 'sub' && $$tagstack[-2] ne 'sup') {
 1116: 	    $currentstring .= '\vskip 0.2 mm';
 1117: 	}
 1118:     } elsif ($target eq 'latexsource') {
 1119: 	$currentstring .= '\\';
 1120:     } 
 1121:     return $currentstring;
 1122: }
 1123: 
 1124: sub end_br {
 1125:     my ($target,$token) = @_;
 1126:     my $currentstring = '';
 1127:     if ($target eq 'web') {
 1128: 	$currentstring .= $token->[2];
 1129:     }
 1130:     return $currentstring;
 1131: }
 1132: 
 1133: #-- <big> tag
 1134: sub start_big {
 1135:     my ($target,$token) = @_;
 1136:     my $currentstring = '';
 1137:     if ($target eq 'web') {
 1138: 	$currentstring .= $token->[4];
 1139:     } elsif ($target eq 'tex') {
 1140: 	$currentstring .= '{\large ';
 1141:     } elsif ($target eq 'latexsource') {
 1142: 	$currentstring .= '{\Large ';
 1143:     }  
 1144:     return $currentstring;
 1145: }
 1146: 
 1147: sub end_big {
 1148:     my ($target,$token) = @_;
 1149:     my $currentstring = '';
 1150:     if ($target eq 'web') {
 1151: 	$currentstring .= $token->[2];
 1152:     } elsif ($target eq 'tex') {
 1153: 	$currentstring .= '}';
 1154:     } elsif ($target eq 'latexsource') {
 1155: 	$currentstring .= '}';
 1156:     }
 1157:     return $currentstring;
 1158: }
 1159: 
 1160: #-- <small> tag
 1161: sub start_small {
 1162:     my ($target,$token) = @_;
 1163:     my $currentstring = '';
 1164:     if ($target eq 'web') {
 1165: 	$currentstring .= $token->[4];
 1166:     } elsif ($target eq 'tex') {
 1167: 	$currentstring .= '{\footnotesize ';
 1168:     } elsif ($target eq 'latexsource') {
 1169: 	$currentstring .= '{\footnotesize ';
 1170:     } 
 1171:     return $currentstring;
 1172: }
 1173: 
 1174: sub end_small {
 1175:     my ($target,$token) = @_;
 1176:     my $currentstring = '';
 1177:     if ($target eq 'web') {
 1178: 	$currentstring .= $token->[2];
 1179:     } elsif ($target eq 'tex') {
 1180: 	$currentstring .= '}';
 1181:     } elsif ($target eq 'latexsource') {
 1182: 	$currentstring .= '}';
 1183:     }
 1184:     return $currentstring;
 1185: }
 1186: 
 1187: #-- <basefont> tag
 1188: sub start_basefont {
 1189:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
 1190:     my $currentstring = '';
 1191:     if ($target eq 'web') {
 1192: 	$currentstring = $token->[4];     
 1193:     } elsif ($target eq 'tex') {
 1194: 	my $basesize=&Apache::lonxml::get_param('TeXsize',$parstack,$safeeval);
 1195: 	if (defined $basesize) {
 1196: 	    $currentstring = '{\\'.$basesize.' ';
 1197: 	}
 1198:     }
 1199:     return $currentstring;
 1200: }
 1201: 
 1202: sub end_basefont {
 1203:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
 1204:     my $currentstring = '';
 1205:     if ($target eq 'web') {
 1206: 	$currentstring = $token->[4];     
 1207:     } elsif ($target eq 'tex') {
 1208: 	my $basesize=&Apache::lonxml::get_param('TeXsize',$parstack,$safeeval);
 1209: 	if (defined $basesize) {
 1210: 	    $currentstring = '}';
 1211: 	}
 1212:     }
 1213:     return $currentstring;
 1214: }
 1215: 
 1216: #-- <font> tag
 1217: sub start_font {
 1218:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
 1219:     my $currentstring = '';
 1220:     if ($target eq 'web') {
 1221: 	my $face=&Apache::lonxml::get_param('face',$parstack,$safeeval);
 1222: 	if ($face=~/symbol/i) {$Apache::lonxml::prevent_entity_encode++;}
 1223: 	$currentstring = $token->[4];     
 1224:     }  elsif ($target eq 'tex') {
 1225: 	my $fontsize=&Apache::lonxml::get_param('TeXsize',$parstack,$safeeval);
 1226: 	if (defined $fontsize) {
 1227: 	    $currentstring = '{\\'.$fontsize.' ';
 1228: 	}
 1229:     }
 1230:     return $currentstring;
 1231: }
 1232: 
 1233: sub end_font {
 1234:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
 1235:     my $currentstring = '';
 1236:     if ($target eq 'web') {
 1237: 	my $face=&Apache::lonxml::get_param('face',$parstack,$safeeval);
 1238: 	if ($face=~/symbol/i) {$Apache::lonxml::prevent_entity_encode--;}
 1239: 	$currentstring = $token->[2];    
 1240:     }  elsif ($target eq 'tex') {
 1241: 	my $fontsize=&Apache::lonxml::get_param('TeXsize',$parstack,$safeeval);
 1242: 	if (defined $fontsize) {
 1243: 	    $currentstring = '}';
 1244: 	}
 1245:     }
 1246:     return $currentstring;
 1247: }
 1248:  
 1249: #-- <strike> tag
 1250: sub start_strike {
 1251:     my ($target,$token) = @_;
 1252:     my $currentstring = '';
 1253:     if ($target eq 'web') {
 1254: 	$currentstring .= $token->[4];
 1255:     } elsif ($target eq 'tex') {
 1256: 	&Apache::lonxml::startredirection();
 1257:     } 
 1258:     return $currentstring;
 1259: }
 1260: 
 1261: sub end_strike {
 1262:     my ($target,$token) = @_;
 1263:     my $currentstring = '';
 1264:     if ($target eq 'web') {
 1265: 	$currentstring .= $token->[2];
 1266:     } elsif ($target eq 'tex') {
 1267: 	$currentstring=&Apache::lonxml::endredirection();
 1268: 	$currentstring=~s/(\S)(\s+)(\S)/$1\}$2\\underline\{$3/g; 
 1269: 	$currentstring=~s/^\s*(\S)/\\underline\{$1/; 
 1270: 	$currentstring=~s/(\S)\s*$/$1\}/;
 1271:     }
 1272:     return $currentstring;
 1273: }
 1274: 
 1275: #-- <s> tag
 1276: sub start_s {
 1277:     my ($target,$token) = @_;
 1278:     my $currentstring = '';
 1279:     if ($target eq 'web') {
 1280: 	$currentstring .= $token->[4];
 1281:     } elsif ($target eq 'tex') {
 1282: 	&Apache::lonxml::startredirection();
 1283:     } 
 1284:     return $currentstring;
 1285: }
 1286: 
 1287: sub end_s {
 1288:     my ($target,$token) = @_;
 1289:     my $currentstring = '';
 1290:     if ($target eq 'web') {
 1291: 	$currentstring .= $token->[2];
 1292:     } elsif ($target eq 'tex') {
 1293: 	$currentstring=&Apache::lonxml::endredirection();
 1294: 	$currentstring=~s/(\S)(\s+)(\S)/$1\}$2\\underline\{$3/g;
 1295: 	$currentstring=~s/^\s*(\S)/\\underline\{$1/;
 1296: 	$currentstring=~s/(\S)\s*$/$1\}/;	
 1297:     }
 1298:     return $currentstring;
 1299: }
 1300: 
 1301: #-- <sub> tag
 1302: sub start_sub {
 1303:     my ($target,$token) = @_;
 1304:     my $currentstring = '';
 1305:     if ($target eq 'web') {
 1306: 	$currentstring .= $token->[4];
 1307:     } elsif ($target eq 'tex') {
 1308: 	$currentstring .= "\$_{ ";
 1309:     } 
 1310:     return $currentstring;
 1311: }
 1312: 
 1313: sub end_sub {
 1314:     my ($target,$token) = @_;
 1315:     my $currentstring = '';
 1316:     if ($target eq 'web') {
 1317: 	$currentstring .= $token->[2];
 1318:     } elsif ($target eq 'tex') {
 1319: 	$currentstring .= " }\$";
 1320:     }
 1321:     return $currentstring;
 1322: }
 1323: 
 1324: #-- <sup> tag
 1325: sub start_sup {
 1326:     my ($target,$token) = @_;
 1327:     my $currentstring = '';
 1328:     if ($target eq 'web') {
 1329: 	$currentstring .= $token->[4];
 1330:     } elsif ($target eq 'tex') {
 1331: 	$currentstring .= "\$^{ ";
 1332:     } 
 1333:     return $currentstring;
 1334: }
 1335: 
 1336: sub end_sup {
 1337:     my ($target,$token) = @_;
 1338:     my $currentstring = '';
 1339:     if ($target eq 'web') {
 1340: 	$currentstring .= $token->[2];
 1341:     } elsif ($target eq 'tex') {
 1342: 	$currentstring .= " }\$";
 1343:     }
 1344:     return $currentstring;
 1345: }
 1346: 
 1347: #-- <hr> tag
 1348: sub start_hr {
 1349:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
 1350:     my $currentstring = '';
 1351:     if ($target eq 'web') {
 1352: 	$currentstring .= $token->[4];
 1353:     } elsif ($target eq 'tex') {
 1354: 	my $LaTeXwidth = &Apache::lonxml::get_param('TeXwidth',$parstack,$safeeval,0);
 1355: 	if (defined $LaTeXwidth) {
 1356: 	    if ($LaTeXwidth=~/^%/) {
 1357: 		substr($LaTeXwidth,0,1)='';
 1358: 		$LaTeXwidth=($LaTeXwidth/100).'\textwidth';
 1359: 	    }
 1360: 	} else {
 1361: 	    $LaTeXwidth ='0.95\textwidth';
 1362: 	}
 1363: 	my ($pre,$post);
 1364: 	my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1);
 1365: 	if (($align eq 'center') || (not defined $align)) {
 1366: 	    $pre=''; $post='';
 1367: 	} elsif ($align eq 'left') {
 1368: 	    $pre='\rlap{'; $post='} \hfill';
 1369: 	} elsif ($align eq 'right') {
 1370: 	    $pre=' \hfill \llap{'; $post='}';
 1371: 	}
 1372: 	$currentstring .= ' \vskip 0 mm \noindent\makebox[\textwidth]{'.$pre.'\makebox['.
 1373:                                     $LaTeXwidth.'][b]{\hrulefill}'.$post.'}\vskip 0 mm ';
 1374:     } 
 1375:     return $currentstring;
 1376: }
 1377: 
 1378: sub end_hr {
 1379:     my ($target,$token) = @_;
 1380:     my $currentstring = '';
 1381:     if ($target eq 'web') {
 1382: 	$currentstring .= $token->[2];
 1383:     } elsif ($target eq 'tex') {
 1384:     } 
 1385:     return $currentstring;
 1386: }
 1387: 
 1388: #-- <div> tag
 1389: sub start_div {
 1390:     my ($target,$token) = @_;
 1391:     my $currentstring = '';
 1392:     if ($target eq 'web') {
 1393: 	$currentstring .= $token->[4];
 1394:     } 
 1395:     return $currentstring;
 1396: }
 1397: 
 1398: sub end_div {
 1399:     my ($target,$token) = @_;
 1400:     my $currentstring = '';
 1401:     if ($target eq 'web') {
 1402: 	$currentstring .= $token->[2];
 1403:     } 
 1404:     return $currentstring;
 1405: }
 1406: 
 1407: #-- <a> tag
 1408: sub start_a {
 1409:     my ($target,$token) = @_;
 1410:     my $currentstring = '';
 1411:     if ($target eq 'web') {
 1412: 	$currentstring .= $token->[4];
 1413:     } elsif ($target eq 'tex') {
 1414:     }
 1415:     return $currentstring;
 1416: }
 1417: 
 1418: sub end_a {
 1419:     my ($target,$token,$tagstack,$stackref) = @_;
 1420:     my $currentstring = '';
 1421:     if ($target eq 'web') {
 1422: 	$currentstring .= $token->[2];
 1423:     } elsif ($target eq 'tex') {
 1424: 	my  $tempor_var = $stackref->[$#$stackref];
 1425: 	if (index($tempor_var,'name') != -1 ) {
 1426: 	    $tempor_var =~ s/name=([^,]*),/$1/g;
 1427: 	} elsif (index($tempor_var,'href') != -1 ) {
 1428: 	    $tempor_var =~ s/href=([^,]*),/$1/g;
 1429: 	    $currentstring .= " \\ref{$tempor_var}";
 1430: 	}
 1431:     }
 1432:     return $currentstring;
 1433: }
 1434: 
 1435: #-- <li> tag
 1436: sub start_li {
 1437:     my ($target,$token,$tagstack,$stackref) = @_;
 1438:     my $currentstring = '';
 1439:     if ($target eq 'web') {
 1440: 	$currentstring = $token->[4];     
 1441:     } elsif ($target eq 'tex') {
 1442: 	my  $tempor_var = $stackref->[$#$stackref];
 1443: 	if (index($tempor_var,'circle') != -1 ) {
 1444: 	    $currentstring .= " \\item[o] ";
 1445: 	} elsif (index($tempor_var,'square') != -1 ) {
 1446: 	    $currentstring .= " \\item[$\Box$] ";
 1447: 	} elsif ($tempor_var ne '') { 
 1448: 	    $_ = $tempor_var;
 1449: 	    m/my\s*([^=]*)=/;
 1450: 	    $currentstring .= " \\item[$1] ";
 1451: 	} else {
 1452: 	    $currentstring .= " \\item ";
 1453: 	}  
 1454:     } 
 1455:     return $currentstring;
 1456: }
 1457: 
 1458: sub end_li {
 1459:     my ($target,$token) = @_;
 1460:     my $currentstring = '';
 1461:     if ($target eq 'web') {
 1462: 	$currentstring = $token->[2];     
 1463:     } 
 1464:     return $currentstring;
 1465: }
 1466: 
 1467: #-- <u> tag
 1468: sub start_u {
 1469:     my ($target,$token) = @_;
 1470:     my $currentstring = '';
 1471:     if ($target eq 'web') {
 1472: 	$currentstring .= $token->[4];
 1473:     } elsif ($target eq 'tex') {
 1474: 	&Apache::lonxml::startredirection();
 1475:     } 
 1476:     return $currentstring;
 1477: }
 1478: 
 1479: sub end_u {
 1480:     my ($target,$token) = @_;
 1481:     my $currentstring = '';
 1482:     if ($target eq 'web') {
 1483: 	$currentstring .= $token->[2];
 1484:     } elsif ($target eq 'tex') {
 1485: 	$currentstring=&Apache::lonxml::endredirection();
 1486: 	$currentstring=~s/(\S)(\s+)(\S)/$1\}$2\\underline\{$3/g;
 1487: 	$currentstring=~s/^\s*(\S)/\\underline\{$1/;
 1488: 	$currentstring=~s/(\S)\s*$/$1\}/;		
 1489:     }
 1490:     return $currentstring;
 1491: }
 1492: 
 1493: #-- <ul> tag
 1494: sub start_ul {
 1495:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
 1496:     my $currentstring = '';
 1497:     if ($target eq 'web') {
 1498: 	$currentstring = $token->[4];     
 1499:     } elsif ($target eq 'tex') {
 1500: 	my $TeXtype=&Apache::lonxml::get_param('type',$parstack,$safeeval,undef,0);
 1501: 	if ($TeXtype eq 'disc') {
 1502: 	    $currentstring .= ' \renewcommand{\labelitemi}{$\bullet$}
 1503:                                 \renewcommand{\labelitemii}{$\bullet$} 
 1504:                                 \renewcommand{\labelitemiii}{$\bullet$}
 1505:                                 \renewcommand{\labelitemiv}{$\bullet$}';
 1506: 	} elsif ($TeXtype eq 'circle') {
 1507: 	    $currentstring .= ' \renewcommand{\labelitemi}{$\circ$}
 1508:                                 \renewcommand{\labelitemii}{$\circ$} 
 1509:                                 \renewcommand{\labelitemiii}{$\circ$}
 1510:                                 \renewcommand{\labelitemiv}{$\circ$}';
 1511: 	} elsif ($TeXtype eq 'square') {
 1512: 	    $currentstring .= ' \renewcommand{\labelitemi}{$\diamond$}
 1513:                                 \renewcommand{\labelitemii}{$\diamond$} 
 1514:                                 \renewcommand{\labelitemiii}{$\diamond$}
 1515:                                 \renewcommand{\labelitemiv}{$\diamond$}';
 1516: 	}
 1517: 	$currentstring .= '\begin{itemize}';  
 1518:     } 
 1519:     return $currentstring;
 1520: }
 1521: 
 1522: sub end_ul {
 1523:     my ($target,$token) = @_;
 1524:     my $currentstring = '';
 1525:     if ($target eq 'web') {
 1526: 	$currentstring = $token->[2];     
 1527:     } elsif ($target eq 'tex') {
 1528: 	$currentstring = '\end{itemize} \renewcommand{\labelitemi}{$\bullet$}
 1529:                                 \renewcommand{\labelitemii}{$\bullet$} 
 1530:                                 \renewcommand{\labelitemiii}{$\bullet$}
 1531:                                 \renewcommand{\labelitemiv}{$\bullet$}';  
 1532:     } 
 1533:     return $currentstring;
 1534: }
 1535: 
 1536: #-- <menu> tag
 1537: sub start_menu {
 1538:     my ($target,$token) = @_;
 1539:     my $currentstring = '';
 1540:     if ($target eq 'web') {
 1541: 	$currentstring = $token->[4];     
 1542:     } elsif ($target eq 'tex') {
 1543: 	$currentstring = " \\begin{itemize} ";  
 1544:     } 
 1545:     return $currentstring;
 1546: }
 1547: 
 1548: sub end_menu {
 1549:     my ($target,$token) = @_;
 1550:     my $currentstring = '';
 1551:     if ($target eq 'web') {
 1552: 	$currentstring = $token->[2];     
 1553:     } elsif ($target eq 'tex') {
 1554: 	$currentstring = " \\end{itemize}";  
 1555:     } 
 1556:     return $currentstring;
 1557: }
 1558: 
 1559: #-- <dir> tag
 1560: sub start_dir {
 1561:     my ($target,$token) = @_;
 1562:     my $currentstring = '';
 1563:     if ($target eq 'web') {
 1564: 	$currentstring = $token->[4];     
 1565:     } elsif ($target eq 'tex') {
 1566: 	$currentstring = " \\begin{itemize} ";  
 1567:     } 
 1568:     return $currentstring;
 1569: }
 1570: 
 1571: sub end_dir {
 1572:     my ($target,$token) = @_;
 1573:     my $currentstring = '';
 1574:     if ($target eq 'web') {
 1575: 	$currentstring = $token->[2];     
 1576:     } elsif ($target eq 'tex') {
 1577: 	$currentstring = " \\end{itemize}";  
 1578:     } 
 1579:     return $currentstring;
 1580: }
 1581: 
 1582: #-- <ol> tag
 1583: sub start_ol {
 1584:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
 1585:     my $currentstring = '';
 1586:     if ($target eq 'web') {
 1587: 	$currentstring = $token->[4];     
 1588:     } elsif ($target eq 'tex') {
 1589: 	my $type=&Apache::lonxml::get_param('type',$parstack,$safeeval,undef,0);
 1590: 	if ($type eq '1') {
 1591: 	    $currentstring .= ' \renewcommand{\labelenumi}{\arabic{enumi}.}
 1592:                                 \renewcommand{\labelenumii}{\arabic{enumii}.} 
 1593:                                 \renewcommand{\labelenumiii}{\arabic{enumiii}.}
 1594:                                 \renewcommand{\labelenumiv}{\arabic{enumiv}.}';
 1595: 	} elsif ($type eq 'A') {
 1596: 	    $currentstring .= ' \renewcommand{\labelenumi}{\Alph{enumi}.}
 1597:                                 \renewcommand{\labelenumii}{\Alph{enumii}.} 
 1598:                                 \renewcommand{\labelenumiii}{\Alph{enumiii}.}
 1599:                                 \renewcommand{\labelenumiv}{\Alph{enumiv}.}';
 1600: 	} elsif ($type eq 'a') {
 1601: 	    $currentstring .= ' \renewcommand{\labelenumi}{\alph{enumi}.}
 1602:                                 \renewcommand{\labelenumii}{\alph{enumii}.}
 1603:                                 \renewcommand{\labelenumiii}{\alph{enumiii}.}
 1604:                                 \renewcommand{\labelenumiv}{\alph{enumiv}.} ';
 1605: 	} elsif ($type eq 'i') {
 1606: 	    $currentstring .= ' \renewcommand{\labelenumi}{\roman{enumi}.}
 1607:                                 \renewcommand{\labelenumii}{\roman{enumii}.}
 1608:                                 \renewcommand{\labelenumiii}{\roman{enumiii}.}
 1609:                                 \renewcommand{\labelenumiv}{\roman{enumiv}.} ';
 1610: 	} elsif ($type eq 'I') {
 1611: 	    $currentstring .= ' \renewcommand{\labelenumi}{\Roman{enumi}.}
 1612:                                 \renewcommand{\labelenumii}{\Roman{enumii}.}
 1613:                                 \renewcommand{\labelenumiii}{\Roman{enumiii}.}
 1614:                                 \renewcommand{\labelenumiv}{\Roman{enumiv}.} ';
 1615: 	}
 1616: 	$currentstring .= '\begin{enumerate}';  
 1617:     } 
 1618:     return $currentstring;
 1619: }
 1620: 
 1621: sub end_ol {
 1622:     my ($target,$token) = @_;
 1623:     my $currentstring = '';
 1624:     if ($target eq 'web') {
 1625: 	$currentstring = $token->[2];     
 1626:     } elsif ($target eq 'tex') {
 1627: 	$currentstring = '\end{enumerate} \renewcommand{\labelenumi}{\arabic{enumi}.}
 1628:                                           \renewcommand{\labelenumii}{\arabic{enumii}.}
 1629:                                           \renewcommand{\labelenumiii}{\arabic{enumiii}.}
 1630:                                           \renewcommand{\labelenumiv}{\arabic{enumiv}.}';  
 1631:     } 
 1632:     return $currentstring;
 1633: }
 1634: 
 1635: #-- <dl> tag
 1636: sub start_dl {
 1637:     my ($target,$token) = @_;
 1638:     my $currentstring = '';
 1639:     if ($target eq 'web') {
 1640: 	$currentstring = $token->[4];     
 1641:     } elsif ($target eq 'tex') {
 1642: 	$currentstring = '\begin{description}';  
 1643:     } 
 1644:     return $currentstring;
 1645: }
 1646: 
 1647: sub end_dl {
 1648:     my ($target,$token) = @_;
 1649:     my $currentstring = '';
 1650:     if ($target eq 'web') {
 1651: 	$currentstring = $token->[2];     
 1652:     } elsif ($target eq 'tex') {
 1653: 	$currentstring = '\end{description}';  
 1654:     } 
 1655:     return $currentstring;
 1656: }
 1657: 
 1658: #-- <dt> tag
 1659: sub start_dt {
 1660:     my ($target,$token) = @_;
 1661:     my $currentstring = '';
 1662:     if ($target eq 'web') {
 1663: 	$currentstring = $token->[4];     
 1664:     } elsif ($target eq 'tex') {
 1665: 	$currentstring = '\item[';  
 1666:     } 
 1667:     return $currentstring;
 1668: }
 1669: 
 1670: sub end_dt {
 1671:     my ($target,$token) = @_;
 1672:     my $currentstring = '';
 1673:     if ($target eq 'web') {
 1674: 	$currentstring = $token->[2];    
 1675:     } elsif ($target eq 'tex') {
 1676: 	$currentstring = ']';  
 1677:     } 
 1678:     return $currentstring;
 1679: }
 1680: 
 1681: #-- <dd> tag
 1682: sub start_dd {
 1683:     my ($target,$token) = @_;
 1684:     my $currentstring = '';
 1685:     if ($target eq 'web') {
 1686: 	$currentstring = $token->[4];     
 1687:     } 
 1688:     return $currentstring;
 1689: }
 1690: 
 1691: sub end_dd {
 1692:     my ($target,$token) = @_;
 1693:     my $currentstring = '';
 1694:     if ($target eq 'web') {
 1695: 	$currentstring = $token->[2];    
 1696:     } 
 1697:     return $currentstring;
 1698: }
 1699: 
 1700: #-- <table> tag
 1701: sub start_table {
 1702:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
 1703:     my $textwidth;
 1704:     if (not defined @Apache::londefdef::table) {
 1705: 	$textwidth=&recalc($ENV{'form.textwidth'});
 1706: 	$textwidth=~/(\d+\.?\d*)/;
 1707: 	$textwidth=0.95*$1;
 1708:     } else {
 1709: 	$textwidth=&Apache::lonxml::get_param('TeXwidth',$parstack,$safeeval,undef,0);
 1710:     }
 1711:     my $currentstring = '';
 1712:     if ($target eq 'web') {
 1713: 	$currentstring = $token->[4];     
 1714:     } elsif ($target eq 'tex') {
 1715: 	my $aa = {};
 1716: 	push @Apache::londefdef::table, $aa; 
 1717: 	$Apache::londefdef::table[-1]{'row_number'} = -1;
 1718:         #table's width
 1719: 	my $TeXwidth = &Apache::lonxml::get_param('TeXwidth',$parstack,$safeeval,undef,0);
 1720: 	if (not defined $TeXwidth) {
 1721: 	    my $htmlwidth = &Apache::lonxml::get_param('width',$parstack,$safeeval,undef,1);
 1722: 	    if ($htmlwidth=~/%/) {
 1723: 		$htmlwidth=~/(\d+)/;
 1724: 		my $value=$1*$textwidth/100;
 1725: 		$Apache::londefdef::table[-1]{'width'}=$value;
 1726: 	    } else {
 1727: 		$Apache::londefdef::table[-1]{'width'}=$textwidth;
 1728: 	    }
 1729: 	} elsif ($TeXwidth=~/%/) {
 1730: 	    $TeXwidth=~/(\d+)/;
 1731: 	    my $value=$1*$textwidth/100;
 1732:             $Apache::londefdef::table[-1]{'width'}=$value;
 1733: 	} else {
 1734: 	    $Apache::londefdef::table[-1]{'width'}=$textwidth;
 1735: 	}        
 1736:         #table's border
 1737: 	my $border = &Apache::lonxml::get_param('border',$parstack,$safeeval,undef,1); 
 1738: 	unless (defined $border) { $border = 0; }
 1739: 	if ($border) { 
 1740: 	    $Apache::londefdef::table[-1]{'hinc'} = '\hline '; 
 1741: 	    $Apache::londefdef::table[-1]{'vinc'} = '&'; 
 1742: 	    $Apache::londefdef::table[-1]{'vvinc'} = '|';
 1743: 	} else {
 1744: 	    $Apache::londefdef::table[-1]{'hinc'} = ''; 
 1745: 	    $Apache::londefdef::table[-1]{'vinc'} = '&'; 
 1746: 	    $Apache::londefdef::table[-1]{'vvinc'} = '';
 1747: 	}
 1748: 	$Apache::londefdef::table[-1]{'output'} = ' \noindent \begin{tabular} ';
 1749: 	$currentstring = '\keephidden{NEW TABLE ENTRY '.$textwidth.'}';
 1750:     }
 1751:     return $currentstring;
 1752: }
 1753:  
 1754: sub end_table {
 1755:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
 1756:     my $currentstring = '';
 1757:     if ($target eq 'web') {
 1758: 	$currentstring = $token->[2];     
 1759:     } elsif ($target eq 'tex') {
 1760: 	my $inmemory = '';
 1761: 	my $output = '';
 1762: 	#construct header of the table
 1763: 	my $header_of_table = '{'.$Apache::londefdef::table[-1]{'vvinc'};
 1764: 	for (my $in=0;$in<=$Apache::londefdef::table[-1]{'counter_columns'};$in++) {
 1765: 	    $header_of_table .= $Apache::londefdef::table[-1]{'columns'}[$in].$Apache::londefdef::table[-1]{'vvinc'};
 1766: 	}
 1767: 	$header_of_table .= '}';
 1768: 	#define the length of the table cells
 1769: 	#always starts with TeXwidth (if defined everything else is ignored)
 1770: 	my @length_row_final = split(/,/,$Apache::londefdef::table[-1]{'TeXlengthrow'}[0]);
 1771: 	for (my $in=1;$in<=$Apache::londefdef::table[-1]{'row_number'};$in++) {
 1772: 	    my @length_row = split(/,/,$Apache::londefdef::table[-1]{'TeXlengthrow'}[$in]);
 1773: 	    for (my $jn=0;$jn<=$#length_row;$jn++) {
 1774: 		if ($length_row_final[$jn]<$length_row[$jn]) {$length_row_final[$jn]=$length_row[$jn];}
 1775: 	    }
 1776: 	}
 1777: 	#continues trying estimate the width of raw data
 1778: 	my @length_raw_row = split(/,/,$Apache::londefdef::table[-1]{'lengthrow'}[0]);
 1779: 	for (my $in=1;$in<=$Apache::londefdef::table[-1]{'row_number'};$in++) {
 1780: 	    my @length_row = split(/,/,$Apache::londefdef::table[-1]{'lengthrow'}[$in]);
 1781: 	    for (my $jn=0;$jn<=$#length_row;$jn++) {
 1782: 		if ($length_raw_row[$jn]<$length_row[$jn]) {$length_raw_row[$jn]=$length_row[$jn];}
 1783: 	    }
 1784: 	}
 1785:         #comparing of TeXwidth and raw data width
 1786: 	my $available_length=$Apache::londefdef::table[-1]{'width'};
 1787: 	my $needed=0;
 1788: 	for (my $jn=0;$jn<=$#length_row_final;$jn++) {
 1789: 	    if ($length_row_final[$jn]!=0) {
 1790: 		$available_length=$available_length-$length_row_final[$jn];
 1791: 		$needed++;
 1792: 	    }
 1793: 	}
 1794: 	$needed=$#length_row_final-$needed+1;
 1795: 	for (my $jn=0;$jn<=$#length_row_final;$jn++) {
 1796: 	    if ($length_row_final[$jn]==0) {
 1797: 		if ($length_raw_row[$jn]<$available_length/3) {
 1798: 		    $length_row_final[$jn]=$length_raw_row[$jn];
 1799: 		    $available_length=$available_length-$length_raw_row[$jn];
 1800: 		    $needed--;
 1801: 		}
 1802: 	    }
 1803: 	}
 1804: 	for (my $jn=0;$jn<=$#length_row_final;$jn++) {
 1805: 	    if ($length_row_final[$jn]==0) {
 1806: 		$length_row_final[$jn]=0.9*$available_length/$needed;
 1807: 	    }
 1808: 	}
 1809: 	#fill the table
 1810: 	for (my $in=0;$in<=$Apache::londefdef::table[-1]{'row_number'};$in++) {
 1811: 	    for (my $jn=0;$jn<=$#length_row_final;$jn++) {
 1812: 		my $substituted=$length_row_final[$jn];
 1813: 		$Apache::londefdef::table[-1]{'rowdata'}[$in]=~s/TOBECHANGEDONNUMBER/$substituted mm/;
 1814: 	    }
 1815: 	    $output .=  $Apache::londefdef::table[-1]{'rowdata'}[$in];
 1816: 	    chop $output;
 1817: 	    $output .= ' \\\\ ';
 1818: 	}
 1819: 	$Apache::londefdef::table[-1]{'output'} .= $header_of_table.$output.$Apache::londefdef::table[-1]{'hinc'}.'\end{tabular}\vskip 0 mm ';
 1820: 	if ($#Apache::londefdef::table > 0) {	    
 1821: 	    my $inmemory = $Apache::londefdef::table[-1]{'output'};
 1822: 	    pop @Apache::londefdef::table;
 1823: 	    push @{$Apache::londefdef::table[-1]{'include'}}, $inmemory;
 1824: 	} else {
 1825: 	    $currentstring .= $Apache::londefdef::table[-1]{'output'};
 1826: 	    pop @Apache::londefdef::table;
 1827: 	}
 1828:     }
 1829:     return $currentstring;
 1830: }
 1831: 
 1832: #-- <tr> tag
 1833: sub start_tr {
 1834:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
 1835:     my $currentstring = '';
 1836:     if ($target eq 'web') {
 1837: 	$currentstring = $token->[4];     
 1838:     } elsif ($target eq 'tex') {
 1839: 	$Apache::londefdef::table[-1]{'row_number'}++;
 1840: 	my $alignchar = substr(&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1),0,1);
 1841: 	if ($alignchar ne '') {
 1842: 	    push @ {$Apache::londefdef::table[-1]{'rows'} }, $alignchar;
 1843: 	} else {
 1844: 	    push @ {$Apache::londefdef::table[-1]{'rows'} }, 'l';
 1845: 	}
 1846: 	push ( @{ $Apache::londefdef::table[-1]{'rowdata'} }, $Apache::londefdef::table[-1]{'hinc'});
 1847: 	$Apache::londefdef::table[-1]{'counter_columns'} = -1;
 1848: 	$Apache::londefdef::table[-1]{'TeXlength'} = '';
 1849:  	$Apache::londefdef::table[-1]{'length'} = '';
 1850:     } 
 1851:     return $currentstring;
 1852: }
 1853:         
 1854: sub end_tr {
 1855:     my ($target,$token) = @_;
 1856:     my $currentstring = '';
 1857:     if ($target eq 'web') {
 1858: 	$currentstring = $token->[2];     
 1859:     } elsif ($target eq 'tex') {
 1860: 	push @{ $Apache::londefdef::table[-1]{'TeXlengthrow'} },$Apache::londefdef::table[-1]{'TeXlength'};
 1861: 	push @{ $Apache::londefdef::table[-1]{'lengthrow'} },$Apache::londefdef::table[-1]{'length'};
 1862:     }
 1863:     return $currentstring;
 1864: }
 1865: 
 1866: #-- <td> tag
 1867: sub start_td {
 1868:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
 1869:     my $currentstring = '';
 1870:     if ($target eq 'web') {
 1871: 	$currentstring = $token->[4];     
 1872:     } elsif ($target eq 'tex') {
 1873: 	my $what_to_push = substr(&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1),0,1);
 1874: 	if ($what_to_push eq '') {
 1875: 	    $what_to_push = substr($Apache::londefdef::table[-1]{'rows'}[0],0,1);;
 1876: 	}
 1877: 	push @{ $Apache::londefdef::table[-1]{'columns'} }, $what_to_push;
 1878: 	$Apache::londefdef::table[-1]{'counter_columns'}++;
 1879: 	&Apache::lonxml::startredirection();
 1880:     } 
 1881:     return $currentstring;
 1882: }   
 1883:      
 1884: sub end_td {
 1885:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
 1886:     my $currentstring = '';
 1887:     if ($target eq 'web') {
 1888: 	$currentstring = $token->[2];     
 1889:     } elsif ($target eq 'tex') {
 1890: 	my $current_row = $Apache::londefdef::table[-1]{'row_number'};
 1891: 	my $data=&Apache::lonxml::endredirection();
 1892: 	my $TeXwidth=&Apache::lonxml::get_param('TeXwidth',$parstack,$safeeval,undef,0);
 1893: 	if (defined $TeXwidth) {		
 1894: 	    my $current_length=&recalc($TeXwidth);
 1895: 	    $current_length=~/(\d+)/;
 1896: 	    $Apache::londefdef::table[-1]{'TeXlength'} .= $1.',';
 1897: 	    $Apache::londefdef::table[-1]{'length'} .= '0,';
 1898: 	} else {
 1899: 	    if ($data=~m/width\s*=\s*(\d+\.?\d*\s*(mm|cm|in|pc|pt)*)/) {
 1900: 		my $current_length=&recalc($1);
 1901: 		$current_length=~/(\d+\.?\d*)/;
 1902: 		$Apache::londefdef::table[-1]{'TeXlength'} .= $1.',';
 1903: 		$Apache::londefdef::table[-1]{'length'} .= '0,';
 1904: 	    } else {     
 1905: 		$data=~/^\s*(\S.*)/;
 1906: 		$data=$1;
 1907: 		$data=~/(.*\S)\s*$/;
 1908: 		$data=$1;
 1909: 		my $current_length=2*length($data);
 1910: 		$Apache::londefdef::table[-1]{'length'} .= $current_length.',';
 1911: 		$Apache::londefdef::table[-1]{'TeXlength'} .= '0,';
 1912: 	    }        
 1913: 	}
 1914: 	for (my $in=0; $in<=$#{$Apache::londefdef::table[-1]{'include'}};$in++) {                                
 1915: 	    $data=~s/\\keephidden\{NEW TABLE ENTRY\}/$Apache::londefdef::table[-1]{'include'}[$in]/;
 1916: 	}
 1917: 	@{ $Apache::londefdef::table[-1]{'rowdata'} }[$current_row] .= '\parbox{TOBECHANGEDONNUMBER}{'.$data.'} '.$Apache::londefdef::table[-1]{'vinc'};
 1918:     }
 1919:     return $currentstring;
 1920: }
 1921: 
 1922: #-- <th> tag
 1923: sub start_th {
 1924:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
 1925:     my $currentstring = '';
 1926:     if ($target eq 'web') {
 1927: 	$currentstring = $token->[4];     
 1928:     } elsif ($target eq 'tex') {
 1929: 	my $what_to_push = substr(&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1),0,1);
 1930: 	if ($what_to_push eq '') {
 1931: 	    $what_to_push = substr($Apache::londefdef::table[-1]{'rows'}[0],0,1);;
 1932: 	}
 1933: 	push @{ $Apache::londefdef::table[-1]{'columns'} }, $what_to_push;
 1934: 	$Apache::londefdef::table[-1]{'counter_columns'}++;
 1935: 	&Apache::lonxml::startredirection();
 1936:     } 
 1937:     return $currentstring;
 1938: }   
 1939:      
 1940: sub end_th {
 1941:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
 1942:     my $currentstring = '';
 1943:     if ($target eq 'web') {
 1944: 	$currentstring = $token->[2];     
 1945:     } elsif ($target eq 'tex') {
 1946: 	my $current_row = $Apache::londefdef::table[-1]{'row_number'};
 1947: 	my $data=&Apache::lonxml::endredirection();
 1948: 	my $TeXwidth=&Apache::lonxml::get_param('TeXwidth',$parstack,$safeeval,undef,0);
 1949: 	if (defined $TeXwidth) {		
 1950: 	    my $current_length=&recalc($TeXwidth);
 1951: 	    $current_length=~/(\d+)/;
 1952: 	    $Apache::londefdef::table[-1]{'TeXlength'} .= $1.',';
 1953: 	    $Apache::londefdef::table[-1]{'length'} .= '0,';
 1954: 	} else {
 1955: 	    if ($data=~m/width\s*=\s*(\d+\.?\d*\s*(mm|cm|in|pc|pt)*)/) {
 1956: 		my $current_length=&recalc($1);
 1957: 		$current_length=~/(\d+)/;
 1958: 		$Apache::londefdef::table[-1]{'TeXlength'} .= $1.',';
 1959: 		$Apache::londefdef::table[-1]{'length'} .= '0,';
 1960: 	    } else {     
 1961: 		$data=~/^\s*(\S.*)/;
 1962: 		$data=$1;
 1963: 		$data=~/(.*\S)\s*$/;
 1964: 		$data=$1;
 1965: 		my $current_length=2*length($data);
 1966: 		$Apache::londefdef::table[-1]{'length'} .= $current_length.',';
 1967: 		$Apache::londefdef::table[-1]{'TeXlength'} .= '0,';
 1968: 	    }        
 1969: 	}
 1970: 	for (my $in=0; $in<=$#{$Apache::londefdef::table[-1]{'include'}};$in++) {                                
 1971: 	    $data=~s/\\keephidden\{NEW TABLE ENTRY\}/$Apache::londefdef::table[-1]{'include'}[$in]/;
 1972: 	}
 1973: 	$data='\textbf{'.$data.'}';
 1974: 	@{ $Apache::londefdef::table[-1]{'rowdata'} }[$current_row] .= '\parbox{TOBECHANGEDONNUMBER}{'.$data.'} '.$Apache::londefdef::table[-1]{'vinc'};
 1975:     }
 1976:     return $currentstring;
 1977: }
 1978: #-- <img> tag
 1979: sub start_img {
 1980:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
 1981:     my $src = &Apache::lonxml::get_param('src',$parstack,$safeeval,
 1982: 					 undef,1);
 1983:     $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=$src;
 1984:     my $currentstring = '';
 1985:     my $width_param = '';
 1986:     my $height_param = '';
 1987:     my $scaling = .3;
 1988:     
 1989:     if ($target eq 'web') {
 1990: 	if ($ENV{'browser.imagesuppress'} ne 'on') {
 1991: 	    $currentstring = $token->[4];
 1992: 	} else {
 1993: 	    my $alttag= &Apache::lonxml::get_param
 1994: 		('alt',$parstack,$safeeval,undef,1);
 1995: 	    unless ($alttag) {
 1996: 		$alttag=&Apache::lonmeta::alttag
 1997: 		    ($Apache::lonxml::pwd[-1],$src);
 1998: 	    }
 1999: 	    $currentstring='[IMAGE: '.$alttag.']';
 2000: 	}
 2001:     } elsif ($target eq 'tex') {
 2002: 	$src=&Apache::lonnet::filelocation($Apache::lonxml::pwd[-1],$src);
 2003: 	&image_replication($src);
 2004: 	
 2005: 	#if original gif/jpg/png file exist do following:
 2006: 	if (-e $src) {          
 2007: 	    #defines the default size of image
 2008: 	    my $image = Image::Magick->new;
 2009: 	    my $current_figure = $image->Read($src);
 2010: 	    $width_param = $image->Get('width') * $scaling;;
 2011: 	    $height_param = $image->Get('height') * $scaling;;
 2012: 	    undef $image;
 2013: 	    #do we have any specified size of the picture?
 2014: 	    my $TeXwidth = &Apache::lonxml::get_param('TeXwidth',$parstack,$safeeval);
 2015: 	    my $TeXheight = &Apache::lonxml::get_param('TeXheight',$parstack,$safeeval);
 2016: 	    my $width = &Apache::lonxml::get_param('width',$parstack,$safeeval,
 2017: 						   undef,1);
 2018: 	    if ($TeXwidth ne '') {  
 2019: 		if ($TeXwidth=~/(\d+)\s*\%/) {
 2020: 		    $width_param = $1*$ENV{'form.textwidth'}/100;
 2021: 		} else { 
 2022: 		    $width_param = $TeXwidth;
 2023: 		}
 2024: 	    } elsif ($TeXheight ne '') {
 2025: 		$width_param = $TeXheight/$height_param*$width_param;
 2026: 	    } elsif ($width ne '') {
 2027: 		$width_param = $width*$scaling;      
 2028: 	    }
 2029: 	    my $file;
 2030: 	    my $path;	
 2031: 	    if ($src =~ m!(.*)/([^/]*)$!) {
 2032: 		$file = $2; 
 2033: 		$path = $1.'/'; 
 2034: 	    } 
 2035: 	    my $newsrc = $src;
 2036: 	    $newsrc =~ s/\.(gif|jpg|png)$/.eps/i;
 2037: 	    $file=~s/\.(gif|jpg|png)$/.eps/i;
 2038: 	    #where can we find the picture?
 2039: 	    if (-e $newsrc) {
 2040: 		#eps counterpart for image exist 
 2041: 		if ($path) {
 2042: 		    $currentstring .= '\vskip 1 mm \noindent\graphicspath{{'.$path.'}}\includegraphics[width='.$width_param.' mm]{'.$file.'} ';
 2043: 		}
 2044: 	    } else {
 2045: 		#there is no eps counterpart for image - check for ps one
 2046: 		$newsrc =~ s/\.eps$/\.ps/;
 2047: 		if (-e $newsrc) {
 2048: 		    #ps counterpart for image exist 
 2049: 		    $file =~ s/\.eps$/\.ps/;
 2050: 		    if ($path) {
 2051: 			$currentstring .= '\vskip 1 mm \noindent\graphicspath{{'.$path.'}}\includegraphics[width='.$width_param.' mm]{'.$file.'} ';
 2052: 		    }
 2053: 		} else {
 2054: 		    #there aren't eps or ps - so create eps 
 2055: 		    my $temp_file;
 2056: 		    my $filename = "/home/httpd/prtspool/$ENV{'user.name'}_$ENV{'user.domain'}_printout.dat";
 2057: 		    $temp_file = Apache::File->new('>>'.$filename); 
 2058: 		    print $temp_file "$src\n";
 2059: 		    $currentstring .= '\vskip 1 mm \graphicspath{{/home/httpd/prtspool/}}\includegraphics[width='.$width_param.' mm]{'.$file.'} ';
 2060: 		}
 2061: 	    }
 2062: 	} else {
 2063: 	    #original image file doesn't exist so check the alt attribute
 2064: 	    my $alt = 
 2065: 		&Apache::lonxml::get_param('alt',$parstack,$safeeval,undef,1);
 2066: 	    unless ($alt) {
 2067: 		$alt=&Apache::lonmeta::alttag($Apache::lonxml::pwd[-1],$src);
 2068: 	    }
 2069: 
 2070: 	    if ($alt) {
 2071: 		$currentstring .= ' '.$alt.' ';
 2072: 	    } else {
 2073: 		#<allow> tag will care about replication 
 2074: 	    }
 2075: 	}
 2076:     }
 2077:     return $currentstring;
 2078: }
 2079: 
 2080: sub end_img {
 2081:     my ($target,$token) = @_;
 2082:     my $currentstring = '';
 2083:     if ($target eq 'web') {
 2084: 	$currentstring = $token->[2];
 2085:     } elsif ($target eq 'tex') {
 2086: 	$currentstring = '';
 2087:     }
 2088:     return $currentstring;
 2089: }
 2090: 
 2091: #-- <applet> tag
 2092: sub start_applet {
 2093:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
 2094:     
 2095:     my $code=&Apache::lonxml::get_param('code',$parstack,$safeeval,undef,1);
 2096:     $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=$code;
 2097:     
 2098:     my $archive=&Apache::lonxml::get_param('archive',$parstack,$safeeval,
 2099: 					   undef,1);
 2100:     $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=$archive;
 2101:     
 2102:     my $currentstring = '';
 2103:     if ($target eq 'web') {
 2104: 	if ($ENV{'browser.appletsuppress'} ne 'on') {
 2105: 	    $currentstring = $token->[4];
 2106: 	} else {
 2107: 	    my $alttag= &Apache::lonxml::get_param('alt',$parstack,
 2108: 						   $safeeval,undef,1);
 2109: 	    unless ($alttag) {
 2110: 		$alttag=&Apache::lonmeta::alttag($Apache::lonxml::pwd[-1],
 2111: 						 $code);
 2112: 	    }
 2113: 	    $currentstring='[APPLET: '.$alttag.']';
 2114: 	}
 2115:     } elsif ($target eq 'tex') {
 2116: 	$currentstring = " \\begin{figure} ";
 2117:     } 
 2118:     return $currentstring;
 2119: }
 2120: 
 2121: sub end_applet {
 2122:     my ($target,$token) = @_;
 2123:     my $currentstring = '';
 2124:     if ($target eq 'web') {
 2125: 	$currentstring = $token->[2];
 2126:     } elsif ($target eq 'tex') {
 2127: 	$currentstring = " \\end{figure}";
 2128:     } 
 2129:     return $currentstring;
 2130: }
 2131: 
 2132: #-- <embed> tag
 2133: sub start_embed {    
 2134:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
 2135:     my $src=&Apache::lonxml::get_param('src',$parstack,$safeeval,undef,1);
 2136:     $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=$src;
 2137:     my $currentstring = '';
 2138:     if ($target eq 'web') {
 2139: 	if ($ENV{'browser.embedsuppress'} ne 'on') {
 2140: 	    $currentstring = $token->[4];
 2141: 	} else {
 2142: 	    my $alttag=&Apache::lonxml::get_param
 2143: 		('alt',$parstack,$safeeval,undef,1);
 2144: 	    unless ($alttag) {
 2145: 		$alttag=&Apache::lonmeta::alttag($Apache::lonxml::pwd[-1],$src);
 2146: 	    }
 2147: 	    $currentstring='[EMBED: '.$alttag.']';
 2148: 	}
 2149:     } elsif ($target eq 'tex') {
 2150: 	$currentstring = " \\begin{figure} ";  
 2151:     } 
 2152:     return $currentstring;
 2153: }
 2154: 
 2155: sub end_embed {
 2156:     my ($target,$token) = @_;
 2157:     my $currentstring = '';
 2158:     if ($target eq 'web') {
 2159: 	$currentstring = $token->[2];     
 2160:     } elsif ($target eq 'tex') {
 2161: 	$currentstring = " \\end{figure}";  
 2162:     } 
 2163:     return $currentstring;
 2164: }
 2165: 
 2166: #-- <param> tag
 2167: sub start_param {
 2168:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
 2169:     if (&Apache::lonxml::get_param
 2170: 	('name',$parstack,$safeeval,undef,1)=~/^cabbase$/i) {
 2171: 	$Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=
 2172: 	    &Apache::lonxml::get_param('value',$parstack,$safeeval,undef,1);
 2173:     }   
 2174:     $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=   
 2175: 	&Apache::lonxml::get_param('src',$parstack,$safeeval,undef,1);
 2176:     my $currentstring = '';
 2177:     if ($target eq 'web') {
 2178: 	$currentstring = $token->[4];     
 2179:     } elsif ($target eq 'tex') {
 2180: 	$currentstring = " \\begin{figure} ";  
 2181:     } 
 2182:     return $currentstring;
 2183: }
 2184: 
 2185: sub end_param {
 2186:     my ($target,$token) = @_;
 2187:     my $currentstring = '';
 2188:     if ($target eq 'web') {
 2189: 	$currentstring = $token->[2];     
 2190:     } elsif ($target eq 'tex') {
 2191: 	$currentstring = " \\end{figure}";  
 2192:     } 
 2193:     return $currentstring;
 2194: }
 2195: 
 2196: #-- <allow> tag
 2197: sub start_allow {
 2198:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
 2199:     my $src = &Apache::lonxml::get_param('src',$parstack,$safeeval,undef,1);
 2200:     $src=&Apache::lonnet::filelocation($Apache::lonxml::pwd[-1],$src);
 2201:     $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=
 2202: 	&Apache::lonnet::clutter($src);
 2203:     &image_replication($src);
 2204:     my $result;
 2205:     if ($target eq 'edit') {
 2206: 	$result .=&Apache::edit::tag_start($target,$token);
 2207: 	$result .=&Apache::edit::text_arg('File Spec:','src',$token,70);
 2208: 	$result .=&Apache::edit::end_row();#.&Apache::edit::start_spanning_row();
 2209:     } elsif ($target eq 'modified') {
 2210: 	my $constructtag=&Apache::edit::get_new_args($token,$parstack,
 2211: 						     $safeeval,'src');
 2212: 	if ($constructtag) { $result = &Apache::edit::rebuild_tag($token); }
 2213:     }
 2214:     return $result;
 2215: }
 2216: 
 2217: sub end_allow {
 2218:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
 2219:     if ( $target eq 'edit') { return (&Apache::edit::end_table()); }
 2220:     return '';
 2221: }
 2222: 
 2223: #-- Frames
 2224: sub start_frameset {
 2225:     my ($target,$token) = @_;
 2226:     my $currentstring = '';
 2227:     if ($target eq 'web') { 
 2228: 	if (!$Apache::lonxml::registered) {
 2229: 	    $currentstring.='<head>'.
 2230: 		&Apache::lonmenu::registerurl(undef,$target).'</head>';
 2231: 	}
 2232: 	my $onLoad='';
 2233: 	foreach my $key (keys(%{$token->[2]})) {
 2234: 	    if ($key =~ /^onload$/i) {
 2235: 		$onLoad.=$token->[2]->{$key}.';';
 2236: 		delete($token->[2]->{$key});
 2237: 	    }
 2238: 	}
 2239: 	$token->[2]->{'onload'}=&Apache::lonmenu::loadevents().';'.$onLoad;
 2240: 	my $onUnload='';
 2241: 	foreach my $key (keys(%{$token->[2]})) {
 2242: 	    if ($key =~ /^onunload$/i) {
 2243: 		$onUnload.=$token->[2]->{$key}.';';
 2244: 		delete($token->[2]->{$key});
 2245: 	    }
 2246: 	}
 2247: 	$token->[2]->{'onunload'}=&Apache::lonmenu::unloadevents().
 2248: 	    ';'.$onUnload;
 2249: 	
 2250: 	$currentstring .= '<'.$token->[1];
 2251: 	foreach (keys %{$token->[2]}) {
 2252: 	    $currentstring.=' '.$_.'="'.$token->[2]->{$_}.'"';
 2253: 	}
 2254: 	$currentstring.='>';
 2255:     }
 2256:     return $currentstring;
 2257: }
 2258: 
 2259: sub end_frameset {
 2260:     my ($target,$token) = @_;
 2261:     my $currentstring = '';
 2262:     if ($target eq 'web') {
 2263: 	$currentstring = $token->[2];
 2264:     }
 2265:     return $currentstring;
 2266: }
 2267: 
 2268: #-- <pre>
 2269: sub start_pre {
 2270:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
 2271:     my $currentstring = '';
 2272:     if ($target eq 'web') {
 2273: 	$currentstring .= $token->[4];
 2274:     } elsif ($target eq 'tex') {
 2275: 	$currentstring .= '\begin{verbatim}';
 2276:     } 
 2277:     return $currentstring;
 2278: }
 2279: 
 2280: sub end_pre {
 2281:     my ($target,$token) = @_;
 2282:     my $currentstring = '';
 2283:     if ($target eq 'web') {
 2284: 	$currentstring .= $token->[2];
 2285:     } elsif ($target eq 'tex') {
 2286: 	$currentstring .= '\end{verbatim}';
 2287:     }
 2288:     return $currentstring;
 2289: }
 2290: 
 2291: #-- <insert>
 2292: sub start_insert {
 2293:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
 2294:     my $currentstring = '';
 2295:     if ($target eq 'web') {
 2296: 	my $display = &Apache::lonxml::get_param('display',$parstack,$safeeval,undef,1);
 2297: 	$currentstring .= '<b>'.$display.'</b>';;
 2298:     }
 2299:     return $currentstring;
 2300: }
 2301: 
 2302: sub end_insert {
 2303:     my ($target,$token) = @_;
 2304:     my $currentstring = '';
 2305:     if ($target eq 'web') {
 2306: 	$currentstring .= '';
 2307:     }
 2308:     return $currentstring;
 2309: }
 2310: 
 2311: #-- <externallink>
 2312: sub start_externallink {
 2313:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
 2314:     my $currentstring = '';
 2315:     if ($target eq 'web') {
 2316: 	my $display = &Apache::lonxml::get_param('display',$parstack,$safeeval,undef,1);
 2317: 	$currentstring .= '<b>'.$display.'</b>';;
 2318:     }
 2319:     return $currentstring;
 2320: }
 2321: 
 2322: sub end_externallink {
 2323:     my ($target,$token) = @_;
 2324:     my $currentstring = '';
 2325:     if ($target eq 'web') {
 2326: 	$currentstring .= '';
 2327:     }
 2328:     return $currentstring;
 2329: }
 2330: 
 2331: #-- <blankspace heigth="">
 2332: sub start_blankspace {
 2333:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
 2334:     my $currentstring = '';
 2335:     if ($target eq 'tex') {
 2336: 	my $howmuch = &Apache::lonxml::get_param('heigth',$parstack,$safeeval,undef,1);
 2337: 	$currentstring .= '\vskip '.$howmuch.' ';
 2338:     }
 2339:     return $currentstring;
 2340: }
 2341: 
 2342: sub end_blankspace {
 2343:     my ($target,$token) = @_;
 2344:     my $currentstring = '';
 2345:     if ($target eq 'tex') {
 2346: 	$currentstring .= '';
 2347:     }
 2348:     return $currentstring;
 2349: }
 2350: 
 2351: #-- <abbr> tag
 2352: sub start_abbr {
 2353:     my ($target,$token) = @_;
 2354:     my $currentstring = '';
 2355:     if ($target eq 'web') {
 2356: 	$currentstring = $token->[4];     
 2357:     } 
 2358:     return $currentstring;
 2359: }
 2360: 
 2361: sub end_abbr {
 2362:     my ($target,$token) = @_;
 2363:     my $currentstring = '';
 2364:     if ($target eq 'web') {
 2365: 	$currentstring = $token->[2];    
 2366:     } 
 2367:     return $currentstring;
 2368: }
 2369: 
 2370: #-- <acronym> tag
 2371: sub start_acronym {
 2372:     my ($target,$token) = @_;
 2373:     my $currentstring = '';
 2374:     if ($target eq 'web') {
 2375: 	$currentstring = $token->[4];     
 2376:     } 
 2377:     return $currentstring;
 2378: }
 2379: 
 2380: sub end_acronym {
 2381:     my ($target,$token) = @_;
 2382:     my $currentstring = '';
 2383:     if ($target eq 'web') {
 2384: 	$currentstring = $token->[2];    
 2385:     } 
 2386:     return $currentstring;
 2387: }
 2388: 
 2389: #-- <area> tag
 2390: sub start_area {
 2391:     my ($target,$token) = @_;
 2392:     my $currentstring = '';
 2393:     if ($target eq 'web') {
 2394: 	$currentstring = $token->[4];     
 2395:     } 
 2396:     return $currentstring;
 2397: }
 2398: 
 2399: sub end_area {
 2400:     my ($target,$token) = @_;
 2401:     my $currentstring = '';
 2402:     if ($target eq 'web') {
 2403: 	$currentstring = $token->[2];    
 2404:     } 
 2405:     return $currentstring;
 2406: }
 2407: 
 2408: #-- <base> tag
 2409: sub start_base {
 2410:     my ($target,$token) = @_;
 2411:     my $currentstring = '';
 2412:     if ($target eq 'web') {
 2413: 	$currentstring = $token->[4];     
 2414:     } 
 2415:     return $currentstring;
 2416: }
 2417: 
 2418: sub end_base {
 2419:     my ($target,$token) = @_;
 2420:     my $currentstring = '';
 2421:     if ($target eq 'web') {
 2422: 	$currentstring = $token->[2];    
 2423:     } 
 2424:     return $currentstring;
 2425: }
 2426: 
 2427: #-- <bdo> tag
 2428: sub start_bdo {
 2429:     my ($target,$token) = @_;
 2430:     my $currentstring = '';
 2431:     if ($target eq 'web') {
 2432: 	$currentstring = $token->[4];     
 2433:     } 
 2434:     return $currentstring;
 2435: }
 2436: 
 2437: sub end_bdo {
 2438:     my ($target,$token) = @_;
 2439:     my $currentstring = '';
 2440:     if ($target eq 'web') {
 2441: 	$currentstring = $token->[2];    
 2442:     } 
 2443:     return $currentstring;
 2444: }
 2445: 
 2446: #-- <bgsound> tag
 2447: sub start_bgsound {
 2448:     my ($target,$token) = @_;
 2449:     my $currentstring = '';
 2450:     if ($target eq 'web') {
 2451: 	$currentstring = $token->[4];     
 2452:     } 
 2453:     return $currentstring;
 2454: }
 2455: 
 2456: sub end_bgsound {
 2457:     my ($target,$token) = @_;
 2458:     my $currentstring = '';
 2459:     if ($target eq 'web') {
 2460: 	$currentstring = $token->[2];    
 2461:     } 
 2462:     return $currentstring;
 2463: }
 2464: 
 2465: #-- <blink> tag
 2466: sub start_blink {
 2467:     my ($target,$token) = @_;
 2468:     my $currentstring = '';
 2469:     if ($target eq 'web') {
 2470: 	$currentstring = $token->[4];     
 2471:     } 
 2472:     return $currentstring;
 2473: }
 2474: 
 2475: sub end_blink {
 2476:     my ($target,$token) = @_;
 2477:     my $currentstring = '';
 2478:     if ($target eq 'web') {
 2479: 	$currentstring = $token->[2];    
 2480:     } 
 2481:     return $currentstring;
 2482: }
 2483: 
 2484: #-- <blockquote> tag
 2485: sub start_blockquote {
 2486:     my ($target,$token) = @_;
 2487:     my $currentstring = '';
 2488:     if ($target eq 'web') {
 2489: 	$currentstring = $token->[4];     
 2490:     } 
 2491:     return $currentstring;
 2492: }
 2493: 
 2494: sub end_blockquote {
 2495:     my ($target,$token) = @_;
 2496:     my $currentstring = '';
 2497:     if ($target eq 'web') {
 2498: 	$currentstring = $token->[2];    
 2499:     } 
 2500:     return $currentstring;
 2501: }
 2502: 
 2503: #-- <button> tag
 2504: sub start_button {
 2505:     my ($target,$token) = @_;
 2506:     my $currentstring = '';
 2507:     if ($target eq 'web') {
 2508: 	$currentstring = $token->[4];     
 2509:     } 
 2510:     return $currentstring;
 2511: }
 2512: 
 2513: sub end_button {
 2514:     my ($target,$token) = @_;
 2515:     my $currentstring = '';
 2516:     if ($target eq 'web') {
 2517: 	$currentstring = $token->[2];    
 2518:     } 
 2519:     return $currentstring;
 2520: }
 2521: 
 2522: #-- <caption> tag
 2523: sub start_caption {
 2524:     my ($target,$token) = @_;
 2525:     my $currentstring = '';
 2526:     if ($target eq 'web') {
 2527: 	$currentstring = $token->[4];     
 2528:     } 
 2529:     return $currentstring;
 2530: }
 2531: 
 2532: sub end_caption {
 2533:     my ($target,$token) = @_;
 2534:     my $currentstring = '';
 2535:     if ($target eq 'web') {
 2536: 	$currentstring = $token->[2];    
 2537:     } 
 2538:     return $currentstring;
 2539: }
 2540: 
 2541: #-- <col> tag
 2542: sub start_col {
 2543:     my ($target,$token) = @_;
 2544:     my $currentstring = '';
 2545:     if ($target eq 'web') {
 2546: 	$currentstring = $token->[4];     
 2547:     } 
 2548:     return $currentstring;
 2549: }
 2550: 
 2551: sub end_col {
 2552:     my ($target,$token) = @_;
 2553:     my $currentstring = '';
 2554:     if ($target eq 'web') {
 2555: 	$currentstring = $token->[2];    
 2556:     } 
 2557:     return $currentstring;
 2558: }
 2559: 
 2560: #-- <colgroup> tag
 2561: sub start_colgroup {
 2562:     my ($target,$token) = @_;
 2563:     my $currentstring = '';
 2564:     if ($target eq 'web') {
 2565: 	$currentstring = $token->[4];     
 2566:     } 
 2567:     return $currentstring;
 2568: }
 2569: 
 2570: sub end_colgroup {
 2571:     my ($target,$token) = @_;
 2572:     my $currentstring = '';
 2573:     if ($target eq 'web') {
 2574: 	$currentstring = $token->[2];    
 2575:     } 
 2576:     return $currentstring;
 2577: }
 2578: 
 2579: #-- <del> tag
 2580: sub start_del {
 2581:     my ($target,$token) = @_;
 2582:     my $currentstring = '';
 2583:     if ($target eq 'web') {
 2584: 	$currentstring = $token->[4];     
 2585:     } 
 2586:     return $currentstring;
 2587: }
 2588: 
 2589: sub end_del {
 2590:     my ($target,$token) = @_;
 2591:     my $currentstring = '';
 2592:     if ($target eq 'web') {
 2593: 	$currentstring = $token->[2];    
 2594:     } 
 2595:     return $currentstring;
 2596: }
 2597: 
 2598: #-- <fieldset> tag
 2599: sub start_fieldset {
 2600:     my ($target,$token) = @_;
 2601:     my $currentstring = '';
 2602:     if ($target eq 'web') {
 2603: 	$currentstring = $token->[4];     
 2604:     } 
 2605:     return $currentstring;
 2606: }
 2607: 
 2608: sub end_fieldset {
 2609:     my ($target,$token) = @_;
 2610:     my $currentstring = '';
 2611:     if ($target eq 'web') {
 2612: 	$currentstring = $token->[2];    
 2613:     } 
 2614:     return $currentstring;
 2615: }
 2616: 
 2617: #-- <frame> tag
 2618: sub start_frame {
 2619:     my ($target,$token) = @_;
 2620:     my $currentstring = '';
 2621:     if ($target eq 'web') {
 2622: 	$currentstring = $token->[4];     
 2623:     } 
 2624:     return $currentstring;
 2625: }
 2626: 
 2627: sub end_frame {
 2628:     my ($target,$token) = @_;
 2629:     my $currentstring = '';
 2630:     if ($target eq 'web') {
 2631: 	$currentstring = $token->[2];    
 2632:     } 
 2633:     return $currentstring;
 2634: }
 2635: 
 2636: #-- <iframe> tag
 2637: sub start_iframe {
 2638:     my ($target,$token) = @_;
 2639:     my $currentstring = '';
 2640:     if ($target eq 'web') {
 2641: 	$currentstring = $token->[4];     
 2642:     } 
 2643:     return $currentstring;
 2644: }
 2645: 
 2646: sub end_iframe {
 2647:     my ($target,$token) = @_;
 2648:     my $currentstring = '';
 2649:     if ($target eq 'web') {
 2650: 	$currentstring = $token->[2];    
 2651:     } 
 2652:     return $currentstring;
 2653: }
 2654: 
 2655: #-- <ins> tag
 2656: sub start_ins {
 2657:     my ($target,$token) = @_;
 2658:     my $currentstring = '';
 2659:     if ($target eq 'web') {
 2660: 	$currentstring = $token->[4];     
 2661:     } 
 2662:     return $currentstring;
 2663: }
 2664: 
 2665: sub end_ins {
 2666:     my ($target,$token) = @_;
 2667:     my $currentstring = '';
 2668:     if ($target eq 'web') {
 2669: 	$currentstring = $token->[2];    
 2670:     } 
 2671:     return $currentstring;
 2672: }
 2673: 
 2674: #-- <isindex> tag
 2675: sub start_isindex {
 2676:     my ($target,$token) = @_;
 2677:     my $currentstring = '';
 2678:     if ($target eq 'web') {
 2679: 	$currentstring = $token->[4];     
 2680:     } 
 2681:     return $currentstring;
 2682: }
 2683: 
 2684: sub end_isindex {
 2685:     my ($target,$token) = @_;
 2686:     my $currentstring = '';
 2687:     if ($target eq 'web') {
 2688: 	$currentstring = $token->[2];    
 2689:     } 
 2690:     return $currentstring;
 2691: }
 2692: 
 2693: #-- <keygen> tag
 2694: sub start_keygen {
 2695:     my ($target,$token) = @_;
 2696:     my $currentstring = '';
 2697:     if ($target eq 'web') {
 2698: 	$currentstring = $token->[4];     
 2699:     } 
 2700:     return $currentstring;
 2701: }
 2702: 
 2703: sub end_keygen {
 2704:     my ($target,$token) = @_;
 2705:     my $currentstring = '';
 2706:     if ($target eq 'web') {
 2707: 	$currentstring = $token->[2];    
 2708:     } 
 2709:     return $currentstring;
 2710: }
 2711: 
 2712: #-- <label> tag
 2713: sub start_label {
 2714:     my ($target,$token) = @_;
 2715:     my $currentstring = '';
 2716:     if ($target eq 'web') {
 2717: 	$currentstring = $token->[4];     
 2718:     } 
 2719:     return $currentstring;
 2720: }
 2721: 
 2722: sub end_label {
 2723:     my ($target,$token) = @_;
 2724:     my $currentstring = '';
 2725:     if ($target eq 'web') {
 2726: 	$currentstring = $token->[2];    
 2727:     } 
 2728:     return $currentstring;
 2729: }
 2730: 
 2731: #-- <layer> tag
 2732: sub start_layer {
 2733:     my ($target,$token) = @_;
 2734:     my $currentstring = '';
 2735:     if ($target eq 'web') {
 2736: 	$currentstring = $token->[4];     
 2737:     } 
 2738:     return $currentstring;
 2739: }
 2740: 
 2741: sub end_layer {
 2742:     my ($target,$token) = @_;
 2743:     my $currentstring = '';
 2744:     if ($target eq 'web') {
 2745: 	$currentstring = $token->[2];    
 2746:     } 
 2747:     return $currentstring;
 2748: }
 2749: 
 2750: #-- <legend> tag
 2751: sub start_legend {
 2752:     my ($target,$token) = @_;
 2753:     my $currentstring = '';
 2754:     if ($target eq 'web') {
 2755: 	$currentstring = $token->[4];     
 2756:     } 
 2757:     return $currentstring;
 2758: }
 2759: 
 2760: sub end_legend {
 2761:     my ($target,$token) = @_;
 2762:     my $currentstring = '';
 2763:     if ($target eq 'web') {
 2764: 	$currentstring = $token->[2];    
 2765:     } 
 2766:     return $currentstring;
 2767: }
 2768: 
 2769: #-- <link> tag
 2770: sub start_link {
 2771:     my ($target,$token) = @_;
 2772:     my $currentstring = '';
 2773:     if ($target eq 'web') {
 2774: 	$currentstring = $token->[4];     
 2775:     } 
 2776:     return $currentstring;
 2777: }
 2778: 
 2779: sub end_link {
 2780:     my ($target,$token) = @_;
 2781:     my $currentstring = '';
 2782:     if ($target eq 'web') {
 2783: 	$currentstring = $token->[2];    
 2784:     } 
 2785:     return $currentstring;
 2786: }
 2787: 
 2788: #-- <marquee> tag
 2789: sub start_marquee {
 2790:     my ($target,$token) = @_;
 2791:     my $currentstring = '';
 2792:     if ($target eq 'web') {
 2793: 	$currentstring = $token->[4];     
 2794:     } 
 2795:     return $currentstring;
 2796: }
 2797: 
 2798: sub end_marquee {
 2799:     my ($target,$token) = @_;
 2800:     my $currentstring = '';
 2801:     if ($target eq 'web') {
 2802: 	$currentstring = $token->[2];    
 2803:     } 
 2804:     return $currentstring;
 2805: }
 2806: 
 2807: #-- <malticol> tag
 2808: sub start_malticol {
 2809:     my ($target,$token) = @_;
 2810:     my $currentstring = '';
 2811:     if ($target eq 'web') {
 2812: 	$currentstring = $token->[4];     
 2813:     } 
 2814:     return $currentstring;
 2815: }
 2816: 
 2817: sub end_malticol {
 2818:     my ($target,$token) = @_;
 2819:     my $currentstring = '';
 2820:     if ($target eq 'web') {
 2821: 	$currentstring = $token->[2];    
 2822:     } 
 2823:     return $currentstring;
 2824: }
 2825: 
 2826: #-- <nobr> tag
 2827: sub start_nobr {
 2828:     my ($target,$token) = @_;
 2829:     my $currentstring = '';
 2830:     if ($target eq 'web') {
 2831: 	$currentstring = $token->[4];     
 2832:     } 
 2833:     return $currentstring;
 2834: }
 2835: 
 2836: sub end_nobr {
 2837:     my ($target,$token) = @_;
 2838:     my $currentstring = '';
 2839:     if ($target eq 'web') {
 2840: 	$currentstring = $token->[2];    
 2841:     } 
 2842:     return $currentstring;
 2843: }
 2844: 
 2845: #-- <noembed> tag
 2846: sub start_noembed {
 2847:     my ($target,$token) = @_;
 2848:     my $currentstring = '';
 2849:     if ($target eq 'web') {
 2850: 	$currentstring = $token->[4];     
 2851:     } 
 2852:     return $currentstring;
 2853: }
 2854: 
 2855: sub end_noembed {
 2856:     my ($target,$token) = @_;
 2857:     my $currentstring = '';
 2858:     if ($target eq 'web') {
 2859: 	$currentstring = $token->[2];    
 2860:     } 
 2861:     return $currentstring;
 2862: }
 2863: 
 2864: #-- <noframes> tag
 2865: sub start_noframes {
 2866:     my ($target,$token) = @_;
 2867:     my $currentstring = '';
 2868:     if ($target eq 'web') {
 2869: 	$currentstring = $token->[4];     
 2870:     } 
 2871:     return $currentstring;
 2872: }
 2873: 
 2874: sub end_noframes {
 2875:     my ($target,$token) = @_;
 2876:     my $currentstring = '';
 2877:     if ($target eq 'web') {
 2878: 	$currentstring = $token->[2];    
 2879:     } 
 2880:     return $currentstring;
 2881: }
 2882: 
 2883: #-- <nolayer> tag
 2884: sub start_nolayer {
 2885:     my ($target,$token) = @_;
 2886:     my $currentstring = '';
 2887:     if ($target eq 'web') {
 2888: 	$currentstring = $token->[4];     
 2889:     } 
 2890:     return $currentstring;
 2891: }
 2892: 
 2893: sub end_nolayer {
 2894:     my ($target,$token) = @_;
 2895:     my $currentstring = '';
 2896:     if ($target eq 'web') {
 2897: 	$currentstring = $token->[2];    
 2898:     } 
 2899:     return $currentstring;
 2900: }
 2901: 
 2902: #-- <noscript> tag
 2903: sub start_noscript {
 2904:     my ($target,$token) = @_;
 2905:     my $currentstring = '';
 2906:     if ($target eq 'web') {
 2907: 	$currentstring = $token->[4];     
 2908:     } 
 2909:     return $currentstring;
 2910: }
 2911: 
 2912: sub end_noscript {
 2913:     my ($target,$token) = @_;
 2914:     my $currentstring = '';
 2915:     if ($target eq 'web') {
 2916: 	$currentstring = $token->[2];    
 2917:     } 
 2918:     return $currentstring;
 2919: }
 2920: 
 2921: #-- <object> tag
 2922: sub start_object {
 2923:     my ($target,$token) = @_;
 2924:     my $currentstring = '';
 2925:     if ($target eq 'web') {
 2926: 	$currentstring = $token->[4];     
 2927:     } 
 2928:     return $currentstring;
 2929: }
 2930: 
 2931: sub end_object {
 2932:     my ($target,$token) = @_;
 2933:     my $currentstring = '';
 2934:     if ($target eq 'web') {
 2935: 	$currentstring = $token->[2];    
 2936:     } 
 2937:     return $currentstring;
 2938: }
 2939: 
 2940: #-- <optgroup> tag
 2941: sub start_optgroup {
 2942:     my ($target,$token) = @_;
 2943:     my $currentstring = '';
 2944:     if ($target eq 'web') {
 2945: 	$currentstring = $token->[4];     
 2946:     } 
 2947:     return $currentstring;
 2948: }
 2949: 
 2950: sub end_optgroup {
 2951:     my ($target,$token) = @_;
 2952:     my $currentstring = '';
 2953:     if ($target eq 'web') {
 2954: 	$currentstring = $token->[2];    
 2955:     } 
 2956:     return $currentstring;
 2957: }
 2958: 
 2959: #-- <samp> tag
 2960: sub start_samp {
 2961:     my ($target,$token) = @_;
 2962:     my $currentstring = '';
 2963:     if ($target eq 'web') {
 2964: 	$currentstring = $token->[4];     
 2965:     } 
 2966:     return $currentstring;
 2967: }
 2968: 
 2969: sub end_samp {
 2970:     my ($target,$token) = @_;
 2971:     my $currentstring = '';
 2972:     if ($target eq 'web') {
 2973: 	$currentstring = $token->[2];    
 2974:     } 
 2975:     return $currentstring;
 2976: }
 2977: 
 2978: #-- <server> tag
 2979: sub start_server {
 2980:     my ($target,$token) = @_;
 2981:     my $currentstring = '';
 2982:     if ($target eq 'web') {
 2983: 	$currentstring = $token->[4];     
 2984:     } 
 2985:     return $currentstring;
 2986: }
 2987: 
 2988: sub end_server {
 2989:     my ($target,$token) = @_;
 2990:     my $currentstring = '';
 2991:     if ($target eq 'web') {
 2992: 	$currentstring = $token->[2];    
 2993:     } 
 2994:     return $currentstring;
 2995: }
 2996: 
 2997: #-- <spacer> tag
 2998: sub start_spacer {
 2999:     my ($target,$token) = @_;
 3000:     my $currentstring = '';
 3001:     if ($target eq 'web') {
 3002: 	$currentstring = $token->[4];     
 3003:     } 
 3004:     return $currentstring;
 3005: }
 3006: 
 3007: sub end_spacer {
 3008:     my ($target,$token) = @_;
 3009:     my $currentstring = '';
 3010:     if ($target eq 'web') {
 3011: 	$currentstring = $token->[2];    
 3012:     } 
 3013:     return $currentstring;
 3014: }
 3015: 
 3016: #-- <span> tag
 3017: sub start_span {
 3018:     my ($target,$token) = @_;
 3019:     my $currentstring = '';
 3020:     if ($target eq 'web') {
 3021: 	$currentstring = $token->[4];     
 3022:     } 
 3023:     return $currentstring;
 3024: }
 3025: 
 3026: sub end_span {
 3027:     my ($target,$token) = @_;
 3028:     my $currentstring = '';
 3029:     if ($target eq 'web') {
 3030: 	$currentstring = $token->[2];    
 3031:     } 
 3032:     return $currentstring;
 3033: }
 3034: 
 3035: #-- <tbody> tag
 3036: sub start_tbody {
 3037:     my ($target,$token) = @_;
 3038:     my $currentstring = '';
 3039:     if ($target eq 'web') {
 3040: 	$currentstring = $token->[4];     
 3041:     } 
 3042:     return $currentstring;
 3043: }
 3044: 
 3045: sub end_tbody {
 3046:     my ($target,$token) = @_;
 3047:     my $currentstring = '';
 3048:     if ($target eq 'web') {
 3049: 	$currentstring = $token->[2];    
 3050:     } 
 3051:     return $currentstring;
 3052: }
 3053: 
 3054: #-- <tfoot> tag
 3055: sub start_tfoot {
 3056:     my ($target,$token) = @_;
 3057:     my $currentstring = '';
 3058:     if ($target eq 'web') {
 3059: 	$currentstring = $token->[4];     
 3060:     } 
 3061:     return $currentstring;
 3062: }
 3063: 
 3064: sub end_tfoot {
 3065:     my ($target,$token) = @_;
 3066:     my $currentstring = '';
 3067:     if ($target eq 'web') {
 3068: 	$currentstring = $token->[2];    
 3069:     } 
 3070:     return $currentstring;
 3071: }
 3072: 
 3073: #-- <thead> tag
 3074: sub start_thead {
 3075:     my ($target,$token) = @_;
 3076:     my $currentstring = '';
 3077:     if ($target eq 'web') {
 3078: 	$currentstring = $token->[4];     
 3079:     } 
 3080:     return $currentstring;
 3081: }
 3082: 
 3083: sub end_thead {
 3084:     my ($target,$token) = @_;
 3085:     my $currentstring = '';
 3086:     if ($target eq 'web') {
 3087: 	$currentstring = $token->[2];    
 3088:     } 
 3089:     return $currentstring;
 3090: }
 3091: 
 3092: #-- <var> tag
 3093: sub start_var {
 3094:     my ($target,$token) = @_;
 3095:     my $currentstring = '';
 3096:     if ($target eq 'web') {
 3097: 	$currentstring = $token->[4];     
 3098:     } 
 3099:     return $currentstring;
 3100: }
 3101: 
 3102: sub end_var {
 3103:     my ($target,$token) = @_;
 3104:     my $currentstring = '';
 3105:     if ($target eq 'web') {
 3106: 	$currentstring = $token->[2];    
 3107:     } 
 3108:     return $currentstring;
 3109: }
 3110: 
 3111: #-- <wbr> tag
 3112: sub start_wbr {
 3113:     my ($target,$token) = @_;
 3114:     my $currentstring = '';
 3115:     if ($target eq 'web') {
 3116: 	$currentstring = $token->[4];     
 3117:     } 
 3118:     return $currentstring;
 3119: }
 3120: 
 3121: sub end_wbr {
 3122:     my ($target,$token) = @_;
 3123:     my $currentstring = '';
 3124:     if ($target eq 'web') {
 3125: 	$currentstring = $token->[2];    
 3126:     } 
 3127:     return $currentstring;
 3128: }
 3129: 
 3130: 
 3131: #-- <hideweboutput> tag
 3132: sub start_hideweboutput {
 3133:     my ($target,$token) = @_;
 3134:     if ($target eq 'web') {
 3135: 	&Apache::lonxml::startredirection();     
 3136:     } 
 3137:     return '';
 3138: }
 3139: 
 3140: sub end_hideweboutput {
 3141:     my ($target,$token) = @_;
 3142:     my $currentstring = '';
 3143:     if ($target eq 'web') {
 3144: 	$currentstring = &Apache::lonxml::endredirection();    
 3145:     } 
 3146:     return '';
 3147: }
 3148: 
 3149: 
 3150: sub image_replication {
 3151:     my $src = shift;
 3152:     if (not -e $src) {
 3153: 	#replicates image itself
 3154: 	&Apache::lonnet::repcopy($src);
 3155: 	#replicates eps or ps 
 3156: 	my $newsrc = $src;
 3157: 	$newsrc =~ s/\.(gif|jpg|jpeg|png)$/.eps/i;
 3158: 	if (not -e $newsrc) {
 3159: 	    if (&Apache::lonnet::repcopy($newsrc) ne 'OK') {
 3160: 		$newsrc =~ s/\.eps$/\.ps/;
 3161: 		&Apache::lonnet::repcopy($newsrc);
 3162: 	    }
 3163: 	}
 3164:     }
 3165:     return '';
 3166: }
 3167: 
 3168: sub recalc {
 3169:     my $argument = shift;
 3170:     if (not $argument=~/(mm|cm|in|pc|pt)/) {return $argument.' mm';}
 3171:     $argument=~/\s*(\d+\.?\d*)\s*(mm|cm|in|pc|pt)/;
 3172:     my $value=$1;
 3173:     my $units=$2;
 3174:     if ($units eq 'cm') {
 3175: 	$value*=10;
 3176:     } elsif ($units eq 'in') {
 3177: 	$value*=25.4;
 3178:     } elsif ($units eq 'pc') {
 3179: 	$value*=(25.4*12/72.27);
 3180:     } elsif ($units eq 'pt') {
 3181: 	$value*=(25.4/72.27);
 3182:     }
 3183:     return $value.' mm';
 3184: }
 3185: 
 3186: 1;
 3187: __END__

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>