File:  [LON-CAPA] / loncom / xml / londefdef.pm
Revision 1.155: download - view: text, annotated - select for diffs
Fri Jul 25 10:44:36 2003 UTC (20 years, 9 months ago) by www
Branches: MAIN
CVS tags: HEAD
Accessibility features work as advertised.

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

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