File:  [LON-CAPA] / loncom / xml / londefdef.pm
Revision 1.121: download - view: text, annotated - select for diffs
Tue Mar 18 07:26:49 2003 UTC (21 years, 2 months ago) by www
Branches: MAIN
CVS tags: HEAD
Continued work on custom access rights, and rewrite of a truly amazing bit
of ancient code for custom role access ...

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

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