File:  [LON-CAPA] / loncom / xml / londefdef.pm
Revision 1.149: download - view: text, annotated - select for diffs
Mon Jun 30 18:54:02 2003 UTC (20 years, 10 months ago) by sakharuk
Branches: MAIN
CVS tags: HEAD
Corrections to print links (the source of this corrections - particular document res/msu/bio/bswelcomeLON-CAPA.html). This html page is a perfect example how to create bad html and absolutely unreasonably complicated document. I have still to work with this html page - the content of this page is embedded into one cell of one column page and LaTeX has a severe limitations for such huge tables.

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

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