File:  [LON-CAPA] / loncom / xml / londefdef.pm
Revision 1.42: download - view: text, annotated - select for diffs
Thu Feb 21 04:10:31 2002 UTC (22 years, 3 months ago) by albertel
Branches: MAIN
CVS tags: HEAD
- improved tex conversion of <img src="" />, handles .gif and .jpg files, with an already existing .eps file
   - also improved reference generation for tags with relative references

    1: # The LearningOnline Network with CAPA
    2: # Tags Default Definition Module 
    3: #
    4: # $Id: londefdef.pm,v 1.42 2002/02/21 04:10:31 albertel Exp $
    5: # 
    6: #
    7: # Copyright Michigan State University Board of Trustees
    8: #
    9: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
   10: #
   11: # LON-CAPA is free software; you can redistribute it and/or modify
   12: # it under the terms of the GNU General Public License as published by
   13: # the Free Software Foundation; either version 2 of the License, or
   14: # (at your option) any later version.
   15: #
   16: # LON-CAPA is distributed in the hope that it will be useful,
   17: # but WITHOUT ANY WARRANTY; without even the implied warranty of
   18: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   19: # GNU General Public License for more details.
   20: #
   21: # You should have received a copy of the GNU General Public License
   22: # along with LON-CAPA; if not, write to the Free Software
   23: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   24: #
   25: # /home/httpd/html/adm/gpl.txt
   26: #
   27: # http://www.lon-capa.org/
   28: #
   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 strict;
   48: use Apache::lonxml;
   49: 
   50: BEGIN {
   51: 
   52:     &Apache::lonxml::register('Apache::londefdef',('m','html','head','map','select','option','input','textarea','form','meta','title','body','center','b','strong','table','dt','h1','h2','h3','h4','h5','h6','cite','i','address','dd','dl','dir','ol','ul','menu','dfn','kbd','tt','code','em','q','p','br','big','small','basefont','font','s','sub','strike','sup','hr','a','li','u','output','param','applet','img','embed','tr','td','allow','frameset','pre'));
   53: 
   54: }
   55: 
   56: #======================= TAG SUBROUTINES =====================
   57: #-- <output>
   58: sub start_output {
   59:   my ($target) = @_;
   60:   if ($target eq 'meta') { $Apache::lonxml::metamode--; }
   61:   return '';
   62: }
   63: sub end_output {
   64:   my ($target) = @_;
   65:   if ($target eq 'meta') { $Apache::lonxml::metamode++; }
   66:   return '';
   67: }
   68: #-- <m> tag
   69: sub start_m {
   70:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
   71:   my $currentstring = '';
   72:   if ($target eq 'web') {
   73:     my $inside = &Apache::lonxml::get_all_text("/m",$$parser[-1]);
   74:     $inside ='\\documentstyle{article}'.$inside;
   75:     &Apache::lonxml::debug("M is starting with:$inside:");
   76:     my $eval=&Apache::lonxml::get_param('eval',$parstack,$safeeval);
   77:     if ($eval eq 'on') {
   78:       $inside=&Apache::run::evaluate($inside,$safeeval,$$parstack[-1]);
   79:       #&Apache::lonxml::debug("M is evaulated to:$inside:");
   80:     }
   81:     $currentstring = &Apache::lontexconvert::converted(\$inside);
   82:     if ($Apache::lontexconvert::errorstring) {
   83:       &Apache::lonxml::warning("tth error: ".
   84: 			       $Apache::lontexconvert::errorstring);
   85:       $Apache::lontexconvert::errorstring='';
   86:     }
   87:     #&Apache::lonxml::debug("M is ends with:$currentstring:");
   88:   } elsif ($target eq 'tex') {
   89:     $currentstring = "";
   90:   }
   91:   return $currentstring;
   92: }
   93: sub end_m {
   94:   my ($target,$token) = @_;
   95:   my $currentstring = '';
   96:   if ($target eq 'web') {
   97:   } elsif ($target eq 'tex') {
   98:     $currentstring = "";
   99:   } elsif ($target eq 'meta') {
  100:   }
  101:   return $currentstring;
  102: }
  103: #-- <html> tag    
  104:       sub start_html {
  105: 	    my ($target,$token) = @_;
  106:             my $currentstring = '';
  107: 	    if ($ENV{'browser.mathml'}) {
  108: 	      &tth::ttminit();
  109: 	    } else {
  110: 	      &tth::tthinit();
  111: 	    }
  112:             if ($target eq 'web') {
  113:               $currentstring = &Apache::lonxml::xmlbegin().
  114:                                &Apache::lonxml::fontsettings();     
  115: 	    } elsif ($target eq 'tex') {
  116: 	      $currentstring .= '\documentclass[letterpaper]{article}
  117:                                  \setlength{\oddsidemargin}{-40pt}
  118:                                  \setlength{\evensidemargin}{-60pt}
  119:                                  \setlength{\topmargin}{200pt}
  120:                                  \setlength{\textwidth}{4.4in}
  121:                                  \setlength{\textheight}{6.8in}
  122:                                  \setlength{\parindent}{20pt}
  123:                                  \setlength{\marginparwidth}{90pt}
  124:                                  \setlength{\textfloatsep}{8pt plus 2.0pt minus 4.0pt}
  125:                                  \newcommand{\keephidden}[1]{}           
  126:                                  \usepackage[dvips]{graphicx}';
  127: 	    }
  128: 	   return $currentstring;
  129: 	}
  130:         sub end_html {
  131: 	    my ($target,$token) = @_;
  132:             my $currentstring = '';
  133:             if ($target eq 'web') {
  134: 		$currentstring = &Apache::lonxml::xmlend();
  135: 	    }
  136: 	   return $currentstring;
  137: 	}
  138: #-- <head> tag
  139:       sub start_head {
  140: 	    my ($target,$token) = @_;
  141:             my $currentstring = '';
  142:             if ($target eq 'web') {
  143:               $currentstring = $token->[4];     
  144: 	    } 
  145: 	   return $currentstring;
  146: 	}
  147:         sub end_head {
  148: 	    my ($target,$token) = @_;
  149:             my $currentstring = '';
  150:             if ($target eq 'web') {
  151:               $currentstring = &Apache::lonxml::registerurl().
  152:                                $token->[2];    
  153:             } 
  154: 	   return $currentstring;
  155: 	}
  156: #-- <map> tag
  157:       sub start_map {
  158: 	    my ($target,$token) = @_;
  159:             my $currentstring = '';
  160:             if ($target eq 'web') {
  161:               $currentstring = $token->[4];     
  162: 	    } 
  163: 	   return $currentstring;
  164: 	}
  165:         sub end_map {
  166: 	    my ($target,$token) = @_;
  167:             my $currentstring = '';
  168:             if ($target eq 'web') {
  169:               $currentstring = $token->[2];    
  170:             } 
  171: 	   return $currentstring;
  172: 	}
  173: #-- <select> tag
  174:       sub start_select {
  175: 	    my ($target,$token) = @_;
  176:             my $currentstring = '';
  177:             if ($target eq 'web') {
  178:               $currentstring = $token->[4];     
  179: 	    } 
  180: 	   return $currentstring;
  181: 	}
  182:         sub end_select {
  183: 	    my ($target,$token) = @_;
  184:             my $currentstring = '';
  185:             if ($target eq 'web') {
  186:               $currentstring = $token->[2];    
  187:             } 
  188: 	   return $currentstring;
  189: 	}
  190: #-- <option> tag
  191:       sub start_option {
  192: 	    my ($target,$token) = @_;
  193:             my $currentstring = '';
  194:             if ($target eq 'web') {
  195:               $currentstring = $token->[4];     
  196: 	    } 
  197: 	   return $currentstring;
  198: 	}
  199:         sub end_option {
  200: 	    my ($target,$token) = @_;
  201:             my $currentstring = '';
  202:             if ($target eq 'web') {
  203:               $currentstring = $token->[2];    
  204:             } 
  205: 	   return $currentstring;
  206: 	}
  207: #-- <input> tag
  208:       sub start_input {
  209: 	    my ($target,$token) = @_;
  210:             my $currentstring = '';
  211:             if ($target eq 'web') {
  212:               $currentstring = $token->[4];     
  213: 	    } 
  214: 	   return $currentstring;
  215: 	}
  216:         sub end_input {
  217: 	    my ($target,$token) = @_;
  218:             my $currentstring = '';
  219:             if ($target eq 'web') {
  220:               $currentstring = $token->[2];    
  221:             } 
  222: 	   return $currentstring;
  223: 	}
  224: #-- <textarea> tag
  225:       sub start_textarea {
  226: 	    my ($target,$token) = @_;
  227:             my $currentstring = '';
  228:             if ($target eq 'web') {
  229:               $currentstring = $token->[4];     
  230: 	    } 
  231: 	   return $currentstring;
  232: 	}
  233:         sub end_textarea {
  234: 	    my ($target,$token) = @_;
  235:             my $currentstring = '';
  236:             if ($target eq 'web') {
  237:               $currentstring = $token->[2];    
  238:             } 
  239: 	   return $currentstring;
  240: 	}
  241: #-- <form> tag
  242:       sub start_form {
  243: 	    my ($target,$token) = @_;
  244:             my $currentstring = '';
  245:             if ($target eq 'web') {
  246:               $currentstring = $token->[4];     
  247: 	    } 
  248: 	   return $currentstring;
  249: 	}
  250:         sub end_form {
  251: 	    my ($target,$token) = @_;
  252:             my $currentstring = '';
  253:             if ($target eq 'web') {
  254:               $currentstring = $token->[2];    
  255:             } 
  256: 	   return $currentstring;
  257: 	}
  258: #-- <title> tag
  259:       sub start_title {
  260: 	    my ($target,$token) = @_;
  261:             my $currentstring = '';
  262:             if ($target eq 'web') {
  263:               $currentstring = $token->[4];     
  264: 	    } elsif ($target eq 'tex') {
  265:               $currentstring .= '\keephidden{' 
  266: 	    }
  267:             if ($target eq 'meta') {
  268: 		$currentstring='<title>';
  269:                 &start_output();
  270:             }
  271: 	   return $currentstring;
  272: 	}
  273:         sub end_title {
  274: 	    my ($target,$token) = @_;
  275:             my $currentstring = '';
  276:             if ($target eq 'web') {
  277:               $currentstring = $token->[2];    
  278:             } elsif ($target eq 'tex') {
  279:               $currentstring .= '}';
  280: 	    }  
  281:             if ($target eq 'meta') {
  282:                &end_output();
  283:                $currentstring='</title>';
  284:             } 
  285: 	   return $currentstring;
  286: 	}
  287: #-- <meta> tag
  288:       sub start_meta {
  289: 	    my ($target,$token,$tagstack,$parstack,$parser) = @_;
  290:             my $currentstring = '';
  291:             if ($target eq 'web') {
  292: 	      my $args='';
  293: 	      if ( $#$parstack > -1 ) { $args=$$parstack[$#$parstack]; }
  294: 	      if ($args eq '') {
  295: 		&Apache::lonxml::get_all_text("/meta",$$parser[$#$parser]);
  296: 	      } else {
  297: 		$currentstring = $token->[4];
  298: 	      }
  299: 	    }
  300:             if ($target eq 'meta') {
  301: 		unless ($token->[2]->{'http-equiv'}) {
  302: 		    my $name=$token->[2]->{'name'};
  303:                     $name=~tr/A-Z/a-z/;
  304:                     $name=~s/\s/\_/g;
  305:                     if ($name) {
  306:                        $currentstring='<'.$name.'>'.
  307:                                          $token->[2]->{'content'}.
  308: 			              '</'.$name.'>';
  309: 		    }
  310:                 }
  311: 	    }
  312: 	   return $currentstring;
  313: 	}
  314:       sub end_meta {
  315: 	my ($target,$token,$tagstack,$parstack,$parser) = @_;
  316: 	my $currentstring = '';
  317: 	if ($target eq 'web') {
  318: 	  my $args='';
  319: 	  if ( $#$parstack > -1 ) { $args=$$parstack[$#$parstack]; }
  320: 	  if ($args ne '') {
  321: 	    $currentstring = $token->[4];
  322: 	  }
  323: 	} 
  324: 	return $currentstring;
  325:       }
  326: #-- <body> tag
  327:         sub start_body {
  328:             my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
  329: #	    my ($target,$token) = @_;
  330:             my $currentstring = '';
  331:             if ($target eq 'web') {
  332: 	      if (!$Apache::lonxml::registered) {
  333: 		$currentstring.='<head>'.&Apache::lonxml::registerurl().'</head>';
  334: 	      }
  335: 	      my $onLoad='';
  336: 	      foreach my $key (keys(%{$token->[2]})) {
  337: 		if ($key =~ /^onload$/i) {
  338: 		  $onLoad.=$token->[2]->{$key}.';';
  339: 		  delete($token->[2]->{$key});
  340: 		}
  341: 	      }
  342: 	      $token->[2]->{'onLoad'}=$onLoad.&Apache::lonxml::loadevents();
  343: 	      my $onUnload='';
  344: 	      foreach my $key (keys(%{$token->[2]})) {
  345: 		if ($key =~ /^onunload$/i) {
  346: 		  $onUnload.=$token->[2]->{$key}.';';
  347: 		  delete($token->[2]->{$key});
  348: 		}
  349: 	      }
  350: 	      $token->[2]->{'onUnload'}=$onUnload.
  351: 		&Apache::lonxml::unloadevents();
  352: 
  353: 	      $currentstring .= '<'.$token->[1];
  354: 	      foreach (keys %{$token->[2]}) {
  355: 	      	$currentstring.=' '.$_.'="'.$token->[2]->{$_}.'"';
  356: 	      }
  357: 	      $currentstring.='>';
  358: 	      if ($ENV{'request.state'} ne 'published') {
  359: 		$currentstring.=(<<EDITBUTTON);
  360: 		<form method="post">
  361: 		<input type="submit" name="showmode" value="Edit" />
  362: 		</form>
  363: EDITBUTTON
  364: 	      }
  365:        	    } elsif ($target eq 'tex') {
  366:               $currentstring = '\begin{document}';  
  367: 	    } 
  368: 	   return $currentstring;
  369: 	}
  370:         sub end_body {
  371: 	    my ($target,$token) = @_;
  372:             my $currentstring = '';
  373:             if ($target eq 'web') {
  374:               $currentstring = $token->[2];     
  375: 	    } elsif ($target eq 'tex') {
  376:               $currentstring = '\end{document}';  
  377: 	    } 
  378: 	   return $currentstring;
  379: 	}
  380: #-- <center> tag
  381:         sub start_center {
  382: 	    my ($target,$token) = @_;
  383:             my $currentstring = '';
  384:             if ($target eq 'web') {
  385:               $currentstring = $token->[4];     
  386: 	    } elsif ($target eq 'tex') {
  387:               $currentstring = '\begin{center}';  
  388: 	    }  elsif ($target eq 'latexsource') {
  389:               $currentstring = '\begin{center}';  
  390: 	    } 
  391: 	   return $currentstring;
  392: 	}
  393:         sub end_center {
  394: 	    my ($target,$token) = @_;
  395:             my $currentstring = '';
  396:             if ($target eq 'web') {
  397:               $currentstring = $token->[2];     
  398: 	    } elsif ($target eq 'tex') {
  399:               $currentstring = '\end{center}';  
  400: 	    }  elsif ($target eq 'latexsource') {
  401:               $currentstring = '\end{center}';  
  402: 	    } 
  403: 	   return $currentstring;
  404: 	}
  405: #-- <b> tag
  406:         sub start_b {
  407: 	    my ($target,$token) = @_;
  408:             my $currentstring = '';
  409:             if ($target eq 'web') {
  410:               $currentstring = $token->[4];     
  411: 	    } elsif ($target eq 'tex') {
  412:               $currentstring = '\textbf{';  
  413: 	    }  elsif ($target eq 'latexsource') {
  414:               $currentstring = '\textbf{';  
  415: 	    } 
  416: 	   return $currentstring;
  417: 	}
  418:         sub end_b {
  419: 	    my ($target,$token) = @_;
  420:             my $currentstring = '';
  421:             if ($target eq 'web') {
  422:               $currentstring = $token->[2];     
  423: 	    } elsif ($target eq 'tex') {
  424:               $currentstring = '}';  
  425: 
  426: 	    } elsif ($target eq 'latexsource') {
  427:               $currentstring = '}';  
  428: 	    } 
  429: 	   return $currentstring;
  430: 	}
  431: #-- <strong> tag
  432:         sub start_strong {
  433: 	    my ($target,$token) = @_;
  434:             my $currentstring = '';
  435:             if ($target eq 'web') {
  436:               $currentstring = $token->[4];     
  437: 	    } elsif ($target eq 'tex') {
  438:               $currentstring = '\textbf{';  
  439: 	    } elsif ($target eq 'latexsource') {
  440:               $currentstring = '\textbf{';  
  441: 	    } 
  442: 	   return $currentstring;
  443: 	}
  444:         sub end_strong {
  445: 	    my ($target,$token) = @_;
  446:             my $currentstring = '';
  447:             if ($target eq 'web') {
  448: 
  449:               $currentstring = $token->[2];     
  450: 	    } elsif ($target eq 'tex') {
  451:               $currentstring = '}';  
  452: 	    }  elsif ($target eq 'latexsource') {
  453:               $currentstring = '}';  
  454: 	    } 
  455: 	   return $currentstring;
  456: 	}
  457: #-- <h1> tag
  458:         sub start_h1 {
  459: 	    my ($target,$token) = @_;
  460:             my $currentstring = '';
  461:             if ($target eq 'web') {
  462: 	       $currentstring .= $token->[4];
  463: 	    } elsif ($target eq 'tex') {
  464: 		$currentstring .= '\large{\textbf{';
  465: 	    } elsif ($target eq 'meta') {
  466: 		$currentstring='<subject>';
  467:                 &start_output();
  468:             }
  469:            return $currentstring;
  470: 	}
  471:         sub end_h1 {
  472: 	    my ($target,$token) = @_;
  473:             my $currentstring = '';
  474:             if ($target eq 'web') {
  475: 	       $currentstring .= $token->[2];
  476: 	    } elsif ($target eq 'tex') {
  477: 		$currentstring .= '}}';
  478: 	    } elsif ($target eq 'meta') {
  479:                 &end_output();
  480: 		$currentstring='</subject>';
  481:             } 
  482:            return $currentstring;
  483: 	}
  484: #-- <h2> tag
  485:         sub start_h2 {
  486: 	    my ($target,$token) = @_;
  487:             my $currentstring = '';
  488:             if ($target eq 'web') {
  489: 	       $currentstring .= $token->[4];
  490: 	    } elsif ($target eq 'tex') {
  491: 		$currentstring .= '\large{\textbf{';
  492: 	    } 
  493:            return $currentstring;
  494: 	}
  495:         sub end_h2 {
  496: 	    my ($target,$token) = @_;
  497:             my $currentstring = '';
  498:             if ($target eq 'web') {
  499: 	       $currentstring .= $token->[2];
  500: 	    } elsif ($target eq 'tex') {
  501: 		$currentstring .= '}}';
  502: 	    } 
  503:            return $currentstring;
  504: 	}
  505: #-- <h3> tag
  506:         sub start_h3 {
  507: 	    my ($target,$token) = @_;
  508:             my $currentstring = '';
  509:             if ($target eq 'web') {
  510: 	       $currentstring .= $token->[4];
  511: 	    } elsif ($target eq 'tex') {
  512: 		$currentstring .= '\large{\textbf{';
  513: 	    } 
  514:            return $currentstring;
  515: 	}
  516:         sub end_h3 {
  517: 	    my ($target,$token) = @_;
  518:             my $currentstring = '';
  519:             if ($target eq 'web') {
  520: 	       $currentstring .= $token->[2];
  521: 	    } elsif ($target eq 'tex') {
  522: 		$currentstring .= '}}';
  523: 	    } 
  524:            return $currentstring;
  525: 	}
  526: #-- <h4> tag
  527:         sub start_h4 {
  528: 	    my ($target,$token) = @_;
  529:             my $currentstring = '';
  530:             if ($target eq 'web') {
  531: 	       $currentstring .= $token->[4];
  532: 	    } elsif ($target eq 'tex') {
  533: 		$currentstring .= '\large{\textbf{';
  534: 	    } 
  535:            return $currentstring;
  536: 	}
  537:         sub end_h4 {
  538: 	    my ($target,$token) = @_;
  539:             my $currentstring = '';
  540:             if ($target eq 'web') {
  541: 	       $currentstring .= $token->[2];
  542: 	    } elsif ($target eq 'tex') {
  543: 		$currentstring .= '}}';
  544: 	    } 
  545:            return $currentstring;
  546: 	}
  547: #-- <h5> tag
  548:         sub start_h5 {
  549: 	    my ($target,$token) = @_;
  550:             my $currentstring = '';
  551:             if ($target eq 'web') {
  552: 	       $currentstring .= $token->[4];
  553: 	    } elsif ($target eq 'tex') {
  554: 		$currentstring .= '\large{\textbf{';
  555: 	    } 
  556:            return $currentstring;
  557: 	}
  558:         sub end_h5 {
  559: 	    my ($target,$token) = @_;
  560:             my $currentstring = '';
  561:             if ($target eq 'web') {
  562: 	       $currentstring .= $token->[2];
  563: 	    } elsif ($target eq 'tex') {
  564: 		$currentstring .= '}}';
  565: 	    } 
  566:            return $currentstring;
  567: 	}
  568: #-- <h6> tag
  569:         sub start_h6 {
  570: 	    my ($target,$token) = @_;
  571:             my $currentstring = '';
  572:             if ($target eq 'web') {
  573: 	       $currentstring .= $token->[4];
  574: 	    } elsif ($target eq 'tex') {
  575: 		$currentstring .= '\large{\textbf{';
  576: 	    } 
  577:            return $currentstring;
  578: 	}
  579:         sub end_h6 {
  580: 	    my ($target,$token) = @_;
  581:             my $currentstring = '';
  582:             if ($target eq 'web') {
  583: 	       $currentstring .= $token->[2];
  584: 	    } elsif ($target eq 'tex') {
  585: 		$currentstring .= '}}';
  586: 	    } 
  587:            return $currentstring;
  588: 	}
  589: #--- <cite> tag
  590:         sub start_cite {
  591: 	    my ($target,$token) = @_;
  592:             my $currentstring = '';
  593:             if ($target eq 'web') {
  594: 	       $currentstring .= $token->[4];
  595: 	    } elsif ($target eq 'tex') {
  596: 		$currentstring .= "\\textit{";
  597: 	    }  elsif ($target eq 'latexsource') {
  598: 		$currentstring .= "\\textit{";
  599: 	    } 
  600:            return $currentstring;
  601: 	}
  602:         sub end_cite {
  603: 	    my ($target,$token) = @_;
  604:             my $currentstring = '';
  605:             if ($target eq 'web') {
  606: 	       $currentstring .= $token->[2];
  607: 	    } elsif ($target eq 'tex') {
  608: 		$currentstring .= "}";
  609: 	    }  elsif ($target eq 'latexsource') {
  610: 		$currentstring .= "}";
  611: 	    } 
  612:            return $currentstring;
  613: 	}
  614: #-- <i> tag
  615:         sub start_i {
  616: 	    my ($target,$token) = @_;
  617:             my $currentstring = '';
  618:             if ($target eq 'web') {
  619: 	       $currentstring .= $token->[4];
  620: 	    } elsif ($target eq 'tex') {
  621: 		$currentstring .= '\textit{';
  622: 	    }  elsif ($target eq 'latexsource') {
  623: 		$currentstring .= '\textit{';
  624: 	    } 
  625:            return $currentstring;
  626: 	}
  627:         sub end_i {
  628: 	    my ($target,$token) = @_;
  629:             my $currentstring = '';
  630:             if ($target eq 'web') {
  631: 	       $currentstring .= $token->[2];
  632: 	    } elsif ($target eq 'tex') {
  633: 		$currentstring .= '}';
  634: 	    } elsif ($target eq 'latexsource') {
  635: 		$currentstring .= '}';
  636: 	    } 
  637:            return $currentstring;
  638: 	}
  639: #-- <address> tag
  640:         sub start_address {
  641: 	    my ($target,$token) = @_;
  642:             my $currentstring = '';
  643:             if ($target eq 'web') {
  644: 	       $currentstring .= $token->[4];
  645: 	    } elsif ($target eq 'tex') {
  646: 		$currentstring .= "\\textit{";
  647: 	    } elsif ($target eq 'latexsource') {
  648: 		$currentstring .= "\\textit{";
  649: 	    } 
  650:            return $currentstring;
  651: 	}
  652:         sub end_address {
  653: 	    my ($target,$token) = @_;
  654:             my $currentstring = '';
  655:             if ($target eq 'web') {
  656: 	       $currentstring .= $token->[2];
  657: 	    } elsif ($target eq 'tex') {
  658: 		$currentstring .= "}";
  659: 	    } elsif ($target eq 'latexsource') {
  660: 		$currentstring .= "}";
  661: 	    }
  662:            return $currentstring;
  663: 	}
  664: #-- <dfn> tag
  665:         sub start_dfn {
  666: 	    my ($target,$token) = @_;
  667:             my $currentstring = '';
  668:             if ($target eq 'web') {
  669: 	       $currentstring .= $token->[4];
  670: 	    } elsif ($target eq 'tex') {
  671: 		$currentstring .= "\\textit{";
  672: 	    } elsif ($target eq 'latexsource') {
  673: 		$currentstring .= "\\textit{";
  674: 	    } 
  675:            return $currentstring;
  676: 	}
  677:         sub end_dfn {
  678: 	    my ($target,$token) = @_;
  679:             my $currentstring = '';
  680:             if ($target eq 'web') {
  681: 	       $currentstring .= $token->[2];
  682: 	    } elsif ($target eq 'tex') {
  683: 		$currentstring .= "}";
  684: 	    } elsif ($target eq 'latexsource') {
  685: 		$currentstring .= "}";
  686: 	    } 
  687:            return $currentstring;
  688: 	}
  689: #-- <tt> tag
  690:         sub start_tt {
  691: 	    my ($target,$token) = @_;
  692:             my $currentstring = '';
  693:             if ($target eq 'web') {
  694: 	       $currentstring .= $token->[4];
  695: 	    } elsif ($target eq 'tex') {
  696: 		$currentstring .= '\texttt{';
  697: 	    } elsif ($target eq 'latexsource') {
  698: 		$currentstring .= '\texttt{';
  699: 	    } 
  700:            return $currentstring;
  701: 	}
  702:         sub end_tt {
  703: 	    my ($target,$token) = @_;
  704:             my $currentstring = '';
  705:             if ($target eq 'web') {
  706: 	       $currentstring .= $token->[2];
  707: 	    } elsif ($target eq 'tex') {
  708: 		$currentstring .= '}';
  709: 	    } elsif ($target eq 'latexsource') {
  710: 		$currentstring .= '}';
  711: 	    }
  712:            return $currentstring;
  713: 	}
  714: #-- <kbd> tag
  715:         sub start_kbd {
  716: 	    my ($target,$token) = @_;
  717:             my $currentstring = '';
  718:             if ($target eq 'web') {
  719: 	       $currentstring .= $token->[4];
  720: 	    } elsif ($target eq 'tex') {
  721: 		$currentstring .= "\\texttt";
  722: 	    } elsif ($target eq 'latexsource') {
  723: 		$currentstring .= "\\texttt{";
  724: 	    } 
  725:            return $currentstring;
  726: 	}
  727:         sub end_kbd {
  728: 	    my ($target,$token) = @_;
  729:             my $currentstring = '';
  730:             if ($target eq 'web') {
  731: 	       $currentstring .= $token->[2];
  732: 	    } elsif ($target eq 'tex') {
  733: 		$currentstring .= "}";
  734: 	    } elsif ($target eq 'latexsource') {
  735: 		$currentstring .= "}";
  736: 	    } 
  737:            return $currentstring;
  738: 	}
  739: #-- <code> tag
  740:         sub start_code {
  741: 	    my ($target,$token) = @_;
  742:             my $currentstring = '';
  743:             if ($target eq 'web') {
  744: 	       $currentstring .= $token->[4];
  745: 	    } elsif ($target eq 'tex') {
  746: 		$currentstring .= '\texttt{';
  747: 	    } 
  748:            return $currentstring;
  749: 	}
  750:         sub end_code {
  751: 	    my ($target,$token) = @_;
  752:             my $currentstring = '';
  753:             if ($target eq 'web') {
  754: 	       $currentstring .= $token->[2];
  755: 	    } elsif ($target eq 'tex') {
  756: 		$currentstring .= '}';
  757: 	    } 
  758:            return $currentstring;
  759: 	}
  760: #-- <em> tag
  761:         sub start_em {
  762: 	    my ($target,$token) = @_;
  763:             my $currentstring = '';
  764:             if ($target eq 'web') {
  765: 	       $currentstring .= $token->[4];
  766: 	    } elsif ($target eq 'tex') {
  767: 		$currentstring .= '\emph{';
  768: 	    } elsif ($target eq 'latexsource') {
  769: 		$currentstring .= '\emph{';
  770: 	    } 
  771:            return $currentstring;
  772: 	}
  773:         sub end_em {
  774: 	    my ($target,$token) = @_;
  775:             my $currentstring = '';
  776:             if ($target eq 'web') {
  777: 	       $currentstring .= $token->[2];
  778: 	    } elsif ($target eq 'tex') {
  779: 		$currentstring .= '}';
  780: 	    } elsif ($target eq 'latexsource') {
  781: 		$currentstring .= '}';
  782: 	    }  
  783:            return $currentstring;
  784: 	}
  785: #-- <q> tag
  786:         sub start_q {
  787: 	    my ($target,$token) = @_;
  788:             my $currentstring = '';
  789:             if ($target eq 'web') {
  790: 	       $currentstring .= $token->[4];
  791: 	    } elsif ($target eq 'tex') {
  792: 		$currentstring .= "\\emph{";
  793: 	    }  elsif ($target eq 'latexsource') {
  794: 		$currentstring .= "\\emph{";
  795: 	    }
  796:            return $currentstring;
  797: 	}
  798:         sub end_q {
  799: 	    my ($target,$token) = @_;
  800:             my $currentstring = '';
  801:             if ($target eq 'web') {
  802: 	       $currentstring .= $token->[2];
  803: 	    } elsif ($target eq 'tex') {
  804: 		$currentstring .= "}";
  805: 	    } elsif ($target eq 'latexsource') {
  806: 		$currentstring .= "}";
  807: 	    }  
  808:            return $currentstring;
  809: 	}
  810: #-- <p> tag
  811:         sub start_p {
  812: 	    my ($target,$token) = @_;
  813:             my $currentstring = '';
  814:             if ($target eq 'web') {
  815: 	       $currentstring .= $token->[4];
  816: 	    } elsif ($target eq 'tex') {
  817: 		$currentstring .= '{\par ';
  818: 	    } elsif ($target eq 'latexsource') {
  819: 		$currentstring .= '{\par ';
  820: 	    } 
  821:            return $currentstring;
  822: 	}
  823:         sub end_p {
  824: 	    my ($target,$token) = @_;
  825:             my $currentstring = '';
  826:             if ($target eq 'web') {
  827: 	       $currentstring .= $token->[2];
  828: 	    } elsif ($target eq 'tex') {
  829: 	        $currentstring .= '}';
  830:             } elsif ($target eq 'latexsource') {
  831: 	        $currentstring .= '}';
  832:             }
  833:            return $currentstring;
  834: 	}
  835: #-- <br> tag
  836:         sub start_br {
  837: 	    my ($target,$token) = @_;
  838:             my $currentstring = '';
  839:             if ($target eq 'web') {
  840: 	       $currentstring .= $token->[4];
  841: 	    } elsif ($target eq 'tex') {
  842: 		$currentstring .= '\\\\';
  843: 	    } elsif ($target eq 'latexsource') {
  844: 		$currentstring .= '\\';
  845: 	    } 
  846:            return $currentstring;
  847: 	}
  848:         sub end_br {
  849: 	    my ($target,$token) = @_;
  850:             my $currentstring = '';
  851:             if ($target eq 'web') {
  852: 	       $currentstring .= $token->[2];
  853: 	    }
  854:            return $currentstring;
  855: 	}
  856: #-- <big> tag
  857:         sub start_big {
  858: 	    my ($target,$token) = @_;
  859:             my $currentstring = '';
  860:             if ($target eq 'web') {
  861: 	       $currentstring .= $token->[4];
  862: 	    } elsif ($target eq 'tex') {
  863: 		$currentstring .= '\large{';
  864: 	    } elsif ($target eq 'latexsource') {
  865: 		$currentstring .= '{\Large ';
  866: 	    }  
  867:            return $currentstring;
  868: 	}
  869:         sub end_big {
  870: 	    my ($target,$token) = @_;
  871:             my $currentstring = '';
  872:             if ($target eq 'web') {
  873: 	       $currentstring .= $token->[2];
  874: 	    } elsif ($target eq 'tex') {
  875: 	        $currentstring .= '}';
  876:             } elsif ($target eq 'latexsource') {
  877: 	        $currentstring .= '}';
  878:             }
  879:            return $currentstring;
  880: 	}
  881: #-- <small> tag
  882:         sub start_small {
  883: 	    my ($target,$token) = @_;
  884:             my $currentstring = '';
  885:             if ($target eq 'web') {
  886: 	       $currentstring .= $token->[4];
  887: 	    } elsif ($target eq 'tex') {
  888: 		$currentstring .= '{\footnotesize ';
  889: 	    } elsif ($target eq 'latexsource') {
  890: 		$currentstring .= '{\footnotesize ';
  891: 	    } 
  892:            return $currentstring;
  893: 	}
  894:         sub end_small {
  895: 	    my ($target,$token) = @_;
  896:             my $currentstring = '';
  897:             if ($target eq 'web') {
  898: 	       $currentstring .= $token->[2];
  899: 	    } elsif ($target eq 'tex') {
  900: 	        $currentstring .= '}';
  901:             } elsif ($target eq 'latexsource') {
  902: 	        $currentstring .= '}';
  903:             }
  904:            return $currentstring;
  905: 	}
  906: #-- <basefont> tag
  907:       sub start_basefont {
  908: 	my ($target,$token) = @_;
  909: 	my $currentstring = '';
  910: 	if ($target eq 'web') {
  911: 	  $currentstring = $token->[4];     
  912: 	} 
  913: 	return $currentstring;
  914:       }
  915:       sub end_basefont {
  916: 	my ($target,$token) = @_;
  917: 	my $currentstring = '';
  918: 	if ($target eq 'web') {
  919: 	  $currentstring = $token->[4];     
  920: 	} 
  921: 	return $currentstring;
  922:       }
  923: #-- <font> tag
  924:          sub start_font {
  925: 	    my ($target,$token) = @_;
  926:             my $currentstring = '';
  927:             if ($target eq 'web') {
  928:               $currentstring = $token->[4];     
  929: 	    } 
  930: 	   return $currentstring;
  931: 	}
  932:         sub end_font {
  933: 	    my ($target,$token) = @_;
  934:             my $currentstring = '';
  935:             if ($target eq 'web') {
  936:               $currentstring = $token->[2];    
  937:             } 
  938: 	   return $currentstring;
  939: 	} 
  940: #-- <strike> tag
  941:         sub start_strike {
  942: 	    my ($target,$token) = @_;
  943:             my $currentstring = '';
  944:             if ($target eq 'web') {
  945: 	       $currentstring .= $token->[4];
  946: 	    } elsif ($target eq 'tex') {
  947: 		$currentstring .= "{\\underline ";
  948: 	    } 
  949:            return $currentstring;
  950: 	}
  951:         sub end_strike {
  952: 	    my ($target,$token) = @_;
  953:             my $currentstring = '';
  954:             if ($target eq 'web') {
  955: 	       $currentstring .= $token->[2];
  956: 	    } elsif ($target eq 'tex') {
  957: 	        $currentstring .= " }";
  958:             }
  959:            return $currentstring;
  960: 	}
  961: #-- <s> tag
  962:         sub start_s {
  963: 	    my ($target,$token) = @_;
  964:             my $currentstring = '';
  965:             if ($target eq 'web') {
  966: 	       $currentstring .= $token->[4];
  967: 	    } elsif ($target eq 'tex') {
  968: 		$currentstring .= "{\\underline ";
  969: 	    } 
  970:            return $currentstring;
  971: 	}
  972:         sub end_s {
  973: 	    my ($target,$token) = @_;
  974:             my $currentstring = '';
  975:             if ($target eq 'web') {
  976: 	       $currentstring .= $token->[2];
  977: 	    } elsif ($target eq 'tex') {
  978: 	        $currentstring .= " }";
  979:             }
  980:            return $currentstring;
  981: 	}
  982: #-- <sub> tag
  983:         sub start_sub {
  984: 	    my ($target,$token) = @_;
  985:             my $currentstring = '';
  986:             if ($target eq 'web') {
  987: 	       $currentstring .= $token->[4];
  988: 	    } elsif ($target eq 'tex') {
  989: 		$currentstring .= "\$_{ ";
  990: 	    } 
  991:            return $currentstring;
  992: 	}
  993:         sub end_sub {
  994: 	    my ($target,$token) = @_;
  995:             my $currentstring = '';
  996:             if ($target eq 'web') {
  997: 	       $currentstring .= $token->[2];
  998: 	    } elsif ($target eq 'tex') {
  999: 	        $currentstring .= " }\$";
 1000:             }
 1001:            return $currentstring;
 1002: 	}
 1003: #-- <sup> tag
 1004:         sub start_sup {
 1005: 	    my ($target,$token) = @_;
 1006:             my $currentstring = '';
 1007:             if ($target eq 'web') {
 1008: 	       $currentstring .= $token->[4];
 1009: 	    } elsif ($target eq 'tex') {
 1010: 		$currentstring .= "\$^{ ";
 1011: 	    } 
 1012:            return $currentstring;
 1013: 	}
 1014:         sub end_sup {
 1015: 	    my ($target,$token) = @_;
 1016:             my $currentstring = '';
 1017:             if ($target eq 'web') {
 1018: 	       $currentstring .= $token->[2];
 1019: 	    } elsif ($target eq 'tex') {
 1020: 	        $currentstring .= " }\$";
 1021:             }
 1022:            return $currentstring;
 1023: 	}
 1024: #-- <hr> tag
 1025:         sub start_hr {
 1026: 	    my ($target,$token) = @_;
 1027:             my $currentstring = '';
 1028:             if ($target eq 'web') {
 1029: 	       $currentstring .= $token->[4];
 1030: 	    } elsif ($target eq 'tex') {
 1031: 		$currentstring .= "\\hline ";
 1032: 	    } 
 1033:            return $currentstring;
 1034: 	}
 1035:         sub end_hr {
 1036: 	    my ($target,$token) = @_;
 1037:             my $currentstring = '';
 1038:             if ($target eq 'web') {
 1039: 	       $currentstring .= $token->[2];
 1040: 	    } elsif ($target eq 'tex') {
 1041: 	    } 
 1042:            return $currentstring;
 1043: 	}
 1044: #-- <a> tag
 1045:         sub start_a {
 1046: 	    my ($target,$token) = @_;
 1047:             my $currentstring = '';
 1048:             if ($target eq 'web') {
 1049: 	       $currentstring .= $token->[4];
 1050: 	    } elsif ($target eq 'tex') {
 1051: 	    }
 1052:            return $currentstring;
 1053: 	}
 1054:         sub end_a {
 1055: 	    my ($target,$token,$tagstack,$stackref) = @_;
 1056:             my $currentstring = '';
 1057:             if ($target eq 'web') {
 1058: 	       $currentstring .= $token->[2];
 1059: 	    } elsif ($target eq 'tex') {
 1060:                 my  $tempor_var = $stackref->[$#$stackref];
 1061: 		if (index($tempor_var,'name') != -1 ) {
 1062: 		    $tempor_var =~ s/name=([^,]*),/$1/g;
 1063: #	        $currentstring .= " \\label{$tempor_var}";
 1064: 	        } elsif (index($tempor_var,'href') != -1 ) {
 1065: 		    $tempor_var =~ s/href=([^,]*),/$1/g;
 1066: 	        $currentstring .= " \\ref{$tempor_var}";
 1067: 	        }
 1068:             }
 1069:            return $currentstring;
 1070: 	}
 1071: #-- <li> tag
 1072:         sub start_li {
 1073: 	    my ($target,$token,$tagstack,$stackref) = @_;
 1074:             my $currentstring = '';
 1075:             if ($target eq 'web') {
 1076:               $currentstring = $token->[4];     
 1077: 	    } elsif ($target eq 'tex') {
 1078:                 my  $tempor_var = $stackref->[$#$stackref];
 1079:                 if (index($tempor_var,'circle') != -1 ) {
 1080: 	          $currentstring .= " \\item[o] ";
 1081: 	        } elsif (index($tempor_var,'square') != -1 ) {
 1082: 	               $currentstring .= " \\item[$\Box$] ";
 1083: 	        } elsif ($tempor_var ne '') { 
 1084: 		       $_ = $tempor_var;
 1085:                        m/my\s*([^=]*)=/;
 1086: 		       $currentstring .= " \\item[$1] ";
 1087: 		} else {
 1088: 		    $currentstring .= " \\item ";
 1089: 	        }  
 1090: 	    } 
 1091: 	   return $currentstring;
 1092: 	}
 1093:         sub end_li {
 1094: 	    my ($target,$token) = @_;
 1095:             my $currentstring = '';
 1096:             if ($target eq 'web') {
 1097:               $currentstring = $token->[2];     
 1098: 	    } 
 1099: 	   return $currentstring;
 1100: 	}
 1101: #-- <u> tag
 1102:         sub start_u {
 1103: 	    my ($target,$token) = @_;
 1104:             my $currentstring = '';
 1105:             if ($target eq 'web') {
 1106: 	       $currentstring .= $token->[4];
 1107: 	    } elsif ($target eq 'tex') {
 1108: 		$currentstring .= "{\\underline ";
 1109: 	    } 
 1110:            return $currentstring;
 1111: 	}
 1112:         sub end_u {
 1113: 	    my ($target,$token) = @_;
 1114:             my $currentstring = '';
 1115:             if ($target eq 'web') {
 1116: 	       $currentstring .= $token->[2];
 1117: 	    } elsif ($target eq 'tex') {
 1118: 	        $currentstring .= " }";
 1119:             }
 1120:            return $currentstring;
 1121: 	}
 1122: #-- <ul> tag
 1123:         sub start_ul {
 1124: 	    my ($target,$token) = @_;
 1125:             my $currentstring = '';
 1126:             if ($target eq 'web') {
 1127:               $currentstring = $token->[4];     
 1128: 	    } elsif ($target eq 'tex') {
 1129:               $currentstring = '\begin{itemize}';  
 1130: 	    } 
 1131: 	   return $currentstring;
 1132: 	}
 1133:         sub end_ul {
 1134: 	    my ($target,$token) = @_;
 1135:             my $currentstring = '';
 1136:             if ($target eq 'web') {
 1137:               $currentstring = $token->[2];     
 1138: 	    } elsif ($target eq 'tex') {
 1139:               $currentstring = '\end{itemize}';  
 1140: 	    } 
 1141: 	   return $currentstring;
 1142: 	}
 1143: #-- <menu> tag
 1144:         sub start_menu {
 1145: 	    my ($target,$token) = @_;
 1146:             my $currentstring = '';
 1147:             if ($target eq 'web') {
 1148:               $currentstring = $token->[4];     
 1149: 	    } elsif ($target eq 'tex') {
 1150:               $currentstring = " \\begin{itemize} ";  
 1151: 	    } 
 1152: 	   return $currentstring;
 1153: 	}
 1154:         sub end_menu {
 1155: 	    my ($target,$token) = @_;
 1156:             my $currentstring = '';
 1157:             if ($target eq 'web') {
 1158:               $currentstring = $token->[2];     
 1159: 	    } elsif ($target eq 'tex') {
 1160:               $currentstring = " \\end{itemize}";  
 1161: 	    } 
 1162: 	   return $currentstring;
 1163: 	}
 1164: #-- <dir> tag
 1165:         sub start_dir {
 1166: 	    my ($target,$token) = @_;
 1167:             my $currentstring = '';
 1168:             if ($target eq 'web') {
 1169:               $currentstring = $token->[4];     
 1170: 	    } elsif ($target eq 'tex') {
 1171:               $currentstring = " \\begin{itemize} ";  
 1172: 	    } 
 1173: 	   return $currentstring;
 1174: 	}
 1175:         sub end_dir {
 1176: 	    my ($target,$token) = @_;
 1177:             my $currentstring = '';
 1178:             if ($target eq 'web') {
 1179:               $currentstring = $token->[2];     
 1180: 	    } elsif ($target eq 'tex') {
 1181:               $currentstring = " \\end{itemize}";  
 1182: 	    } 
 1183: 	   return $currentstring;
 1184: 	}
 1185: #-- <ol> tag
 1186:         sub start_ol {
 1187: 	    my ($target,$token) = @_;
 1188:             my $currentstring = '';
 1189:             if ($target eq 'web') {
 1190:               $currentstring = $token->[4];     
 1191: 	    } elsif ($target eq 'tex') {
 1192:               $currentstring = '\begin{enumerate}';  
 1193: 	    } 
 1194: 	   return $currentstring;
 1195: 	}
 1196:         sub end_ol {
 1197: 	    my ($target,$token) = @_;
 1198:             my $currentstring = '';
 1199:             if ($target eq 'web') {
 1200:               $currentstring = $token->[2];     
 1201: 	    } elsif ($target eq 'tex') {
 1202:               $currentstring = '\end{enumerate}';  
 1203: 	    } 
 1204: 	   return $currentstring;
 1205: 	}
 1206: #-- <dl> tag
 1207:         sub start_dl {
 1208: 	    my ($target,$token) = @_;
 1209:             my $currentstring = '';
 1210:             if ($target eq 'web') {
 1211:               $currentstring = $token->[4];     
 1212: 	    } elsif ($target eq 'tex') {
 1213:               $currentstring = '\begin{description}';  
 1214: 	    } 
 1215: 	   return $currentstring;
 1216: 	}
 1217:         sub end_dl {
 1218: 	    my ($target,$token) = @_;
 1219:             my $currentstring = '';
 1220:             if ($target eq 'web') {
 1221:               $currentstring = $token->[2];     
 1222: 	    } elsif ($target eq 'tex') {
 1223:               $currentstring = '\end{description}';  
 1224: 	    } 
 1225: 	   return $currentstring;
 1226: 	}
 1227: #-- <dt> tag
 1228:         sub start_dt {
 1229: 	    my ($target,$token) = @_;
 1230:             my $currentstring = '';
 1231:             if ($target eq 'web') {
 1232:               $currentstring = $token->[4];     
 1233: 	    } elsif ($target eq 'tex') {
 1234:               $currentstring = '\item[';  
 1235: 	    } 
 1236: 	   return $currentstring;
 1237: 	}
 1238:         sub end_dt {
 1239: 	    my ($target,$token) = @_;
 1240:             my $currentstring = '';
 1241:             if ($target eq 'web') {
 1242:               $currentstring = $token->[2];    
 1243:             } elsif ($target eq 'tex') {
 1244:               $currentstring = ']';  
 1245: 	    } 
 1246: 	   return $currentstring;
 1247: 	}
 1248: #-- <dd> tag
 1249:         sub start_dd {
 1250: 	    my ($target,$token) = @_;
 1251:             my $currentstring = '';
 1252:             if ($target eq 'web') {
 1253:               $currentstring = $token->[4];     
 1254: 	    } 
 1255: 	   return $currentstring;
 1256: 	}
 1257:         sub end_dd {
 1258: 	    my ($target,$token) = @_;
 1259:             my $currentstring = '';
 1260:             if ($target eq 'web') {
 1261:               $currentstring = $token->[2];    
 1262:             } 
 1263: 	   return $currentstring;
 1264: 	}
 1265: #-- <table> tag
 1266:         sub start_table {
 1267: 	    my ($target,$token) = @_;
 1268:             my $currentstring = '';
 1269:             if ($target eq 'web') {
 1270:               $currentstring = $token->[4];     
 1271: 	    } elsif ($target eq 'tex') {
 1272:               $currentstring = '';  
 1273: 	    } 
 1274: 	   return $currentstring;
 1275: 	}
 1276:         sub end_table {
 1277: 	    my ($target,$token) = @_;
 1278:             my $currentstring = '';
 1279:             if ($target eq 'web') {
 1280:               $currentstring = $token->[2];     
 1281: 	    } elsif ($target eq 'tex') {
 1282:               $currentstring = '';  
 1283: 	    } 
 1284: 	   return $currentstring;
 1285: 	}
 1286: #-- <tr> tag
 1287:         sub start_tr {
 1288: 	    my ($target,$token) = @_;
 1289:             my $currentstring = '';
 1290:             if ($target eq 'web') {
 1291:               $currentstring = $token->[4];     
 1292: 	    } elsif ($target eq 'tex') {
 1293: 	      $currentstring = '';
 1294: 	    } 
 1295: 	   return $currentstring;
 1296: 	}
 1297:         sub end_tr {
 1298: 	    my ($target,$token) = @_;
 1299:             my $currentstring = '';
 1300:             if ($target eq 'web') {
 1301:               $currentstring = $token->[2];     
 1302: 	    } elsif ($target eq 'tex') {
 1303:               $currentstring = '';  
 1304: 	    } 
 1305: 	   return $currentstring;
 1306: 	}
 1307: #-- <td> tag
 1308:         sub start_td {
 1309: 	    my ($target,$token) = @_;
 1310:             my $currentstring = '';
 1311:             if ($target eq 'web') {
 1312:               $currentstring = $token->[4];     
 1313: 	    } elsif ($target eq 'tex') {
 1314: 	      $currentstring = '';
 1315: 	    } 
 1316: 	   return $currentstring;
 1317: 	}
 1318:         sub end_td {
 1319: 	    my ($target,$token) = @_;
 1320:             my $currentstring = '';
 1321:             if ($target eq 'web') {
 1322:               $currentstring = $token->[2];     
 1323: 	    } elsif ($target eq 'tex') {
 1324:               $currentstring = '';  
 1325: 	    } 
 1326: 	   return $currentstring;
 1327: 	}
 1328: #-- <img> tag
 1329:         sub start_img {
 1330: 	    my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
 1331:             $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=   
 1332:                                         $token->[2]->{'src'};
 1333:             my $currentstring = '';
 1334: 	    if ($target eq 'web') {
 1335:               $currentstring = $token->[4];     
 1336: 	    } elsif ($target eq 'tex') {
 1337: 	      my $src = &Apache::lonxml::get_param('src',$parstack,$safeeval);
 1338: 	      my $file;
 1339: 	      my $path;
 1340:               if ($src =~ m!(.*)/([^/]*)$!) {
 1341: 		$file = $2;
 1342: 		$path = $1;
 1343: 		if ($path=~m:^/:) {
 1344: 		  $path = '/home/httpd/html'.$path;
 1345: 		} elsif ($path =~ /^\./) {
 1346: 		  $path = $Apache::lonxml::pwd[-1].'/'.$path;
 1347: 		} else {
 1348: 		  #else it is a full url don't print
 1349: 		  $path = undef;
 1350: 		}
 1351: 	      } else {
 1352: 		$path = $Apache::lonxml::pwd[-1];
 1353: 		$file = $src;
 1354: 	      }
 1355: 	      $file=~s/(\.gif|\.jpg)^/\.eps/;
 1356: 	      if ($path) {
 1357: 		$currentstring = '\graphicspath{{'.$path.'}}\fbox{\includegraphics{'.$file.'}}';
 1358: 	      } else {
 1359: 		$currentstring = 'See the image at \tt{'.$src.'}';
 1360: 	      }
 1361: 	    }
 1362: 	    return $currentstring;
 1363: 	}
 1364:         sub end_img {
 1365: 	    my ($target,$token) = @_;
 1366:             my $currentstring = '';
 1367:             if ($target eq 'web') {
 1368:               $currentstring = $token->[2];  
 1369: 	    } elsif ($target eq 'tex') {
 1370:               $currentstring = '';  
 1371: 	    } 
 1372: 	   return $currentstring;
 1373: 	}
 1374: #-- <applet> tag
 1375: 
 1376:         sub start_applet {
 1377: 	    my ($target,$token) = @_;
 1378:               $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=   
 1379:                                         $token->[2]->{'code'};
 1380:               $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=   
 1381:                                         $token->[2]->{'archive'};
 1382:             my $currentstring = '';
 1383:             if ($target eq 'web') {
 1384:               $currentstring = $token->[4];     
 1385: 	    } elsif ($target eq 'tex') {
 1386:               $currentstring = " \\begin{figure} ";  
 1387: 	    } 
 1388: 	   return $currentstring;
 1389: 	}
 1390:         sub end_applet {
 1391: 	    my ($target,$token) = @_;
 1392:             my $currentstring = '';
 1393:             if ($target eq 'web') {
 1394:               $currentstring = $token->[2];     
 1395: 	    } elsif ($target eq 'tex') {
 1396:               $currentstring = " \\end{figure}";  
 1397: 	    } 
 1398: 	   return $currentstring;
 1399: 	}
 1400: 
 1401: #-- <embed> tag
 1402: 
 1403:         sub start_embed {
 1404: 	    my ($target,$token) = @_;
 1405:             $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=   
 1406:                                         $token->[2]->{'src'};
 1407:            my $currentstring = '';
 1408:             if ($target eq 'web') {
 1409:               $currentstring = $token->[4];     
 1410: 	    } elsif ($target eq 'tex') {
 1411:               $currentstring = " \\begin{figure} ";  
 1412: 	    } 
 1413: 	   return $currentstring;
 1414: 	}
 1415:         sub end_embed {
 1416: 	    my ($target,$token) = @_;
 1417:             my $currentstring = '';
 1418:             if ($target eq 'web') {
 1419:               $currentstring = $token->[2];     
 1420: 	    } elsif ($target eq 'tex') {
 1421:               $currentstring = " \\end{figure}";  
 1422: 	    } 
 1423: 	   return $currentstring;
 1424: 	}
 1425: 
 1426: #-- <param> tag
 1427: 
 1428:         sub start_param {
 1429: 	    my ($target,$token) = @_;
 1430: 	    if ($token->[2]->{'name'} eq 'cabbase') {
 1431:                       $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=
 1432: 					     $token->[2]->{'value'};
 1433:             }   
 1434:             $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=   
 1435:                                         $token->[2]->{'src'};
 1436:             my $currentstring = '';
 1437:             if ($target eq 'web') {
 1438:               $currentstring = $token->[4];     
 1439: 	    } elsif ($target eq 'tex') {
 1440:               $currentstring = " \\begin{figure} ";  
 1441: 	    } 
 1442: 	   return $currentstring;
 1443: 	}
 1444:         sub end_param {
 1445: 	    my ($target,$token) = @_;
 1446:             my $currentstring = '';
 1447:             if ($target eq 'web') {
 1448:               $currentstring = $token->[2];     
 1449: 	    } elsif ($target eq 'tex') {
 1450:               $currentstring = " \\end{figure}";  
 1451: 	    } 
 1452: 	   return $currentstring;
 1453: 	}
 1454: 
 1455: #-- <allow> tag
 1456: 
 1457:         sub start_allow {
 1458: 	    my ($target,$token) = @_;
 1459: 
 1460:             $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=   
 1461:                                         $token->[2]->{'src'};
 1462: 
 1463: 	   return '';
 1464: 	}
 1465:         sub end_allow {
 1466: 	   return '';
 1467: 	}
 1468: #-- Frames
 1469: 	sub start_frameset {
 1470: 	  my ($target,$token) = @_;
 1471: 	  my $currentstring = '';
 1472: 	  if ($target eq 'web') { 
 1473: 	    if (!$Apache::lonxml::registered) {
 1474: 	      $currentstring.='<head>'.&Apache::lonxml::registerurl().'</head>';
 1475: 	    }
 1476: 	    $currentstring .= $token->[4];
 1477: 	  }
 1478: 	  return $currentstring;
 1479: 	}
 1480:         sub end_frameset {
 1481: 	  my ($target,$token) = @_;
 1482: 	  my $currentstring = '';
 1483: 	  if ($target eq 'web') {
 1484: 	    $currentstring = $token->[2];
 1485: 	  }
 1486: 	  return $currentstring;
 1487: 	}
 1488: #-- <pre>
 1489: 	sub start_pre {
 1490: 	    my ($target,$token) = @_;
 1491:             my $currentstring = '';
 1492:             if ($target eq 'web') {
 1493: 	       $currentstring .= $token->[4];
 1494: 	    } elsif ($target eq 'tex') {
 1495: 		$currentstring .= '\begin{verbatim}';
 1496: 	    } 
 1497:            return $currentstring;
 1498: 	}
 1499:         sub end_pre {
 1500: 	    my ($target,$token) = @_;
 1501:             my $currentstring = '';
 1502:             if ($target eq 'web') {
 1503: 	       $currentstring .= $token->[2];
 1504: 	    } elsif ($target eq 'tex') {
 1505: 		$currentstring .= '\end{verbatim}';
 1506: 	    }
 1507:            return $currentstring;
 1508: 	}
 1509: 1;
 1510: __END__

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