Annotation of loncom/xml/londefdef.pm, revision 1.73

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

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