File:  [LON-CAPA] / loncom / xml / londefdef.pm
Revision 1.136: download - view: text, annotated - select for diffs
Thu May 29 18:11:00 2003 UTC (20 years, 11 months ago) by sakharuk
Branches: MAIN
CVS tags: version_0_99_1, HEAD
Changes in <pre> tag - LaTeX does not like verb environment inside parbox.

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

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