File:  [LON-CAPA] / loncom / xml / londefdef.pm
Revision 1.59: download - view: text, annotated - select for diffs
Wed May 15 14:45:45 2002 UTC (22 years ago) by sakharuk
Branches: MAIN
CVS tags: HEAD
added <th> tag

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

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