File:  [LON-CAPA] / loncom / xml / londefdef.pm
Revision 1.140: download - view: text, annotated - select for diffs
Thu Jun 19 15:30:58 2003 UTC (20 years, 11 months ago) by sakharuk
Branches: MAIN
CVS tags: HEAD
LaTeX parsing is changed to batchmode. It allows to automatically correct a simple LaTeX errors (such as typos for example <m>$a^2</m> instead <m>$a^2$</m>) but for more complicated situations it;s more unpredictable.

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

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