File:  [LON-CAPA] / loncom / xml / londefdef.pm
Revision 1.55: download - view: text, annotated - select for diffs
Fri Apr 26 18:25:56 2002 UTC (22 years, 1 month ago) by sakharuk
Branches: MAIN
CVS tags: stable_2002_april, HEAD
sorry, I commited the wrong version last time``

    1: 
    2: # The LearningOnline Network with CAPA
    3: # Tags Default Definition Module 
    4: #
    5: # $Id: londefdef.pm,v 1.55 2002/04/26 18:25:56 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: 
   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','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'}=$onLoad.&Apache::lonxml::loadevents();
  341: 	      my $onUnload='';
  342: 	      foreach my $key (keys(%{$token->[2]})) {
  343: 		if ($key =~ /^onunload$/i) {
  344: 		  $onUnload.=$token->[2]->{$key}.';';
  345: 		  delete($token->[2]->{$key});
  346: 		}
  347: 	      }
  348: 	      $token->[2]->{'onUnload'}=$onUnload.
  349: 		&Apache::lonxml::unloadevents();
  350: 
  351: 	      $currentstring .= '<'.$token->[1];
  352: 	      foreach (keys %{$token->[2]}) {
  353: 	      	$currentstring.=' '.$_.'="'.$token->[2]->{$_}.'"';
  354: 	      }
  355: 	      $currentstring.='>';
  356: 	      if ($ENV{'request.state'} ne 'published') {
  357: 		$currentstring.=(<<EDITBUTTON);
  358: 		<form method="post">
  359: 		<input type="submit" name="editmode" value="Edit" />
  360: 		</form>
  361: EDITBUTTON
  362: 	      }
  363:        	    } elsif ($target eq 'tex') {
  364:               $currentstring = '\begin{document}';  
  365: 	    } 
  366: 	   return $currentstring;
  367: 	}
  368:         sub end_body {
  369: 	    my ($target,$token) = @_;
  370:             my $currentstring = '';
  371:             if ($target eq 'web') {
  372:               $currentstring = $token->[2];     
  373: 	    } elsif ($target eq 'tex') {
  374:               $currentstring = '\end{document}';  
  375: 	    } 
  376: 	   return $currentstring;
  377: 	}
  378: #-- <center> tag
  379:         sub start_center {
  380: 	    my ($target,$token) = @_;
  381:             my $currentstring = '';
  382:             if ($target eq 'web') {
  383:               $currentstring = $token->[4];     
  384: 	    } elsif ($target eq 'tex') {
  385:               $currentstring = '\begin{center}';  
  386: 	    }  elsif ($target eq 'latexsource') {
  387:               $currentstring = '\begin{center}';  
  388: 	    } 
  389: 	   return $currentstring;
  390: 	}
  391:         sub end_center {
  392: 	    my ($target,$token) = @_;
  393:             my $currentstring = '';
  394:             if ($target eq 'web') {
  395:               $currentstring = $token->[2];     
  396: 	    } elsif ($target eq 'tex') {
  397:               $currentstring = '\end{center}';  
  398: 	    }  elsif ($target eq 'latexsource') {
  399:               $currentstring = '\end{center}';  
  400: 	    } 
  401: 	   return $currentstring;
  402: 	}
  403: #-- <b> tag
  404:         sub start_b {
  405: 	    my ($target,$token) = @_;
  406:             my $currentstring = '';
  407:             if ($target eq 'web') {
  408:               $currentstring = $token->[4];     
  409: 	    } elsif ($target eq 'tex') {
  410:               $currentstring = '\textbf{';  
  411: 	    }  elsif ($target eq 'latexsource') {
  412:               $currentstring = '\textbf{';  
  413: 	    } 
  414: 	   return $currentstring;
  415: 	}
  416:         sub end_b {
  417: 	    my ($target,$token) = @_;
  418:             my $currentstring = '';
  419:             if ($target eq 'web') {
  420:               $currentstring = $token->[2];     
  421: 	    } elsif ($target eq 'tex') {
  422:               $currentstring = '}';  
  423: 
  424: 	    } elsif ($target eq 'latexsource') {
  425:               $currentstring = '}';  
  426: 	    } 
  427: 	   return $currentstring;
  428: 	}
  429: #-- <strong> tag
  430:         sub start_strong {
  431: 	    my ($target,$token) = @_;
  432:             my $currentstring = '';
  433:             if ($target eq 'web') {
  434:               $currentstring = $token->[4];     
  435: 	    } elsif ($target eq 'tex') {
  436:               $currentstring = '\textbf{';  
  437: 	    } elsif ($target eq 'latexsource') {
  438:               $currentstring = '\textbf{';  
  439: 	    } 
  440: 	   return $currentstring;
  441: 	}
  442:         sub end_strong {
  443: 	    my ($target,$token) = @_;
  444:             my $currentstring = '';
  445:             if ($target eq 'web') {
  446: 
  447:               $currentstring = $token->[2];     
  448: 	    } elsif ($target eq 'tex') {
  449:               $currentstring = '}';  
  450: 	    }  elsif ($target eq 'latexsource') {
  451:               $currentstring = '}';  
  452: 	    } 
  453: 	   return $currentstring;
  454: 	}
  455: #-- <h1> tag
  456:         sub start_h1 {
  457: 	    my ($target,$token) = @_;
  458:             my $currentstring = '';
  459:             if ($target eq 'web') {
  460: 	       $currentstring .= $token->[4];
  461: 	    } elsif ($target eq 'tex') {
  462: 		$currentstring .= '\large{\textbf{';
  463: 	    } elsif ($target eq 'meta') {
  464: 		$currentstring='<subject>';
  465:                 &start_output();
  466:             }
  467:            return $currentstring;
  468: 	}
  469:         sub end_h1 {
  470: 	    my ($target,$token) = @_;
  471:             my $currentstring = '';
  472:             if ($target eq 'web') {
  473: 	       $currentstring .= $token->[2];
  474: 	    } elsif ($target eq 'tex') {
  475: 		$currentstring .= '}}';
  476: 	    } elsif ($target eq 'meta') {
  477:                 &end_output();
  478: 		$currentstring='</subject>';
  479:             } 
  480:            return $currentstring;
  481: 	}
  482: #-- <h2> tag
  483:         sub start_h2 {
  484: 	    my ($target,$token) = @_;
  485:             my $currentstring = '';
  486:             if ($target eq 'web') {
  487: 	       $currentstring .= $token->[4];
  488: 	    } elsif ($target eq 'tex') {
  489: 		$currentstring .= '\large{\textbf{';
  490: 	    } 
  491:            return $currentstring;
  492: 	}
  493:         sub end_h2 {
  494: 	    my ($target,$token) = @_;
  495:             my $currentstring = '';
  496:             if ($target eq 'web') {
  497: 	       $currentstring .= $token->[2];
  498: 	    } elsif ($target eq 'tex') {
  499: 		$currentstring .= '}}';
  500: 	    } 
  501:            return $currentstring;
  502: 	}
  503: #-- <h3> tag
  504:         sub start_h3 {
  505: 	    my ($target,$token) = @_;
  506:             my $currentstring = '';
  507:             if ($target eq 'web') {
  508: 	       $currentstring .= $token->[4];
  509: 	    } elsif ($target eq 'tex') {
  510: 		$currentstring .= '\large{\textbf{';
  511: 	    } 
  512:            return $currentstring;
  513: 	}
  514:         sub end_h3 {
  515: 	    my ($target,$token) = @_;
  516:             my $currentstring = '';
  517:             if ($target eq 'web') {
  518: 	       $currentstring .= $token->[2];
  519: 	    } elsif ($target eq 'tex') {
  520: 		$currentstring .= '}}';
  521: 	    } 
  522:            return $currentstring;
  523: 	}
  524: #-- <h4> tag
  525:         sub start_h4 {
  526: 	    my ($target,$token) = @_;
  527:             my $currentstring = '';
  528:             if ($target eq 'web') {
  529: 	       $currentstring .= $token->[4];
  530: 	    } elsif ($target eq 'tex') {
  531: 		$currentstring .= '\large{\textbf{';
  532: 	    } 
  533:            return $currentstring;
  534: 	}
  535:         sub end_h4 {
  536: 	    my ($target,$token) = @_;
  537:             my $currentstring = '';
  538:             if ($target eq 'web') {
  539: 	       $currentstring .= $token->[2];
  540: 	    } elsif ($target eq 'tex') {
  541: 		$currentstring .= '}}';
  542: 	    } 
  543:            return $currentstring;
  544: 	}
  545: #-- <h5> tag
  546:         sub start_h5 {
  547: 	    my ($target,$token) = @_;
  548:             my $currentstring = '';
  549:             if ($target eq 'web') {
  550: 	       $currentstring .= $token->[4];
  551: 	    } elsif ($target eq 'tex') {
  552: 		$currentstring .= '\large{\textbf{';
  553: 	    } 
  554:            return $currentstring;
  555: 	}
  556:         sub end_h5 {
  557: 	    my ($target,$token) = @_;
  558:             my $currentstring = '';
  559:             if ($target eq 'web') {
  560: 	       $currentstring .= $token->[2];
  561: 	    } elsif ($target eq 'tex') {
  562: 		$currentstring .= '}}';
  563: 	    } 
  564:            return $currentstring;
  565: 	}
  566: #-- <h6> tag
  567:         sub start_h6 {
  568: 	    my ($target,$token) = @_;
  569:             my $currentstring = '';
  570:             if ($target eq 'web') {
  571: 	       $currentstring .= $token->[4];
  572: 	    } elsif ($target eq 'tex') {
  573: 		$currentstring .= '\large{\textbf{';
  574: 	    } 
  575:            return $currentstring;
  576: 	}
  577:         sub end_h6 {
  578: 	    my ($target,$token) = @_;
  579:             my $currentstring = '';
  580:             if ($target eq 'web') {
  581: 	       $currentstring .= $token->[2];
  582: 	    } elsif ($target eq 'tex') {
  583: 		$currentstring .= '}}';
  584: 	    } 
  585:            return $currentstring;
  586: 	}
  587: #--- <cite> tag
  588:         sub start_cite {
  589: 	    my ($target,$token) = @_;
  590:             my $currentstring = '';
  591:             if ($target eq 'web') {
  592: 	       $currentstring .= $token->[4];
  593: 	    } elsif ($target eq 'tex') {
  594: 		$currentstring .= "\\textit{";
  595: 	    }  elsif ($target eq 'latexsource') {
  596: 		$currentstring .= "\\textit{";
  597: 	    } 
  598:            return $currentstring;
  599: 	}
  600:         sub end_cite {
  601: 	    my ($target,$token) = @_;
  602:             my $currentstring = '';
  603:             if ($target eq 'web') {
  604: 	       $currentstring .= $token->[2];
  605: 	    } elsif ($target eq 'tex') {
  606: 		$currentstring .= "}";
  607: 	    }  elsif ($target eq 'latexsource') {
  608: 		$currentstring .= "}";
  609: 	    } 
  610:            return $currentstring;
  611: 	}
  612: #-- <i> tag
  613:         sub start_i {
  614: 	    my ($target,$token) = @_;
  615:             my $currentstring = '';
  616:             if ($target eq 'web') {
  617: 	       $currentstring .= $token->[4];
  618: 	    } elsif ($target eq 'tex') {
  619: 		$currentstring .= '\textit{';
  620: 	    }  elsif ($target eq 'latexsource') {
  621: 		$currentstring .= '\textit{';
  622: 	    } 
  623:            return $currentstring;
  624: 	}
  625:         sub end_i {
  626: 	    my ($target,$token) = @_;
  627:             my $currentstring = '';
  628:             if ($target eq 'web') {
  629: 	       $currentstring .= $token->[2];
  630: 	    } elsif ($target eq 'tex') {
  631: 		$currentstring .= '}';
  632: 	    } elsif ($target eq 'latexsource') {
  633: 		$currentstring .= '}';
  634: 	    } 
  635:            return $currentstring;
  636: 	}
  637: #-- <address> tag
  638:         sub start_address {
  639: 	    my ($target,$token) = @_;
  640:             my $currentstring = '';
  641:             if ($target eq 'web') {
  642: 	       $currentstring .= $token->[4];
  643: 	    } elsif ($target eq 'tex') {
  644: 		$currentstring .= "\\textit{";
  645: 	    } elsif ($target eq 'latexsource') {
  646: 		$currentstring .= "\\textit{";
  647: 	    } 
  648:            return $currentstring;
  649: 	}
  650:         sub end_address {
  651: 	    my ($target,$token) = @_;
  652:             my $currentstring = '';
  653:             if ($target eq 'web') {
  654: 	       $currentstring .= $token->[2];
  655: 	    } elsif ($target eq 'tex') {
  656: 		$currentstring .= "}";
  657: 	    } elsif ($target eq 'latexsource') {
  658: 		$currentstring .= "}";
  659: 	    }
  660:            return $currentstring;
  661: 	}
  662: #-- <dfn> tag
  663:         sub start_dfn {
  664: 	    my ($target,$token) = @_;
  665:             my $currentstring = '';
  666:             if ($target eq 'web') {
  667: 	       $currentstring .= $token->[4];
  668: 	    } elsif ($target eq 'tex') {
  669: 		$currentstring .= "\\textit{";
  670: 	    } elsif ($target eq 'latexsource') {
  671: 		$currentstring .= "\\textit{";
  672: 	    } 
  673:            return $currentstring;
  674: 	}
  675:         sub end_dfn {
  676: 	    my ($target,$token) = @_;
  677:             my $currentstring = '';
  678:             if ($target eq 'web') {
  679: 	       $currentstring .= $token->[2];
  680: 	    } elsif ($target eq 'tex') {
  681: 		$currentstring .= "}";
  682: 	    } elsif ($target eq 'latexsource') {
  683: 		$currentstring .= "}";
  684: 	    } 
  685:            return $currentstring;
  686: 	}
  687: #-- <tt> tag
  688:         sub start_tt {
  689: 	    my ($target,$token) = @_;
  690:             my $currentstring = '';
  691:             if ($target eq 'web') {
  692: 	       $currentstring .= $token->[4];
  693: 	    } elsif ($target eq 'tex') {
  694: 		$currentstring .= '\texttt{';
  695: 	    } elsif ($target eq 'latexsource') {
  696: 		$currentstring .= '\texttt{';
  697: 	    } 
  698:            return $currentstring;
  699: 	}
  700:         sub end_tt {
  701: 	    my ($target,$token) = @_;
  702:             my $currentstring = '';
  703:             if ($target eq 'web') {
  704: 	       $currentstring .= $token->[2];
  705: 	    } elsif ($target eq 'tex') {
  706: 		$currentstring .= '}';
  707: 	    } elsif ($target eq 'latexsource') {
  708: 		$currentstring .= '}';
  709: 	    }
  710:            return $currentstring;
  711: 	}
  712: #-- <kbd> tag
  713:         sub start_kbd {
  714: 	    my ($target,$token) = @_;
  715:             my $currentstring = '';
  716:             if ($target eq 'web') {
  717: 	       $currentstring .= $token->[4];
  718: 	    } elsif ($target eq 'tex') {
  719: 		$currentstring .= "\\texttt";
  720: 	    } elsif ($target eq 'latexsource') {
  721: 		$currentstring .= "\\texttt{";
  722: 	    } 
  723:            return $currentstring;
  724: 	}
  725:         sub end_kbd {
  726: 	    my ($target,$token) = @_;
  727:             my $currentstring = '';
  728:             if ($target eq 'web') {
  729: 	       $currentstring .= $token->[2];
  730: 	    } elsif ($target eq 'tex') {
  731: 		$currentstring .= "}";
  732: 	    } elsif ($target eq 'latexsource') {
  733: 		$currentstring .= "}";
  734: 	    } 
  735:            return $currentstring;
  736: 	}
  737: #-- <code> tag
  738:         sub start_code {
  739: 	    my ($target,$token) = @_;
  740:             my $currentstring = '';
  741:             if ($target eq 'web') {
  742: 	       $currentstring .= $token->[4];
  743: 	    } elsif ($target eq 'tex') {
  744: 		$currentstring .= '\texttt{';
  745: 	    } 
  746:            return $currentstring;
  747: 	}
  748:         sub end_code {
  749: 	    my ($target,$token) = @_;
  750:             my $currentstring = '';
  751:             if ($target eq 'web') {
  752: 	       $currentstring .= $token->[2];
  753: 	    } elsif ($target eq 'tex') {
  754: 		$currentstring .= '}';
  755: 	    } 
  756:            return $currentstring;
  757: 	}
  758: #-- <em> tag
  759:         sub start_em {
  760: 	    my ($target,$token) = @_;
  761:             my $currentstring = '';
  762:             if ($target eq 'web') {
  763: 	       $currentstring .= $token->[4];
  764: 	    } elsif ($target eq 'tex') {
  765: 		$currentstring .= '\emph{';
  766: 	    } elsif ($target eq 'latexsource') {
  767: 		$currentstring .= '\emph{';
  768: 	    } 
  769:            return $currentstring;
  770: 	}
  771:         sub end_em {
  772: 	    my ($target,$token) = @_;
  773:             my $currentstring = '';
  774:             if ($target eq 'web') {
  775: 	       $currentstring .= $token->[2];
  776: 	    } elsif ($target eq 'tex') {
  777: 		$currentstring .= '}';
  778: 	    } elsif ($target eq 'latexsource') {
  779: 		$currentstring .= '}';
  780: 	    }  
  781:            return $currentstring;
  782: 	}
  783: #-- <q> tag
  784:         sub start_q {
  785: 	    my ($target,$token) = @_;
  786:             my $currentstring = '';
  787:             if ($target eq 'web') {
  788: 	       $currentstring .= $token->[4];
  789: 	    } elsif ($target eq 'tex') {
  790: 		$currentstring .= "\\emph{";
  791: 	    }  elsif ($target eq 'latexsource') {
  792: 		$currentstring .= "\\emph{";
  793: 	    }
  794:            return $currentstring;
  795: 	}
  796:         sub end_q {
  797: 	    my ($target,$token) = @_;
  798:             my $currentstring = '';
  799:             if ($target eq 'web') {
  800: 	       $currentstring .= $token->[2];
  801: 	    } elsif ($target eq 'tex') {
  802: 		$currentstring .= "}";
  803: 	    } elsif ($target eq 'latexsource') {
  804: 		$currentstring .= "}";
  805: 	    }  
  806:            return $currentstring;
  807: 	}
  808: #-- <p> tag
  809:         sub start_p {
  810: 	    my ($target,$token) = @_;
  811:             my $currentstring = '';
  812:             if ($target eq 'web') {
  813: 	       $currentstring .= $token->[4];
  814: 	    } elsif ($target eq 'tex') {
  815: 		$currentstring .= '{\par ';
  816: 	    } elsif ($target eq 'latexsource') {
  817: 		$currentstring .= '{\par ';
  818: 	    } 
  819:            return $currentstring;
  820: 	}
  821:         sub end_p {
  822: 	    my ($target,$token) = @_;
  823:             my $currentstring = '';
  824:             if ($target eq 'web') {
  825: 	       $currentstring .= $token->[2];
  826: 	    } elsif ($target eq 'tex') {
  827: 	        $currentstring .= '}';
  828:             } elsif ($target eq 'latexsource') {
  829: 	        $currentstring .= '}';
  830:             }
  831:            return $currentstring;
  832: 	}
  833: #-- <br> tag
  834:         sub start_br {
  835: 	    my ($target,$token) = @_;
  836:             my $currentstring = '';
  837:             if ($target eq 'web') {
  838: 	       $currentstring .= $token->[4];
  839: 	    } elsif ($target eq 'tex') {
  840: 		$currentstring .= '\\\\';
  841: 	    } elsif ($target eq 'latexsource') {
  842: 		$currentstring .= '\\';
  843: 	    } 
  844:            return $currentstring;
  845: 	}
  846:         sub end_br {
  847: 	    my ($target,$token) = @_;
  848:             my $currentstring = '';
  849:             if ($target eq 'web') {
  850: 	       $currentstring .= $token->[2];
  851: 	    }
  852:            return $currentstring;
  853: 	}
  854: #-- <big> tag
  855:         sub start_big {
  856: 	    my ($target,$token) = @_;
  857:             my $currentstring = '';
  858:             if ($target eq 'web') {
  859: 	       $currentstring .= $token->[4];
  860: 	    } elsif ($target eq 'tex') {
  861: 		$currentstring .= '\large{';
  862: 	    } elsif ($target eq 'latexsource') {
  863: 		$currentstring .= '{\Large ';
  864: 	    }  
  865:            return $currentstring;
  866: 	}
  867:         sub end_big {
  868: 	    my ($target,$token) = @_;
  869:             my $currentstring = '';
  870:             if ($target eq 'web') {
  871: 	       $currentstring .= $token->[2];
  872: 	    } elsif ($target eq 'tex') {
  873: 	        $currentstring .= '}';
  874:             } elsif ($target eq 'latexsource') {
  875: 	        $currentstring .= '}';
  876:             }
  877:            return $currentstring;
  878: 	}
  879: #-- <small> tag
  880:         sub start_small {
  881: 	    my ($target,$token) = @_;
  882:             my $currentstring = '';
  883:             if ($target eq 'web') {
  884: 	       $currentstring .= $token->[4];
  885: 	    } elsif ($target eq 'tex') {
  886: 		$currentstring .= '{\footnotesize ';
  887: 	    } elsif ($target eq 'latexsource') {
  888: 		$currentstring .= '{\footnotesize ';
  889: 	    } 
  890:            return $currentstring;
  891: 	}
  892:         sub end_small {
  893: 	    my ($target,$token) = @_;
  894:             my $currentstring = '';
  895:             if ($target eq 'web') {
  896: 	       $currentstring .= $token->[2];
  897: 	    } elsif ($target eq 'tex') {
  898: 	        $currentstring .= '}';
  899:             } elsif ($target eq 'latexsource') {
  900: 	        $currentstring .= '}';
  901:             }
  902:            return $currentstring;
  903: 	}
  904: #-- <basefont> tag
  905:       sub start_basefont {
  906: 	my ($target,$token) = @_;
  907: 	my $currentstring = '';
  908: 	if ($target eq 'web') {
  909: 	  $currentstring = $token->[4];     
  910: 	} 
  911: 	return $currentstring;
  912:       }
  913:       sub end_basefont {
  914: 	my ($target,$token) = @_;
  915: 	my $currentstring = '';
  916: 	if ($target eq 'web') {
  917: 	  $currentstring = $token->[4];     
  918: 	} 
  919: 	return $currentstring;
  920:       }
  921: #-- <font> tag
  922:          sub start_font {
  923: 	    my ($target,$token) = @_;
  924:             my $currentstring = '';
  925:             if ($target eq 'web') {
  926:               $currentstring = $token->[4];     
  927: 	    } 
  928: 	   return $currentstring;
  929: 	}
  930:         sub end_font {
  931: 	    my ($target,$token) = @_;
  932:             my $currentstring = '';
  933:             if ($target eq 'web') {
  934:               $currentstring = $token->[2];    
  935:             } 
  936: 	   return $currentstring;
  937: 	} 
  938: #-- <strike> tag
  939:         sub start_strike {
  940: 	    my ($target,$token) = @_;
  941:             my $currentstring = '';
  942:             if ($target eq 'web') {
  943: 	       $currentstring .= $token->[4];
  944: 	    } elsif ($target eq 'tex') {
  945: 		$currentstring .= "{\\underline ";
  946: 	    } 
  947:            return $currentstring;
  948: 	}
  949:         sub end_strike {
  950: 	    my ($target,$token) = @_;
  951:             my $currentstring = '';
  952:             if ($target eq 'web') {
  953: 	       $currentstring .= $token->[2];
  954: 	    } elsif ($target eq 'tex') {
  955: 	        $currentstring .= " }";
  956:             }
  957:            return $currentstring;
  958: 	}
  959: #-- <s> tag
  960:         sub start_s {
  961: 	    my ($target,$token) = @_;
  962:             my $currentstring = '';
  963:             if ($target eq 'web') {
  964: 	       $currentstring .= $token->[4];
  965: 	    } elsif ($target eq 'tex') {
  966: 		$currentstring .= "{\\underline ";
  967: 	    } 
  968:            return $currentstring;
  969: 	}
  970:         sub end_s {
  971: 	    my ($target,$token) = @_;
  972:             my $currentstring = '';
  973:             if ($target eq 'web') {
  974: 	       $currentstring .= $token->[2];
  975: 	    } elsif ($target eq 'tex') {
  976: 	        $currentstring .= " }";
  977:             }
  978:            return $currentstring;
  979: 	}
  980: #-- <sub> tag
  981:         sub start_sub {
  982: 	    my ($target,$token) = @_;
  983:             my $currentstring = '';
  984:             if ($target eq 'web') {
  985: 	       $currentstring .= $token->[4];
  986: 	    } elsif ($target eq 'tex') {
  987: 		$currentstring .= "\$_{ ";
  988: 	    } 
  989:            return $currentstring;
  990: 	}
  991:         sub end_sub {
  992: 	    my ($target,$token) = @_;
  993:             my $currentstring = '';
  994:             if ($target eq 'web') {
  995: 	       $currentstring .= $token->[2];
  996: 	    } elsif ($target eq 'tex') {
  997: 	        $currentstring .= " }\$";
  998:             }
  999:            return $currentstring;
 1000: 	}
 1001: #-- <sup> tag
 1002:         sub start_sup {
 1003: 	    my ($target,$token) = @_;
 1004:             my $currentstring = '';
 1005:             if ($target eq 'web') {
 1006: 	       $currentstring .= $token->[4];
 1007: 	    } elsif ($target eq 'tex') {
 1008: 		$currentstring .= "\$^{ ";
 1009: 	    } 
 1010:            return $currentstring;
 1011: 	}
 1012:         sub end_sup {
 1013: 	    my ($target,$token) = @_;
 1014:             my $currentstring = '';
 1015:             if ($target eq 'web') {
 1016: 	       $currentstring .= $token->[2];
 1017: 	    } elsif ($target eq 'tex') {
 1018: 	        $currentstring .= " }\$";
 1019:             }
 1020:            return $currentstring;
 1021: 	}
 1022: #-- <hr> tag
 1023:         sub start_hr {
 1024: 	    my ($target,$token) = @_;
 1025:             my $currentstring = '';
 1026:             if ($target eq 'web') {
 1027: 	       $currentstring .= $token->[4];
 1028: 	    } elsif ($target eq 'tex') {
 1029: 		$currentstring .= "\\hline ";
 1030: 	    } 
 1031:            return $currentstring;
 1032: 	}
 1033:         sub end_hr {
 1034: 	    my ($target,$token) = @_;
 1035:             my $currentstring = '';
 1036:             if ($target eq 'web') {
 1037: 	       $currentstring .= $token->[2];
 1038: 	    } elsif ($target eq 'tex') {
 1039: 	    } 
 1040:            return $currentstring;
 1041: 	}
 1042: #-- <a> tag
 1043:         sub start_a {
 1044: 	    my ($target,$token) = @_;
 1045:             my $currentstring = '';
 1046:             if ($target eq 'web') {
 1047: 	       $currentstring .= $token->[4];
 1048: 	    } elsif ($target eq 'tex') {
 1049: 	    }
 1050:            return $currentstring;
 1051: 	}
 1052:         sub end_a {
 1053: 	    my ($target,$token,$tagstack,$stackref) = @_;
 1054:             my $currentstring = '';
 1055:             if ($target eq 'web') {
 1056: 	       $currentstring .= $token->[2];
 1057: 	    } elsif ($target eq 'tex') {
 1058:                 my  $tempor_var = $stackref->[$#$stackref];
 1059: 		if (index($tempor_var,'name') != -1 ) {
 1060: 		    $tempor_var =~ s/name=([^,]*),/$1/g;
 1061: #	        $currentstring .= " \\label{$tempor_var}";
 1062: 	        } elsif (index($tempor_var,'href') != -1 ) {
 1063: 		    $tempor_var =~ s/href=([^,]*),/$1/g;
 1064: 	        $currentstring .= " \\ref{$tempor_var}";
 1065: 	        }
 1066:             }
 1067:            return $currentstring;
 1068: 	}
 1069: #-- <li> tag
 1070:         sub start_li {
 1071: 	    my ($target,$token,$tagstack,$stackref) = @_;
 1072:             my $currentstring = '';
 1073:             if ($target eq 'web') {
 1074:               $currentstring = $token->[4];     
 1075: 	    } elsif ($target eq 'tex') {
 1076:                 my  $tempor_var = $stackref->[$#$stackref];
 1077:                 if (index($tempor_var,'circle') != -1 ) {
 1078: 	          $currentstring .= " \\item[o] ";
 1079: 	        } elsif (index($tempor_var,'square') != -1 ) {
 1080: 	               $currentstring .= " \\item[$\Box$] ";
 1081: 	        } elsif ($tempor_var ne '') { 
 1082: 		       $_ = $tempor_var;
 1083:                        m/my\s*([^=]*)=/;
 1084: 		       $currentstring .= " \\item[$1] ";
 1085: 		} else {
 1086: 		    $currentstring .= " \\item ";
 1087: 	        }  
 1088: 	    } 
 1089: 	   return $currentstring;
 1090: 	}
 1091:         sub end_li {
 1092: 	    my ($target,$token) = @_;
 1093:             my $currentstring = '';
 1094:             if ($target eq 'web') {
 1095:               $currentstring = $token->[2];     
 1096: 	    } 
 1097: 	   return $currentstring;
 1098: 	}
 1099: #-- <u> tag
 1100:         sub start_u {
 1101: 	    my ($target,$token) = @_;
 1102:             my $currentstring = '';
 1103:             if ($target eq 'web') {
 1104: 	       $currentstring .= $token->[4];
 1105: 	    } elsif ($target eq 'tex') {
 1106: 		$currentstring .= "{\\underline ";
 1107: 	    } 
 1108:            return $currentstring;
 1109: 	}
 1110:         sub end_u {
 1111: 	    my ($target,$token) = @_;
 1112:             my $currentstring = '';
 1113:             if ($target eq 'web') {
 1114: 	       $currentstring .= $token->[2];
 1115: 	    } elsif ($target eq 'tex') {
 1116: 	        $currentstring .= " }";
 1117:             }
 1118:            return $currentstring;
 1119: 	}
 1120: #-- <ul> tag
 1121:         sub start_ul {
 1122: 	    my ($target,$token) = @_;
 1123:             my $currentstring = '';
 1124:             if ($target eq 'web') {
 1125:               $currentstring = $token->[4];     
 1126: 	    } elsif ($target eq 'tex') {
 1127:               $currentstring = '\begin{itemize}';  
 1128: 	    } 
 1129: 	   return $currentstring;
 1130: 	}
 1131:         sub end_ul {
 1132: 	    my ($target,$token) = @_;
 1133:             my $currentstring = '';
 1134:             if ($target eq 'web') {
 1135:               $currentstring = $token->[2];     
 1136: 	    } elsif ($target eq 'tex') {
 1137:               $currentstring = '\end{itemize}';  
 1138: 	    } 
 1139: 	   return $currentstring;
 1140: 	}
 1141: #-- <menu> tag
 1142:         sub start_menu {
 1143: 	    my ($target,$token) = @_;
 1144:             my $currentstring = '';
 1145:             if ($target eq 'web') {
 1146:               $currentstring = $token->[4];     
 1147: 	    } elsif ($target eq 'tex') {
 1148:               $currentstring = " \\begin{itemize} ";  
 1149: 	    } 
 1150: 	   return $currentstring;
 1151: 	}
 1152:         sub end_menu {
 1153: 	    my ($target,$token) = @_;
 1154:             my $currentstring = '';
 1155:             if ($target eq 'web') {
 1156:               $currentstring = $token->[2];     
 1157: 	    } elsif ($target eq 'tex') {
 1158:               $currentstring = " \\end{itemize}";  
 1159: 	    } 
 1160: 	   return $currentstring;
 1161: 	}
 1162: #-- <dir> tag
 1163:         sub start_dir {
 1164: 	    my ($target,$token) = @_;
 1165:             my $currentstring = '';
 1166:             if ($target eq 'web') {
 1167:               $currentstring = $token->[4];     
 1168: 	    } elsif ($target eq 'tex') {
 1169:               $currentstring = " \\begin{itemize} ";  
 1170: 	    } 
 1171: 	   return $currentstring;
 1172: 	}
 1173:         sub end_dir {
 1174: 	    my ($target,$token) = @_;
 1175:             my $currentstring = '';
 1176:             if ($target eq 'web') {
 1177:               $currentstring = $token->[2];     
 1178: 	    } elsif ($target eq 'tex') {
 1179:               $currentstring = " \\end{itemize}";  
 1180: 	    } 
 1181: 	   return $currentstring;
 1182: 	}
 1183: #-- <ol> tag
 1184:         sub start_ol {
 1185: 	    my ($target,$token) = @_;
 1186:             my $currentstring = '';
 1187:             if ($target eq 'web') {
 1188:               $currentstring = $token->[4];     
 1189: 	    } elsif ($target eq 'tex') {
 1190:               $currentstring = '\begin{enumerate}';  
 1191: 	    } 
 1192: 	   return $currentstring;
 1193: 	}
 1194:         sub end_ol {
 1195: 	    my ($target,$token) = @_;
 1196:             my $currentstring = '';
 1197:             if ($target eq 'web') {
 1198:               $currentstring = $token->[2];     
 1199: 	    } elsif ($target eq 'tex') {
 1200:               $currentstring = '\end{enumerate}';  
 1201: 	    } 
 1202: 	   return $currentstring;
 1203: 	}
 1204: #-- <dl> tag
 1205:         sub start_dl {
 1206: 	    my ($target,$token) = @_;
 1207:             my $currentstring = '';
 1208:             if ($target eq 'web') {
 1209:               $currentstring = $token->[4];     
 1210: 	    } elsif ($target eq 'tex') {
 1211:               $currentstring = '\begin{description}';  
 1212: 	    } 
 1213: 	   return $currentstring;
 1214: 	}
 1215:         sub end_dl {
 1216: 	    my ($target,$token) = @_;
 1217:             my $currentstring = '';
 1218:             if ($target eq 'web') {
 1219:               $currentstring = $token->[2];     
 1220: 	    } elsif ($target eq 'tex') {
 1221:               $currentstring = '\end{description}';  
 1222: 	    } 
 1223: 	   return $currentstring;
 1224: 	}
 1225: #-- <dt> tag
 1226:         sub start_dt {
 1227: 	    my ($target,$token) = @_;
 1228:             my $currentstring = '';
 1229:             if ($target eq 'web') {
 1230:               $currentstring = $token->[4];     
 1231: 	    } elsif ($target eq 'tex') {
 1232:               $currentstring = '\item[';  
 1233: 	    } 
 1234: 	   return $currentstring;
 1235: 	}
 1236:         sub end_dt {
 1237: 	    my ($target,$token) = @_;
 1238:             my $currentstring = '';
 1239:             if ($target eq 'web') {
 1240:               $currentstring = $token->[2];    
 1241:             } elsif ($target eq 'tex') {
 1242:               $currentstring = ']';  
 1243: 	    } 
 1244: 	   return $currentstring;
 1245: 	}
 1246: #-- <dd> tag
 1247:         sub start_dd {
 1248: 	    my ($target,$token) = @_;
 1249:             my $currentstring = '';
 1250:             if ($target eq 'web') {
 1251:               $currentstring = $token->[4];     
 1252: 	    } 
 1253: 	   return $currentstring;
 1254: 	}
 1255:         sub end_dd {
 1256: 	    my ($target,$token) = @_;
 1257:             my $currentstring = '';
 1258:             if ($target eq 'web') {
 1259:               $currentstring = $token->[2];    
 1260:             } 
 1261: 	   return $currentstring;
 1262: 	}
 1263: #-- <table> tag
 1264:         sub start_table {
 1265: 	    my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
 1266:             my $currentstring = '';
 1267:             if ($target eq 'web') {
 1268:               $currentstring = $token->[4];     
 1269: 	    } elsif ($target eq 'tex') {
 1270: 		my $aa = {};
 1271: 		push @Apache::londefdef::table, $aa; 
 1272: 		$Apache::londefdef::table[-1]{'row_number'} = -1;
 1273: 		$Apache::londefdef::table[-1]{'output'} = '\begin{tabular} ';
 1274: 		my $border = &Apache::lonxml::get_param('border',$parstack,$safeeval);
 1275: 		unless (defined $border) { $border = 0; }
 1276: 		if ($border) { 
 1277: 		    $Apache::londefdef::table[-1]{'hinc'} = '\hline '; 
 1278: 		    $Apache::londefdef::table[-1]{'vinc'} = '&'; 
 1279: 		    $Apache::londefdef::table[-1]{'vvinc'} = '|';
 1280: 		} else {
 1281: 		    $Apache::londefdef::table[-1]{'hinc'} = ''; 
 1282: 		    $Apache::londefdef::table[-1]{'vinc'} = ''; 
 1283: 		    $Apache::londefdef::table[-1]{'vvinc'} = '';
 1284: 		}
 1285: 	    } 
 1286: 	   return $currentstring;
 1287: 	}
 1288:         sub end_table {
 1289: 	    my ($target,$token) = @_;
 1290:             my $currentstring = '';
 1291:             if ($target eq 'web') {
 1292:               $currentstring = $token->[2];     
 1293: 	    } elsif ($target eq 'tex') {
 1294: 		my $inmemory = '';
 1295: 		my $output = '';
 1296: 		my $header_of_table = '{'.$Apache::londefdef::table[-1]{'vvinc'};
 1297: 		my $in;
 1298: 		for ($in=0;$in<=$Apache::londefdef::table[-1]{'counter_columns'};$in++) {
 1299: 		    $header_of_table .= $Apache::londefdef::table[-1]{'columns'}[$in].$Apache::londefdef::table[-1]{'vvinc'};
 1300: 		}
 1301: 		$header_of_table .= '}';
 1302: 		for ($in=0;$in<=$Apache::londefdef::table[-1]{'row_number'};$in++) {
 1303: 		    $output .=  $Apache::londefdef::table[-1]{'rowdata'}[$in];
 1304: 		    chop $output;
 1305: 		    $output .= ' \\\\ ';
 1306: 		}
 1307: 		$Apache::londefdef::table[-1]{'output'} .= $header_of_table.$output.$Apache::londefdef::table[-1]{'hinc'}.'\end{tabular}';
 1308: 		if ($#Apache::londefdef::table > 0) {
 1309: 		    $inmemory = $Apache::londefdef::table[-1]{'output'};
 1310: 		    pop @Apache::londefdef::table;
 1311: 		    $Apache::londefdef::table[-1]{'rowdata'}[$Apache::londefdef::table[-1]{'row_number'}] .= $inmemory;
 1312: 		} else {
 1313: 		    $currentstring = $Apache::londefdef::table[-1]{'output'};
 1314: 		    $currentstring =~ s/\\\\\s+\\\\/\\\\/g; 
 1315: 		    pop @Apache::londefdef::table;
 1316: 		}
 1317: 	    }
 1318: 	   return $currentstring;
 1319: 	}
 1320: #-- <tr> tag
 1321:         sub start_tr {
 1322: 	    my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
 1323:             my $currentstring = '';
 1324:             if ($target eq 'web') {
 1325:               $currentstring = $token->[4];     
 1326: 	    } elsif ($target eq 'tex') {
 1327: 		$Apache::londefdef::table[-1]{'row_number'}++;
 1328: 		my $alignchar = substr(&Apache::lonxml::get_param('align',$parstack,$safeeval),0,1);
 1329: 		if ($alignchar ne '') {
 1330: 		    push @ {$Apache::londefdef::table[-1]{'rows'} }, $alignchar;
 1331: 		} else {
 1332: 		    push @ {$Apache::londefdef::table[-1]{'rows'} }, 'c';
 1333: 		}
 1334: 		push ( @{ $Apache::londefdef::table[-1]{'rowdata'} }, $Apache::londefdef::table[-1]{'hinc'});
 1335: 		$Apache::londefdef::table[-1]{'counter_columns'} = -1;
 1336: 
 1337: 	    } 
 1338: 	   return $currentstring;
 1339: 	}        
 1340:         sub end_tr {
 1341: 	    my ($target,$token) = @_;
 1342:             my $currentstring = '';
 1343:             if ($target eq 'web') {
 1344: 		$currentstring = $token->[2];     
 1345: 	    } elsif ($target eq 'tex') {
 1346: #		$currentstring .= ' START ROW '. $Apache::londefdef::table[-1]{'rowdata'}[$Apache::londefdef::table[-1]{'row_number'}].' END ROW ';
 1347: 	    }
 1348: 	   return $currentstring;
 1349: 	}
 1350: #-- <td> tag
 1351:         sub start_td {
 1352: 	    my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
 1353:             my $currentstring = '';
 1354:             if ($target eq 'web') {
 1355:               $currentstring = $token->[4];     
 1356: 	    } elsif ($target eq 'tex') {
 1357: 		my $what_to_push = substr(&Apache::lonxml::get_param('align',$parstack,$safeeval),0,1);
 1358: 		if ($what_to_push eq '') {
 1359: 		    $what_to_push = substr($Apache::londefdef::table[-1]{'rows'}[0],0,1);;
 1360: 		}
 1361: 		    push @{ $Apache::londefdef::table[-1]{'columns'} }, $what_to_push;
 1362: 		$Apache::londefdef::table[-1]{'counter_columns'}++;
 1363: 		&Apache::lonxml::startredirection();
 1364: ;
 1365: 	    } 
 1366: 	   return $currentstring;
 1367: 	}        
 1368:         sub end_td {
 1369: 	    my ($target,$token) = @_;
 1370:             my $currentstring = '';
 1371:             if ($target eq 'web') {
 1372: 		$currentstring = $token->[2];     
 1373: 	    } elsif ($target eq 'tex') {
 1374: 		my $current_row = $Apache::londefdef::table[-1]{'row_number'};
 1375: 		my $data=&Apache::lonxml::endredirection();
 1376: 		@{ $Apache::londefdef::table[-1]{'rowdata'} }[$current_row] .= $data.' '.$Apache::londefdef::table[-1]{'vinc'};
 1377: 	    }
 1378: 	   return $currentstring;
 1379: 	}
 1380: #-- <img> tag
 1381:         sub start_img {
 1382: 	    my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
 1383:             $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=
 1384:                                         $token->[2]->{'src'};
 1385:             my $currentstring = '';
 1386: 
 1387: 	    if ($target eq 'web') {
 1388:               $currentstring = $token->[4];     
 1389: 	    } elsif ($target eq 'tex') {
 1390: 	      my $src = &Apache::lonxml::get_param('src',$parstack,$safeeval);
 1391: 	      $src=&Apache::lonnet::filelocation($Apache::lonxml::pwd[-1],$src);
 1392: 	      my $file;
 1393: 	      my $path;	
 1394:               if ($src =~ m!(.*)/([^/]*)$!) {
 1395: 		  $file = $2;
 1396: 		  $path = $1; 
 1397: 	      } else {
 1398: 		  $path = $Apache::lonxml::pwd[-1];
 1399: 		  $file = $src;
 1400: 	      }
 1401: 	      $file=~s/(\.gif|\.jpg)$/\.eps/;
 1402: 	      if ($path) {
 1403: 		$currentstring .= '\graphicspath{{'.$path.'/}}\fbox{\includegraphics{'.$file.'}}';
 1404: 	      } else {
 1405: 		$currentstring .= 'See the image at \tt{'.$src.'}';
 1406: 	      }
 1407: 	    }
 1408: 	    return $currentstring;
 1409: 	}
 1410:         sub end_img {
 1411: 	    my ($target,$token) = @_;
 1412:             my $currentstring = '';
 1413:             if ($target eq 'web') {
 1414:               $currentstring = $token->[2];
 1415: 	    } elsif ($target eq 'tex') {
 1416:               $currentstring = '';
 1417: 	    }
 1418: 	   return $currentstring;
 1419: 	}
 1420: #-- <applet> tag
 1421: 
 1422:         sub start_applet {
 1423: 	    my ($target,$token) = @_;
 1424:               $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=   
 1425:                                         $token->[2]->{'code'};
 1426:               $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=
 1427:                                         $token->[2]->{'archive'};
 1428:             my $currentstring = '';
 1429:             if ($target eq 'web') {
 1430:               $currentstring = $token->[4];
 1431: 	    } elsif ($target eq 'tex') {
 1432:               $currentstring = " \\begin{figure} ";
 1433: 	    } 
 1434: 	   return $currentstring;
 1435: 	}
 1436: sub end_applet {
 1437:     my ($target,$token) = @_;
 1438:     my $currentstring = '';
 1439:     if ($target eq 'web') {
 1440: 	$currentstring = $token->[2];
 1441:     } elsif ($target eq 'tex') {
 1442: 	$currentstring = " \\end{figure}";
 1443:     } 
 1444:     return $currentstring;
 1445: }
 1446: 
 1447: #-- <embed> tag
 1448: 
 1449: sub start_embed {    
 1450:     my ($target,$token) = @_;
 1451:     $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=
 1452: 	$token->[2]->{'src'};
 1453:     my $currentstring = '';
 1454:     if ($target eq 'web') {
 1455: 	$currentstring = $token->[4];
 1456:     } elsif ($target eq 'tex') {
 1457: 	$currentstring = " \\begin{figure} ";  
 1458:     } 
 1459:     return $currentstring;
 1460: }
 1461:         sub end_embed {
 1462: 	    my ($target,$token) = @_;
 1463:             my $currentstring = '';
 1464:             if ($target eq 'web') {
 1465:               $currentstring = $token->[2];     
 1466: 	    } elsif ($target eq 'tex') {
 1467:               $currentstring = " \\end{figure}";  
 1468: 	    } 
 1469: 	   return $currentstring;
 1470: 	}
 1471: 
 1472: #-- <param> tag
 1473: 
 1474:         sub start_param {
 1475: 	    my ($target,$token) = @_;
 1476: 	    if ($token->[2]->{'name'} eq 'cabbase') {
 1477:                       $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=
 1478: 					     $token->[2]->{'value'};
 1479:             }   
 1480:             $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=   
 1481:                                         $token->[2]->{'src'};
 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_param {
 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: #-- <allow> tag
 1502: 
 1503:         sub start_allow {
 1504: 	    my ($target,$token) = @_;
 1505: 
 1506:             $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=   
 1507:                                         $token->[2]->{'src'};
 1508: 
 1509: 	   return '';
 1510: 	}
 1511:         sub end_allow {
 1512: 	   return '';
 1513: 	}
 1514: #-- Frames
 1515: 	sub start_frameset {
 1516: 	  my ($target,$token) = @_;
 1517: 	  my $currentstring = '';
 1518: 	  if ($target eq 'web') { 
 1519: 	    if (!$Apache::lonxml::registered) {
 1520: 	      $currentstring.='<head>'.
 1521: 		  &Apache::lonxml::registerurl(undef,$target).'</head>';
 1522: 	    }
 1523: 	    $currentstring .= $token->[4];
 1524: 	  }
 1525: 	  return $currentstring;
 1526: 	}
 1527:         sub end_frameset {
 1528: 	  my ($target,$token) = @_;
 1529: 	  my $currentstring = '';
 1530: 	  if ($target eq 'web') {
 1531: 	    $currentstring = $token->[2];
 1532: 	  }
 1533: 	  return $currentstring;
 1534: 	}
 1535: #-- <pre>
 1536: 	sub start_pre {
 1537: 	    my ($target,$token) = @_;
 1538:             my $currentstring = '';
 1539:             if ($target eq 'web') {
 1540: 	       $currentstring .= $token->[4];
 1541: 	    } elsif ($target eq 'tex') {
 1542: 		$currentstring .= '\begin{verbatim}';
 1543: 	    } 
 1544:            return $currentstring;
 1545: 	}
 1546:         sub end_pre {
 1547: 	    my ($target,$token) = @_;
 1548:             my $currentstring = '';
 1549:             if ($target eq 'web') {
 1550: 	       $currentstring .= $token->[2];
 1551: 	    } elsif ($target eq 'tex') {
 1552: 		$currentstring .= '\end{verbatim}';
 1553: 	    }
 1554:            return $currentstring;
 1555: 	}
 1556: #-- <insert>
 1557: 	sub start_insert {
 1558: 	    my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
 1559:             my $currentstring = '';
 1560:             if ($target eq 'web') {
 1561: 		my $display = &Apache::lonxml::get_param('display',$parstack,$safeeval);
 1562: 	       $currentstring .= '<b>'.$display.'</b>';;
 1563: 	    }
 1564:            return $currentstring;
 1565: 	}
 1566:         sub end_insert {
 1567: 	    my ($target,$token) = @_;
 1568:             my $currentstring = '';
 1569:             if ($target eq 'web') {
 1570: 	       $currentstring .= '';
 1571: 	    }
 1572:            return $currentstring;
 1573: 	}
 1574: #-- <externallink>
 1575: 	sub start_externallink {
 1576: 	    my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
 1577:             my $currentstring = '';
 1578:             if ($target eq 'web') {
 1579: 		my $display = &Apache::lonxml::get_param('display',$parstack,$safeeval);
 1580: 	       $currentstring .= '<b>'.$display.'</b>';;
 1581: 	    }
 1582:            return $currentstring;
 1583: 	}
 1584:         sub end_externallink {
 1585: 	    my ($target,$token) = @_;
 1586:             my $currentstring = '';
 1587:             if ($target eq 'web') {
 1588: 	       $currentstring .= '';
 1589: 	    }
 1590:            return $currentstring;
 1591: 	}
 1592: 1;
 1593: __END__

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