File:  [LON-CAPA] / loncom / xml / londefdef.pm
Revision 1.158.4.5: download - view: text, annotated - select for diffs
Tue Sep 2 14:30:31 2003 UTC (20 years, 8 months ago) by albertel
Branches: version_1_0_1
Diff to branchpoint 1.158: preferred, unified
- backport 1.166 1.167

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

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