File:  [LON-CAPA] / loncom / xml / londefdef.pm
Revision 1.191: download - view: text, annotated - select for diffs
Sat Nov 15 12:46:41 2003 UTC (20 years, 6 months ago) by albertel
Branches: MAIN
CVS tags: version_1_1_0, version_1_0_99_3, version_1_0_99_2, version_1_0_99_1, version_1_0_99, HEAD
- BUG#2383, make <m> tag work in analyze mode

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

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