File:  [LON-CAPA] / loncom / xml / londefdef.pm
Revision 1.130: download - view: text, annotated - select for diffs
Fri Apr 18 15:14:18 2003 UTC (21 years, 1 month ago) by sakharuk
Branches: MAIN
CVS tags: HEAD
Changed <th> tag. Now it's almost identical to <td> tag but prints in bold. Additional work may be necessary to resolve some conflicts with the content environments inside of the "internals" of <th> tag.

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

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