File:  [LON-CAPA] / loncom / xml / londefdef.pm
Revision 1.118: download - view: text, annotated - select for diffs
Wed Feb 19 14:30:10 2003 UTC (21 years, 2 months ago) by www
Branches: MAIN
CVS tags: HEAD
image_replicate now takes complete file path as argument (incl. /home/httpd)

Several fixes to image_replicate and calling thereof:
* does now recognize relative paths
* does recognize ".GIF" (uppercase extensions)
* does recognize ".jpeg"
* do not trust "early stop" in && boolean evaluation

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

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