File:  [LON-CAPA] / loncom / xml / londefdef.pm
Revision 1.51: download - view: text, annotated - select for diffs
Fri Apr 5 18:11:11 2002 UTC (22 years, 1 month ago) by sakharuk
Branches: MAIN
CVS tags: HEAD
Guy I've taken your remarks into account. I have not finished yet - CLOSPAN,ROWSPAN

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

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