File:  [LON-CAPA] / loncom / xml / londefdef.pm
Revision 1.158.4.4: download - view: text, annotated - select for diffs
Sat Aug 30 02:41:26 2003 UTC (20 years, 8 months ago) by albertel
Branches: version_1_0_1
Diff to branchpoint 1.158: preferred, unified
- backport 1.170

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

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