File:  [LON-CAPA] / loncom / xml / londefdef.pm
Revision 1.53: download - view: text, annotated - select for diffs
Tue Apr 16 14:37:24 2002 UTC (22 years, 1 month ago) by sakharuk
Branches: MAIN
CVS tags: HEAD
now works for nested tables

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

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