File:  [LON-CAPA] / loncom / xml / londefdef.pm
Revision 1.153: download - view: text, annotated - select for diffs
Mon Jul 14 14:29:26 2003 UTC (20 years, 10 months ago) by sakharuk
Branches: MAIN
CVS tags: HEAD
Added switch -  batchmode on/batchmode off.

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

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