File:  [LON-CAPA] / loncom / xml / londefdef.pm
Revision 1.150: download - view: text, annotated - select for diffs
Mon Jun 30 19:26:36 2003 UTC (20 years, 10 months ago) by sakharuk
Branches: MAIN
CVS tags: HEAD
Added longtable environment to print a huge tables (a lot of info inside one particular cell).

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

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