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

1.1       sakharuk    1: # The LearningOnline Network with CAPA
                      2: # Tags Default Definition Module 
                      3: #
1.124   ! sakharuk    4: # $Id: londefdef.pm,v 1.123 2003/03/19 16:50:14 www 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.118     www        47: use Apache::lonnet();
1.1       sakharuk   48: use strict;
1.124   ! sakharuk   49: use Apache::lonxml;
1.57      sakharuk   50: use Apache::File();
1.70      sakharuk   51: use Image::Magick;
1.118     www        52: use Apache::lonmenu();
                     53: use Apache::lonmeta();
1.54      sakharuk   54: 
1.38      harris41   55: BEGIN {
1.15      sakharuk   56: 
1.121     www        57:     &Apache::lonxml::register('Apache::londefdef',('a','abbr','acronym','accessrule','address','allow','applet','area','b','base','basefont','bgo','bgsound','big','blink','blockquote','blankspace','body','br','button','caption','center','cite','code','col','colgroup','dd','del','dfn','dir','div','dl','dt','em','embed','externallink','fieldset','font','form','frame','frameset','h1','h2','h3','h4','h5','h6','head','hr','html','i','iframe','img','input','ins','insert','isindex','kbd','keygen','label','layer','legend','li','link','m','map','marquee','menu','meta','multicol','nobr','noembed','noframes','nolayer','noscript','object','ol','optgroup','option','output','p','param','pre','q','s','samp','select','server','small','spacer','span','strike','strong','sub','sup','table','tbody','td','textarea','tfoot','th','thead','title','tr','tt','tthoption','u','ul','var','wbr'));
1.15      sakharuk   58: 
1.3       sakharuk   59: }
1.1       sakharuk   60: 
1.35      sakharuk   61: #======================= TAG SUBROUTINES =====================
1.8       sakharuk   62: #-- <output>
1.21      albertel   63: sub start_output {
1.122     albertel   64:     my ($target) = @_;
                     65:     if ($target eq 'meta') { $Apache::lonxml::metamode--; }
                     66:     return '';
1.21      albertel   67: }
                     68: sub end_output {
1.122     albertel   69:     my ($target) = @_;
                     70:     if ($target eq 'meta') { $Apache::lonxml::metamode++; }
                     71:     return '';
1.21      albertel   72: }
1.4       sakharuk   73: #-- <m> tag
1.33      albertel   74: sub start_m {
1.122     albertel   75:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
                     76:     my $currentstring = '';
                     77:     if ($target eq 'web') {
                     78: 	$Apache::lonxml::prevent_entity_encode++;
                     79: 	my $inside = &Apache::lonxml::get_all_text_unbalanced("/m",$parser);
                     80: 	$inside ='\\documentstyle{article}'.$inside;
                     81: 	&Apache::lonxml::debug("M is starting with:$inside:");
                     82: 	my $eval=&Apache::lonxml::get_param('eval',$parstack,$safeeval);
                     83: 	if ($eval eq 'on') {
                     84: 	    $inside=&Apache::run::evaluate($inside,$safeeval,$$parstack[-1]);
                     85: 	    #&Apache::lonxml::debug("M is evaulated to:$inside:");
                     86: 	}
                     87: 	$currentstring = &Apache::lontexconvert::converted(\$inside);
                     88: 	if ($Apache::lontexconvert::errorstring) {
                     89: 	    &Apache::lonxml::warning("tth error: ".
                     90: 				     $Apache::lontexconvert::errorstring);
                     91: 	    $Apache::lontexconvert::errorstring='';
                     92: 	}
                     93: 	#&Apache::lonxml::debug("M is ends with:$currentstring:");
                     94:     } elsif ($target eq 'tex') {
                     95: 	$currentstring = &Apache::lonxml::get_all_text_unbalanced("/m",$parser);
                     96: 	if ($currentstring=~/^(\s*\\\\\s*)*$/) {$currentstring = ' \vskip 0 mm ';}
                     97:     } else {
                     98: 	my $inside = &Apache::lonxml::get_all_text_unbalanced("/m",$parser);
                     99:     }
                    100:     return $currentstring;
1.33      albertel  101: }
1.122     albertel  102: 
1.33      albertel  103: sub end_m {
1.122     albertel  104:     my ($target,$token) = @_;
                    105:     my $currentstring = '';
                    106:     if ($target eq 'web') {
                    107: 	$Apache::lonxml::prevent_entity_encode--;
                    108:     } elsif ($target eq 'tex') {
                    109: 	$currentstring = "";
                    110:     } elsif ($target eq 'meta') {
                    111:     }
                    112:     return $currentstring;
1.33      albertel  113: }
1.110     albertel  114: 
                    115: sub start_tthoption {
1.122     albertel  116:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
                    117:     my $result;
                    118:     if ($target eq 'web') {
                    119: 	my $inside = &Apache::lonxml::get_all_text("/tthoption",$parser);
                    120: 	$inside=~s/^\s*//;
                    121: 	if ($ENV{'browser.mathml'}) {
                    122: 	    &tth::ttmoptions($inside);
                    123: 	} else {
                    124: 	    &tth::tthoptions($inside);
                    125: 	}
                    126:     }
                    127:     return $result;
1.110     albertel  128: }
                    129: 
                    130: sub end_tthoption {
1.122     albertel  131:     my ($target,$token) = @_;
                    132:     my $result;
                    133:     return $result;
1.110     albertel  134: }
                    135: 
1.35      sakharuk  136: #-- <html> tag    
1.100     albertel  137: sub start_html {
                    138:     my ($target,$token) = @_;
                    139:     my $currentstring = '';
                    140:     if ($ENV{'browser.mathml'}) {
                    141: 	&tth::ttminit();
                    142: 	if ($ENV{'browser.unicode'}) {
                    143: 	    &tth::ttmoptions('-L -u1');
                    144: 	} else {
                    145: 	    &tth::ttmoptions('-L -u0');
                    146: 	}
                    147:     } else {
                    148: 	&tth::tthinit();
                    149: 	if ($ENV{'browser.unicode'}) {
                    150: 	    &tth::tthoptions('-L -u1');
                    151: 	} else {
                    152: 	    &tth::tthoptions('-L -u0');
                    153: 	}
                    154:     }
                    155:     if ($target eq 'web') {
                    156: 	$currentstring = &Apache::lonxml::xmlbegin().
                    157: 	    &Apache::lonxml::fontsettings();     
                    158:     } elsif ($target eq 'tex') {
                    159: 	@Apache::londefdef::table = ();
                    160: 	$currentstring .= '\documentclass[letterpaper]{article}
1.114     sakharuk  161:                            \newcommand{\keephidden}[1]{}
                    162:                            \renewcommand{\deg}{$^{\circ}$}
                    163:                            \usepackage{textcomp}
                    164:                            \usepackage[dvips]{graphicx}
                    165:                            \usepackage{epsfig}\usepackage{calc}
                    166: \newenvironment{choicelist}{\begin{list}{}{\setlength{\rightmargin}{0in}\setlength{\leftmargin}{0.13in}\setlength{\topsep}{0.05in}\setlength{\itemsep}{0.022in}\setlength{\parsep}{0in}\setlength{\belowdisplayskip}{0.04in}\setlength{\abovedisplayskip}{0.05in}\setlength{\abovedisplayshortskip}{-0.04in}\setlength{\belowdisplayshortskip}{0.04in}}}{\end{list}}';
1.100     albertel  167:     }
                    168:     return $currentstring;
                    169: }
1.122     albertel  170: 
                    171: sub end_html {
                    172:     my ($target,$token) = @_;
                    173:     my $currentstring = '';
                    174:     if ($target eq 'web') {
                    175: 	$currentstring = &Apache::lonxml::xmlend();
                    176:     }
                    177:     return $currentstring;
                    178: }
                    179: 
1.35      sakharuk  180: #-- <head> tag
1.122     albertel  181: sub start_head {
                    182:     my ($target,$token) = @_;
                    183:     my $currentstring = '';
                    184:     if ($target eq 'web') {
                    185: 	$currentstring = $token->[4];     
                    186:     } 
                    187:     return $currentstring;
                    188: }
                    189: 
                    190: sub end_head {
                    191:     my ($target,$token) = @_;
                    192:     my $currentstring = '';
                    193:     if ($target eq 'web') {
                    194: 	$currentstring = &Apache::lonmenu::registerurl(undef,$target).
                    195: 	    $token->[2];    
                    196:     } 
                    197:     return $currentstring;
                    198: }
                    199: 
1.35      sakharuk  200: #-- <map> tag
1.122     albertel  201: sub start_map {
                    202:     my ($target,$token) = @_;
                    203:     my $currentstring = '';
                    204:     if ($target eq 'web') {
                    205: 	$currentstring = $token->[4];     
                    206:     } 
                    207:     return $currentstring;
                    208: }
                    209: 
                    210: sub end_map {
                    211:     my ($target,$token) = @_;
                    212:     my $currentstring = '';
                    213:     if ($target eq 'web') {
                    214: 	$currentstring = $token->[2];    
                    215:     } 
                    216:     return $currentstring;
                    217: }
                    218: 
1.35      sakharuk  219: #-- <select> tag
1.122     albertel  220: sub start_select {
                    221:     my ($target,$token) = @_;
                    222:     my $currentstring = '';
                    223:     if ($target eq 'web') {
                    224: 	$currentstring = $token->[4];     
                    225:     } 
                    226:     return $currentstring;
                    227: }
                    228: 
                    229: sub end_select {
                    230:     my ($target,$token) = @_;
                    231:     my $currentstring = '';
                    232:     if ($target eq 'web') {
                    233: 	$currentstring = $token->[2];    
                    234:     } 
                    235:     return $currentstring;
                    236: }
                    237: 
1.35      sakharuk  238: #-- <option> tag
1.122     albertel  239: sub start_option {
                    240:     my ($target,$token) = @_;
                    241:     my $currentstring = '';
                    242:     if ($target eq 'web') {
                    243: 	$currentstring = $token->[4];     
                    244:     } 
                    245:     return $currentstring;
                    246: }
                    247: 
                    248: sub end_option {
                    249:     my ($target,$token) = @_;
                    250:     my $currentstring = '';
                    251:     if ($target eq 'web') {
                    252: 	$currentstring = $token->[2];    
                    253:     } 
                    254:     return $currentstring;
                    255: }
                    256: 
1.35      sakharuk  257: #-- <input> tag
1.122     albertel  258: sub start_input {
                    259:     my ($target,$token) = @_;
                    260:     my $currentstring = '';
                    261:     if ($target eq 'web') {
                    262: 	$currentstring = $token->[4];     
                    263:     } 
                    264:     return $currentstring;
                    265: }
                    266: 
                    267: sub end_input {
                    268:     my ($target,$token) = @_;
                    269:     my $currentstring = '';
                    270:     if ($target eq 'web') {
                    271: 	$currentstring = $token->[2];    
                    272:     } 
                    273:     return $currentstring;
                    274: }
                    275: 
1.35      sakharuk  276: #-- <textarea> tag
1.122     albertel  277: sub start_textarea {
                    278:     my ($target,$token) = @_;
                    279:     my $currentstring = '';
                    280:     if ($target eq 'web') {
                    281: 	$currentstring = $token->[4];     
                    282:     } 
                    283:     return $currentstring;
                    284: }
                    285: 
                    286: sub end_textarea {
                    287:     my ($target,$token) = @_;
                    288:     my $currentstring = '';
                    289:     if ($target eq 'web') {
                    290: 	$currentstring = $token->[2];    
                    291:     } 
                    292:     return $currentstring;
                    293: }
                    294: 
1.35      sakharuk  295: #-- <form> tag
1.122     albertel  296: sub start_form {
                    297:     my ($target,$token) = @_;
                    298:     my $currentstring = '';
                    299:     if ($target eq 'web') {
                    300: 	$currentstring = $token->[4];     
                    301:     } 
                    302:     return $currentstring;
                    303: }
                    304: 
                    305: sub end_form {
                    306:     my ($target,$token) = @_;
                    307:     my $currentstring = '';
                    308:     if ($target eq 'web') {
                    309: 	$currentstring = $token->[2];    
                    310:     } 
                    311:     return $currentstring;
                    312: }
                    313: 
1.35      sakharuk  314: #-- <title> tag
1.122     albertel  315: sub start_title {
                    316:     my ($target,$token) = @_;
                    317:     my $currentstring = '';
                    318:     if ($target eq 'web') {
                    319: 	$currentstring = $token->[4];     
                    320:     } elsif ($target eq 'tex') {
                    321: 	$currentstring .= '\keephidden{' 
                    322:     }
                    323:     if ($target eq 'meta') {
                    324: 	$currentstring='<title>';
                    325: 	&start_output();
                    326:     }
                    327:     return $currentstring;
                    328: }
                    329: 
                    330: sub end_title {
                    331:     my ($target,$token) = @_;
                    332:     my $currentstring = '';
                    333:     if ($target eq 'web') {
                    334: 	$currentstring = $token->[2];    
                    335:     } elsif ($target eq 'tex') {
                    336: 	$currentstring .= '}';
                    337:     }  
                    338:     if ($target eq 'meta') {
                    339: 	&end_output();
                    340: 	$currentstring='</title>';
                    341:     } 
                    342:     return $currentstring;
                    343: }
                    344: 
                    345: #-- <meta> tag
                    346: sub start_meta {
                    347:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
                    348:     my $currentstring = '';
                    349:     if ($target eq 'web') {
                    350: 	my $args='';
                    351: 	if ( $#$parstack > -1 ) { $args=$$parstack[$#$parstack]; }
                    352: 	if ($args eq '') {
                    353: 	    &Apache::lonxml::get_all_text("/meta",$parser);
                    354: 	} else {
                    355: 	    $currentstring = $token->[4];
1.1       sakharuk  356: 	}
1.122     albertel  357:     }
                    358:     if ($target eq 'meta') {
                    359: 	unless (&Apache::lonxml::get_param
                    360: 		('http-equiv',$parstack,$safeeval,undef,1)) {
                    361: 	    my $name=$token->[2]->{'name'};
                    362: 	    $name=~tr/A-Z/a-z/;
                    363: 	    $name=~s/\s/\_/gs;
                    364: 	    $name=~s/\W//gs;
                    365: 	    if ($name) {
                    366: 		$currentstring='<'.$name.'>'.
                    367: 		    &Apache::lonxml::get_param
                    368: 			('content',$parstack,$safeeval,undef,1).
                    369: 			    '</'.$name.'>';
1.1       sakharuk  370: 	    }
                    371: 	}
1.122     albertel  372:     }
                    373:     return $currentstring;
                    374: }
                    375: 
                    376: sub end_meta {
                    377:     my ($target,$token,$tagstack,$parstack,$parser) = @_;
                    378:     my $currentstring = '';
                    379:     if ($target eq 'web') {
                    380: 	my $args='';
                    381: 	if ( $#$parstack > -1 ) { $args=$$parstack[$#$parstack]; }
                    382: 	if ($args ne '') {
1.121     www       383: 	    $currentstring = $token->[4];
1.122     albertel  384: 	}
                    385:     } 
                    386:     return $currentstring;
                    387: }
                    388: 
1.121     www       389: # accessrule
1.122     albertel  390: sub start_accessrule {
                    391:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
                    392:     my $currentstring = '';
                    393:     my $eff=&Apache::lonxml::get_param
                    394: 	('effect',$parstack,$safeeval,undef,1);
                    395:     my $realm=&Apache::lonxml::get_param
                    396: 	('realm',$parstack,$safeeval,undef,1);
1.123     www       397:     my $role=&Apache::lonxml::get_param
                    398: 	('role',$parstack,$safeeval,undef,1);
                    399:     $realm=~s/\s+//g;
                    400:     $realm=~s/\//\_/g;
                    401:     $realm=~s/^\_//;
                    402:     $realm=~s/\W/\;/g;
                    403:     $role=~s/\s+//g;
                    404:     $role=~s/\//\_/g;
                    405:     $role=~s/\W/\;/g;
1.122     albertel  406:     if ($target eq 'web') {
                    407: 	my $args='';
                    408: 	if ( $#$parstack > -1 ) { $args=$$parstack[$#$parstack]; }
                    409: 	if ($args eq '') {
                    410: 	    &Apache::lonxml::get_all_text("/accessrule",$parser);
                    411: 	} else {
                    412: 	    $currentstring = $token->[4];
                    413: 	}
                    414:     }
                    415:     if ($target eq 'meta') {
1.123     www       416: 	$currentstring='<rule>'.$eff.':'.$realm.':'.$role.'</rule>';
1.122     albertel  417:     }
                    418:     return $currentstring;
                    419: }
                    420: 
                    421: sub end_accessrule {
                    422:     my ($target,$token,$tagstack,$parstack,$parser) = @_;
                    423:     my $currentstring = '';
                    424:     if ($target eq 'web') {
                    425: 	my $args='';
                    426: 	if ( $#$parstack > -1 ) { $args=$$parstack[$#$parstack]; }
                    427: 	if ($args ne '') {
                    428: 	    $currentstring = $token->[4];
                    429: 	}
                    430:     } 
                    431:     return $currentstring;
                    432: }
                    433: 
                    434: #-- <body> tag
                    435: sub start_body {
                    436:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
                    437:     my $currentstring = '';
                    438:     if ($target eq 'web') {
                    439: 	if (!$Apache::lonxml::registered) {
                    440: 	    $currentstring.='<head>'.
                    441: 		&Apache::lonmenu::registerurl(undef,$target).'</head>';
                    442: 	}
                    443: 	my $onLoad='';
                    444: 	foreach my $key (keys(%{$token->[2]})) {
                    445: 	    if ($key =~ /^onload$/i) {
                    446: 		$onLoad.=$token->[2]->{$key}.';';
                    447: 		delete($token->[2]->{$key});
1.121     www       448: 	    }
1.122     albertel  449: 	}
                    450: 	$token->[2]->{'onload'}=&Apache::lonmenu::loadevents().';'.$onLoad;
                    451: 	my $onUnload='';
                    452: 	foreach my $key (keys(%{$token->[2]})) {
                    453: 	    if ($key =~ /^onunload$/i) {
                    454: 		$onUnload.=$token->[2]->{$key}.';';
                    455: 		delete($token->[2]->{$key});
1.121     www       456: 	    }
                    457: 	}
1.122     albertel  458: 	$token->[2]->{'onunload'}=&Apache::lonmenu::unloadevents().
                    459: 	    ';'.$onUnload;
                    460: 	
                    461: 	$currentstring .= '<'.$token->[1];
                    462: 	foreach (keys %{$token->[2]}) {
                    463: 	    $currentstring.=' '.$_.'="'.$token->[2]->{$_}.'"';
                    464: 	}
                    465: 	$currentstring.='>';
                    466: 	if ($ENV{'request.state'} ne 'published') {
                    467: 	    $currentstring.=(<<EDITBUTTON);
1.40      albertel  468: 		<form method="post">
1.49      albertel  469: 		<input type="submit" name="editmode" value="Edit" />
1.40      albertel  470: 		</form>
                    471: EDITBUTTON
1.122     albertel  472: 	} else {
                    473: 	    $currentstring.=&Apache::lonmenu::menubuttons(undef,$target,1);
1.1       sakharuk  474: 	}
1.122     albertel  475:     } elsif ($target eq 'tex') {
                    476: 	$currentstring = '\begin{document}';  
                    477:     } 
                    478:     return $currentstring;
                    479: }
                    480: 
                    481: sub end_body {
                    482:     my ($target,$token) = @_;
                    483:     my $currentstring = '';
                    484:     if ($target eq 'web') {
                    485: 	$currentstring = $token->[2];     
                    486:     } elsif ($target eq 'tex') {
                    487: 	$currentstring = '\end{document}';  
                    488:     } 
                    489:     return $currentstring;
                    490: }
                    491: 
1.35      sakharuk  492: #-- <center> tag
1.122     albertel  493: sub start_center {
                    494:     my ($target,$token) = @_;
                    495:     my $currentstring = '';
                    496:     if ($target eq 'web') {
                    497: 	$currentstring = $token->[4];     
                    498:     } elsif ($target eq 'tex') {
                    499: 	$currentstring = '\begin{center}';  
                    500:     }  elsif ($target eq 'latexsource') {
                    501: 	$currentstring = '\begin{center}';  
                    502:     } 
                    503:     return $currentstring;
                    504: }
                    505: 
                    506: sub end_center {
                    507:     my ($target,$token) = @_;
                    508:     my $currentstring = '';
                    509:     if ($target eq 'web') {
                    510: 	$currentstring = $token->[2];     
                    511:     } elsif ($target eq 'tex') {
                    512: 	$currentstring = '\end{center}';  
                    513:     }  elsif ($target eq 'latexsource') {
                    514: 	$currentstring = '\end{center}';  
                    515:     } 
                    516:     return $currentstring;
                    517: }
                    518: 
1.35      sakharuk  519: #-- <b> tag
1.122     albertel  520: sub start_b {
                    521:     my ($target,$token) = @_;
                    522:     my $currentstring = '';
                    523:     if ($target eq 'web') {
                    524: 	$currentstring = $token->[4];     
                    525:     } elsif ($target eq 'tex') {
                    526: 	$currentstring = '\textbf{';  
                    527:     }  elsif ($target eq 'latexsource') {
                    528: 	$currentstring = '\textbf{';  
                    529:     } 
                    530:     return $currentstring;
                    531: }
                    532: 
                    533: sub end_b {
                    534:     my ($target,$token) = @_;
                    535:     my $currentstring = '';
                    536:     if ($target eq 'web') {
                    537: 	$currentstring = $token->[2];     
                    538:     } elsif ($target eq 'tex') {
                    539: 	$currentstring = '}';  
                    540:     } elsif ($target eq 'latexsource') {
                    541: 	$currentstring = '}';  
                    542:     } 
                    543:     return $currentstring;
                    544: }
1.35      sakharuk  545: 
                    546: #-- <strong> tag
1.122     albertel  547: sub start_strong {
                    548:     my ($target,$token) = @_;
                    549:     my $currentstring = '';
                    550:     if ($target eq 'web') {
                    551: 	$currentstring = $token->[4];     
                    552:     } elsif ($target eq 'tex') {
                    553: 	$currentstring = '\textbf{';  
                    554:     } elsif ($target eq 'latexsource') {
                    555: 	$currentstring = '\textbf{';  
                    556:     } 
                    557:     return $currentstring;
                    558: }
                    559: 
                    560: sub end_strong {
                    561:     my ($target,$token) = @_;
                    562:     my $currentstring = '';
                    563:     if ($target eq 'web') {
                    564: 	
                    565: 	$currentstring = $token->[2];     
                    566:     } elsif ($target eq 'tex') {
                    567: 	$currentstring = '}';  
                    568:     }  elsif ($target eq 'latexsource') {
                    569: 	$currentstring = '}';  
                    570:     } 
                    571:     return $currentstring;
                    572: }
                    573: 
1.35      sakharuk  574: #-- <h1> tag
1.122     albertel  575: sub start_h1 {
                    576:     my ($target,$token) = @_;
                    577:     my $currentstring = '';
                    578:     if ($target eq 'web') {
                    579: 	$currentstring .= $token->[4];
                    580:     } elsif ($target eq 'tex') {
                    581: 	$currentstring .= '{\large \textbf{';
                    582:     } elsif ($target eq 'meta') {
                    583: 	$currentstring='<subject>';
                    584: 	&start_output();
                    585:     }
                    586:     return $currentstring;
                    587: }
                    588: 
                    589: sub end_h1 {
                    590:     my ($target,$token) = @_;
                    591:     my $currentstring = '';
                    592:     if ($target eq 'web') {
                    593: 	$currentstring .= $token->[2];
                    594:     } elsif ($target eq 'tex') {
                    595: 	$currentstring .= '}}';
                    596:     } elsif ($target eq 'meta') {
                    597: 	&end_output();
                    598: 	$currentstring='</subject>';
                    599:     } 
                    600:     return $currentstring;
                    601: }
                    602: 
1.35      sakharuk  603: #-- <h2> tag
1.122     albertel  604: sub start_h2 {
                    605:     my ($target,$token) = @_;
                    606:     my $currentstring = '';
                    607:     if ($target eq 'web') {
                    608: 	$currentstring .= $token->[4];
                    609:     } elsif ($target eq 'tex') {
                    610: 	$currentstring .= '{\large \textbf{';
                    611:     } 
                    612:     return $currentstring;
                    613: }
                    614: 
                    615: sub end_h2 {
                    616:     my ($target,$token) = @_;
                    617:     my $currentstring = '';
                    618:     if ($target eq 'web') {
                    619: 	$currentstring .= $token->[2];
                    620:     } elsif ($target eq 'tex') {
                    621: 	$currentstring .= '}}';
                    622:     } 
                    623:     return $currentstring;
                    624: }
                    625: 
1.35      sakharuk  626: #-- <h3> tag
1.122     albertel  627: sub start_h3 {
                    628:     my ($target,$token) = @_;
                    629:     my $currentstring = '';
                    630:     if ($target eq 'web') {
                    631: 	$currentstring .= $token->[4];
                    632:     } elsif ($target eq 'tex') {
                    633: 	$currentstring .= '{\large \textbf{';
                    634:     } 
                    635:     return $currentstring;
                    636: }
                    637: 
                    638: sub end_h3 {
                    639:     my ($target,$token) = @_;
                    640:     my $currentstring = '';
                    641:     if ($target eq 'web') {
                    642: 	$currentstring .= $token->[2];
                    643:     } elsif ($target eq 'tex') {
                    644: 	$currentstring .= '}}';
                    645:     } 
                    646:     return $currentstring;
                    647: }
                    648: 
1.35      sakharuk  649: #-- <h4> tag
1.122     albertel  650: sub start_h4 {
                    651:     my ($target,$token) = @_;
                    652:     my $currentstring = '';
                    653:     if ($target eq 'web') {
                    654: 	$currentstring .= $token->[4];
                    655:     } elsif ($target eq 'tex') {
                    656: 	$currentstring .= '{\large \textbf{';
                    657:     } 
                    658:     return $currentstring;
                    659: }
                    660: 
                    661: sub end_h4 {
                    662:     my ($target,$token) = @_;
                    663:     my $currentstring = '';
                    664:     if ($target eq 'web') {
                    665: 	$currentstring .= $token->[2];
                    666:     } elsif ($target eq 'tex') {
                    667: 	$currentstring .= '}}';
                    668:     } 
                    669:     return $currentstring;
                    670: }
                    671: 
1.35      sakharuk  672: #-- <h5> tag
1.122     albertel  673: sub start_h5 {
                    674:     my ($target,$token) = @_;
                    675:     my $currentstring = '';
                    676:     if ($target eq 'web') {
                    677: 	$currentstring .= $token->[4];
                    678:     } elsif ($target eq 'tex') {
                    679: 	$currentstring .= '{\large \textbf{';
                    680:     } 
                    681:     return $currentstring;
                    682: }
                    683: 
                    684: sub end_h5 {
                    685:     my ($target,$token) = @_;
                    686:     my $currentstring = '';
                    687:     if ($target eq 'web') {
                    688: 	$currentstring .= $token->[2];
                    689:     } elsif ($target eq 'tex') {
                    690: 	$currentstring .= '}}';
                    691:     } 
                    692:     return $currentstring;
                    693: }
                    694: 
1.35      sakharuk  695: #-- <h6> tag
1.122     albertel  696: sub start_h6 {
                    697:     my ($target,$token) = @_;
                    698:     my $currentstring = '';
                    699:     if ($target eq 'web') {
                    700: 	$currentstring .= $token->[4];
                    701:     } elsif ($target eq 'tex') {
                    702: 	$currentstring .= '{\large \textbf{';
                    703:     } 
                    704:     return $currentstring;
                    705: }
                    706: 
                    707: sub end_h6 {
                    708:     my ($target,$token) = @_;
                    709:     my $currentstring = '';
                    710:     if ($target eq 'web') {
                    711: 	$currentstring .= $token->[2];
                    712:     } elsif ($target eq 'tex') {
                    713: 	$currentstring .= '}}';
                    714:     } 
                    715:     return $currentstring;
                    716: }
                    717: 
1.35      sakharuk  718: #--- <cite> tag
1.122     albertel  719: sub start_cite {
                    720:     my ($target,$token) = @_;
                    721:     my $currentstring = '';
                    722:     if ($target eq 'web') {
                    723: 	$currentstring .= $token->[4];
                    724:     } elsif ($target eq 'tex') {
                    725: 	$currentstring .= "\\textit{";
                    726:     }  elsif ($target eq 'latexsource') {
                    727: 	$currentstring .= "\\textit{";
                    728:     } 
                    729:     return $currentstring;
                    730: }
                    731: 
                    732: sub end_cite {
                    733:     my ($target,$token) = @_;
                    734:     my $currentstring = '';
                    735:     if ($target eq 'web') {
                    736: 	$currentstring .= $token->[2];
                    737:     } elsif ($target eq 'tex') {
                    738: 	$currentstring .= "}";
                    739:     }  elsif ($target eq 'latexsource') {
                    740: 	$currentstring .= "}";
                    741:     } 
                    742:     return $currentstring;
                    743: }
                    744: 
1.35      sakharuk  745: #-- <i> tag
1.122     albertel  746: sub start_i {
                    747:     my ($target,$token) = @_;
                    748:     my $currentstring = '';
                    749:     if ($target eq 'web') {
                    750: 	$currentstring .= $token->[4];
                    751:     } elsif ($target eq 'tex') {
                    752: 	$currentstring .= '\textit{';
                    753:     }  elsif ($target eq 'latexsource') {
                    754: 	$currentstring .= '\textit{';
                    755:     } 
                    756:     return $currentstring;
                    757: }
                    758: 
                    759: sub end_i {
                    760:     my ($target,$token) = @_;
                    761:     my $currentstring = '';
                    762:     if ($target eq 'web') {
                    763: 	$currentstring .= $token->[2];
                    764:     } elsif ($target eq 'tex') {
                    765: 	$currentstring .= '}';
                    766:     } elsif ($target eq 'latexsource') {
                    767: 	$currentstring .= '}';
                    768:     } 
                    769:     return $currentstring;
                    770: }
                    771: 
1.35      sakharuk  772: #-- <address> tag
1.122     albertel  773: sub start_address {
                    774:     my ($target,$token) = @_;
                    775:     my $currentstring = '';
                    776:     if ($target eq 'web') {
                    777: 	$currentstring .= $token->[4];
                    778:     } elsif ($target eq 'tex') {
                    779: 	$currentstring .= "\\textit{";
                    780:     } elsif ($target eq 'latexsource') {
                    781: 	$currentstring .= "\\textit{";
                    782:     } 
                    783:     return $currentstring;
                    784: }
                    785: 
                    786: sub end_address {
                    787:     my ($target,$token) = @_;
                    788:     my $currentstring = '';
                    789:     if ($target eq 'web') {
                    790: 	$currentstring .= $token->[2];
                    791:     } elsif ($target eq 'tex') {
                    792: 	$currentstring .= "}";
                    793:     } elsif ($target eq 'latexsource') {
                    794: 	$currentstring .= "}";
                    795:     }
                    796:     return $currentstring;
                    797: }
                    798: 
1.35      sakharuk  799: #-- <dfn> tag
1.122     albertel  800: sub start_dfn {
                    801:     my ($target,$token) = @_;
                    802:     my $currentstring = '';
                    803:     if ($target eq 'web') {
                    804: 	$currentstring .= $token->[4];
                    805:     } elsif ($target eq 'tex') {
                    806: 	$currentstring .= "\\textit{";
                    807:     } elsif ($target eq 'latexsource') {
                    808: 	$currentstring .= "\\textit{";
                    809:     } 
                    810:     return $currentstring;
                    811: }
                    812: 
                    813: sub end_dfn {
                    814:     my ($target,$token) = @_;
                    815:     my $currentstring = '';
                    816:     if ($target eq 'web') {
                    817: 	$currentstring .= $token->[2];
                    818:     } elsif ($target eq 'tex') {
                    819: 	$currentstring .= "}";
                    820:     } elsif ($target eq 'latexsource') {
                    821: 	$currentstring .= "}";
                    822:     } 
                    823:     return $currentstring;
                    824: }
                    825: 
1.35      sakharuk  826: #-- <tt> tag
1.122     albertel  827: sub start_tt {
                    828:     my ($target,$token) = @_;
                    829:     my $currentstring = '';
                    830:     if ($target eq 'web') {
                    831: 	$currentstring .= $token->[4];
                    832:     } elsif ($target eq 'tex') {
                    833: 	$currentstring .= '\texttt{';
                    834:     } elsif ($target eq 'latexsource') {
                    835: 	$currentstring .= '\texttt{';
                    836:     } 
                    837:     return $currentstring;
                    838: }
                    839: 
                    840: sub end_tt {
                    841:     my ($target,$token) = @_;
                    842:     my $currentstring = '';
                    843:     if ($target eq 'web') {
                    844: 	$currentstring .= $token->[2];
                    845:     } elsif ($target eq 'tex') {
                    846: 	$currentstring .= '}';
                    847:     } elsif ($target eq 'latexsource') {
                    848: 	$currentstring .= '}';
                    849:     }
                    850:     return $currentstring;
                    851: }
                    852: 
1.35      sakharuk  853: #-- <kbd> tag
1.122     albertel  854: sub start_kbd {
                    855:     my ($target,$token) = @_;
                    856:     my $currentstring = '';
                    857:     if ($target eq 'web') {
                    858: 	$currentstring .= $token->[4];
                    859:     } elsif ($target eq 'tex') {
                    860: 	$currentstring .= "\\texttt";
                    861:     } elsif ($target eq 'latexsource') {
                    862: 	$currentstring .= "\\texttt{";
                    863:     } 
                    864:     return $currentstring;
                    865: }
                    866: 
                    867: sub end_kbd {
                    868:     my ($target,$token) = @_;
                    869:     my $currentstring = '';
                    870:     if ($target eq 'web') {
                    871: 	$currentstring .= $token->[2];
                    872:     } elsif ($target eq 'tex') {
                    873: 	$currentstring .= "}";
                    874:     } elsif ($target eq 'latexsource') {
                    875: 	$currentstring .= "}";
                    876:     } 
                    877:     return $currentstring;
                    878: }
                    879: 
1.35      sakharuk  880: #-- <code> tag
1.122     albertel  881: sub start_code {
                    882:     my ($target,$token) = @_;
                    883:     my $currentstring = '';
                    884:     if ($target eq 'web') {
                    885: 	$currentstring .= $token->[4];
                    886:     } elsif ($target eq 'tex') {
                    887: 	$currentstring .= '\texttt{';
                    888:     } 
                    889:     return $currentstring;
                    890: }
                    891: 
                    892: sub end_code {
                    893:     my ($target,$token) = @_;
                    894:     my $currentstring = '';
                    895:     if ($target eq 'web') {
                    896: 	$currentstring .= $token->[2];
                    897:     } elsif ($target eq 'tex') {
                    898: 	$currentstring .= '}';
                    899:     } 
                    900:     return $currentstring;
                    901: }
                    902: 
1.35      sakharuk  903: #-- <em> tag
1.122     albertel  904: sub start_em {
                    905:     my ($target,$token) = @_;
                    906:     my $currentstring = '';
                    907:     if ($target eq 'web') {
                    908: 	$currentstring .= $token->[4];
                    909:     } elsif ($target eq 'tex') {
                    910: 	$currentstring .= '\emph{';
                    911:     } elsif ($target eq 'latexsource') {
                    912: 	$currentstring .= '\emph{';
                    913:     } 
                    914:     return $currentstring;
                    915: }
                    916: 
                    917: sub end_em {
                    918:     my ($target,$token) = @_;
                    919:     my $currentstring = '';
                    920:     if ($target eq 'web') {
                    921: 	$currentstring .= $token->[2];
                    922:     } elsif ($target eq 'tex') {
                    923: 	$currentstring .= '}';
                    924:     } elsif ($target eq 'latexsource') {
                    925: 	$currentstring .= '}';
                    926:     }  
                    927:     return $currentstring;
                    928: }
                    929: 
1.35      sakharuk  930: #-- <q> tag
1.122     albertel  931: sub start_q {
                    932:     my ($target,$token) = @_;
                    933:     my $currentstring = '';
                    934:     if ($target eq 'web') {
                    935: 	$currentstring .= $token->[4];
                    936:     } elsif ($target eq 'tex') {
                    937: 	$currentstring .= "\\emph{";
                    938:     }  elsif ($target eq 'latexsource') {
                    939: 	$currentstring .= "\\emph{";
                    940:     }
                    941:     return $currentstring;
                    942: }
                    943: 
                    944: sub end_q {
                    945:     my ($target,$token) = @_;
                    946:     my $currentstring = '';
                    947:     if ($target eq 'web') {
                    948: 	$currentstring .= $token->[2];
                    949:     } elsif ($target eq 'tex') {
                    950: 	$currentstring .= "}";
                    951:     } elsif ($target eq 'latexsource') {
                    952: 	$currentstring .= "}";
                    953:     }  
                    954:     return $currentstring;
                    955: }
                    956: 
1.35      sakharuk  957: #-- <p> tag
1.122     albertel  958: sub start_p {
                    959:     my ($target,$token) = @_;
                    960:     my $currentstring = '';
                    961:     if ($target eq 'web') {
                    962: 	$currentstring .= $token->[4];
                    963:     } elsif ($target eq 'tex') {
                    964: 	$currentstring .= '{\par ';
                    965:     } elsif ($target eq 'latexsource') {
                    966: 	$currentstring .= '{\par ';
                    967:     } 
                    968:     return $currentstring;
                    969: }
                    970: 
                    971: sub end_p {
                    972:     my ($target,$token) = @_;
                    973:     my $currentstring = '';
                    974:     if ($target eq 'web') {
                    975: 	$currentstring .= $token->[2];
                    976:     } elsif ($target eq 'tex') {
                    977: 	$currentstring .= '}';
                    978:     } elsif ($target eq 'latexsource') {
                    979: 	$currentstring .= '}';
                    980:     }
                    981:     return $currentstring;
                    982: }
                    983: 
1.35      sakharuk  984: #-- <br> tag
1.122     albertel  985: sub start_br {
                    986:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
                    987:     my $currentstring = '';
                    988:     if ($target eq 'web') {
                    989: 	$currentstring .= $token->[4];
                    990:     } elsif ($target eq 'tex') {
                    991: 	if ($$tagstack[-2] ne 'sub' && $$tagstack[-2] ne 'sup') {
                    992: 	    $currentstring .= '\vskip 0.2 mm';
1.1       sakharuk  993: 	}
1.122     albertel  994:     } elsif ($target eq 'latexsource') {
                    995: 	$currentstring .= '\\';
                    996:     } 
                    997:     return $currentstring;
                    998: }
                    999: 
                   1000: sub end_br {
                   1001:     my ($target,$token) = @_;
                   1002:     my $currentstring = '';
                   1003:     if ($target eq 'web') {
                   1004: 	$currentstring .= $token->[2];
                   1005:     }
                   1006:     return $currentstring;
                   1007: }
                   1008: 
1.35      sakharuk 1009: #-- <big> tag
1.122     albertel 1010: sub start_big {
                   1011:     my ($target,$token) = @_;
                   1012:     my $currentstring = '';
                   1013:     if ($target eq 'web') {
                   1014: 	$currentstring .= $token->[4];
                   1015:     } elsif ($target eq 'tex') {
                   1016: 	$currentstring .= '\large{';
                   1017:     } elsif ($target eq 'latexsource') {
                   1018: 	$currentstring .= '{\Large ';
                   1019:     }  
                   1020:     return $currentstring;
                   1021: }
                   1022: 
                   1023: sub end_big {
                   1024:     my ($target,$token) = @_;
                   1025:     my $currentstring = '';
                   1026:     if ($target eq 'web') {
                   1027: 	$currentstring .= $token->[2];
                   1028:     } elsif ($target eq 'tex') {
                   1029: 	$currentstring .= '}';
                   1030:     } elsif ($target eq 'latexsource') {
                   1031: 	$currentstring .= '}';
                   1032:     }
                   1033:     return $currentstring;
                   1034: }
                   1035: 
1.35      sakharuk 1036: #-- <small> tag
1.122     albertel 1037: sub start_small {
                   1038:     my ($target,$token) = @_;
                   1039:     my $currentstring = '';
                   1040:     if ($target eq 'web') {
                   1041: 	$currentstring .= $token->[4];
                   1042:     } elsif ($target eq 'tex') {
                   1043: 	$currentstring .= '{\footnotesize ';
                   1044:     } elsif ($target eq 'latexsource') {
                   1045: 	$currentstring .= '{\footnotesize ';
                   1046:     } 
                   1047:     return $currentstring;
                   1048: }
                   1049: 
                   1050: sub end_small {
                   1051:     my ($target,$token) = @_;
                   1052:     my $currentstring = '';
                   1053:     if ($target eq 'web') {
                   1054: 	$currentstring .= $token->[2];
                   1055:     } elsif ($target eq 'tex') {
                   1056: 	$currentstring .= '}';
                   1057:     } elsif ($target eq 'latexsource') {
                   1058: 	$currentstring .= '}';
                   1059:     }
                   1060:     return $currentstring;
                   1061: }
                   1062: 
1.35      sakharuk 1063: #-- <basefont> tag
1.122     albertel 1064: sub start_basefont {
                   1065:     my ($target,$token) = @_;
                   1066:     my $currentstring = '';
                   1067:     if ($target eq 'web') {
                   1068: 	$currentstring = $token->[4];     
                   1069:     } 
                   1070:     return $currentstring;
                   1071: }
                   1072: 
                   1073: sub end_basefont {
                   1074:     my ($target,$token) = @_;
                   1075:     my $currentstring = '';
                   1076:     if ($target eq 'web') {
                   1077: 	$currentstring = $token->[4];     
                   1078:     } 
                   1079:     return $currentstring;
                   1080: }
                   1081: 
1.35      sakharuk 1082: #-- <font> tag
1.122     albertel 1083: sub start_font {
                   1084:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
                   1085:     my $currentstring = '';
                   1086:     if ($target eq 'web') {
                   1087: 	my $face=&Apache::lonxml::get_param('face',$parstack,$safeeval);
                   1088: 	if ($face=~/symbol/i) {$Apache::lonxml::prevent_entity_encode++;}
                   1089: 	$currentstring = $token->[4];     
                   1090:     } 
                   1091:     return $currentstring;
                   1092: }
                   1093: 
                   1094: sub end_font {
                   1095:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
                   1096:     my $currentstring = '';
                   1097:     if ($target eq 'web') {
                   1098: 	my $face=&Apache::lonxml::get_param('face',$parstack,$safeeval);
                   1099: 	if ($face=~/symbol/i) {$Apache::lonxml::prevent_entity_encode--;}
                   1100: 	$currentstring = $token->[2];    
                   1101:     } 
                   1102:     return $currentstring;
                   1103: }
                   1104:  
1.35      sakharuk 1105: #-- <strike> tag
1.122     albertel 1106: sub start_strike {
                   1107:     my ($target,$token) = @_;
                   1108:     my $currentstring = '';
                   1109:     if ($target eq 'web') {
                   1110: 	$currentstring .= $token->[4];
                   1111:     } elsif ($target eq 'tex') {
                   1112: 	&Apache::lonxml::startredirection();
                   1113:     } 
                   1114:     return $currentstring;
                   1115: }
                   1116: 
                   1117: sub end_strike {
                   1118:     my ($target,$token) = @_;
                   1119:     my $currentstring = '';
                   1120:     if ($target eq 'web') {
                   1121: 	$currentstring .= $token->[2];
                   1122:     } elsif ($target eq 'tex') {
                   1123: 	$currentstring=&Apache::lonxml::endredirection();
                   1124: 	$currentstring=~s/(\S)(\s+)(\S)/$1\}$2\\underline\{$3/g; 
                   1125: 	$currentstring=~s/^\s*(\S)/\\underline\{$1/; 
                   1126: 	$currentstring=~s/(\S)\s*$/$1\}/;
                   1127:     }
                   1128:     return $currentstring;
                   1129: }
                   1130: 
1.35      sakharuk 1131: #-- <s> tag
1.122     albertel 1132: sub start_s {
                   1133:     my ($target,$token) = @_;
                   1134:     my $currentstring = '';
                   1135:     if ($target eq 'web') {
                   1136: 	$currentstring .= $token->[4];
                   1137:     } elsif ($target eq 'tex') {
                   1138: 	&Apache::lonxml::startredirection();
                   1139:     } 
                   1140:     return $currentstring;
                   1141: }
                   1142: 
                   1143: sub end_s {
                   1144:     my ($target,$token) = @_;
                   1145:     my $currentstring = '';
                   1146:     if ($target eq 'web') {
                   1147: 	$currentstring .= $token->[2];
                   1148:     } elsif ($target eq 'tex') {
                   1149: 	$currentstring=&Apache::lonxml::endredirection();
                   1150: 	$currentstring=~s/(\S)(\s+)(\S)/$1\}$2\\underline\{$3/g;
                   1151: 	$currentstring=~s/^\s*(\S)/\\underline\{$1/;
                   1152: 	$currentstring=~s/(\S)\s*$/$1\}/;	
                   1153:     }
                   1154:     return $currentstring;
                   1155: }
                   1156: 
1.35      sakharuk 1157: #-- <sub> tag
1.122     albertel 1158: sub start_sub {
                   1159:     my ($target,$token) = @_;
                   1160:     my $currentstring = '';
                   1161:     if ($target eq 'web') {
                   1162: 	$currentstring .= $token->[4];
                   1163:     } elsif ($target eq 'tex') {
                   1164: 	$currentstring .= "\$_{ ";
                   1165:     } 
                   1166:     return $currentstring;
                   1167: }
                   1168: 
                   1169: sub end_sub {
                   1170:     my ($target,$token) = @_;
                   1171:     my $currentstring = '';
                   1172:     if ($target eq 'web') {
                   1173: 	$currentstring .= $token->[2];
                   1174:     } elsif ($target eq 'tex') {
                   1175: 	$currentstring .= " }\$";
                   1176:     }
                   1177:     return $currentstring;
                   1178: }
                   1179: 
1.35      sakharuk 1180: #-- <sup> tag
1.122     albertel 1181: sub start_sup {
                   1182:     my ($target,$token) = @_;
                   1183:     my $currentstring = '';
                   1184:     if ($target eq 'web') {
                   1185: 	$currentstring .= $token->[4];
                   1186:     } elsif ($target eq 'tex') {
                   1187: 	$currentstring .= "\$^{ ";
                   1188:     } 
                   1189:     return $currentstring;
                   1190: }
                   1191: 
                   1192: sub end_sup {
                   1193:     my ($target,$token) = @_;
                   1194:     my $currentstring = '';
                   1195:     if ($target eq 'web') {
                   1196: 	$currentstring .= $token->[2];
                   1197:     } elsif ($target eq 'tex') {
                   1198: 	$currentstring .= " }\$";
                   1199:     }
                   1200:     return $currentstring;
                   1201: }
                   1202: 
1.35      sakharuk 1203: #-- <hr> tag
1.122     albertel 1204: sub start_hr {
1.124   ! sakharuk 1205:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1.122     albertel 1206:     my $currentstring = '';
                   1207:     if ($target eq 'web') {
                   1208: 	$currentstring .= $token->[4];
                   1209:     } elsif ($target eq 'tex') {
1.124   ! sakharuk 1210: 	my $LaTeXwidth = &Apache::lonxml::get_param('TeXwidth',$parstack,$safeeval);
        !          1211: 	if (defined $LaTeXwidth) {
        !          1212: 	    if ($LaTeXwidth=~/^%/) {
        !          1213: 		substr($LaTeXwidth,0,1)='';
        !          1214: 		$LaTeXwidth=($LaTeXwidth/100).'\textwidth';
        !          1215: 	    }
        !          1216: 	} else {
        !          1217: 	    $LaTeXwidth ='0.95\textwidth';
        !          1218: 	}
        !          1219: 	my ($pre,$post);
        !          1220: 	my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1);
        !          1221: 	if (($align eq 'center') || (not defined $align)) {
        !          1222: 	    $pre=''; $post='';
        !          1223: 	} elsif ($align eq 'left') {
        !          1224: 	    $pre='\rlap{'; $post='} \hfill';
        !          1225: 	} elsif ($align eq 'right') {
        !          1226: 	    $pre=' \hfill \llap{'; $post='}';
        !          1227: 	}
        !          1228: 	$currentstring .= ' \vskip 0 mm \noindent\makebox[\textwidth]{'.$pre.'\makebox['.
        !          1229:                                     $LaTeXwidth.'][b]{\hrulefill}'.$post.'}\vskip 0 mm ';
1.122     albertel 1230:     } 
                   1231:     return $currentstring;
                   1232: }
                   1233: 
                   1234: sub end_hr {
                   1235:     my ($target,$token) = @_;
                   1236:     my $currentstring = '';
                   1237:     if ($target eq 'web') {
                   1238: 	$currentstring .= $token->[2];
                   1239:     } elsif ($target eq 'tex') {
                   1240:     } 
                   1241:     return $currentstring;
                   1242: }
                   1243: 
1.85      sakharuk 1244: #-- <div> tag
1.122     albertel 1245: sub start_div {
                   1246:     my ($target,$token) = @_;
                   1247:     my $currentstring = '';
                   1248:     if ($target eq 'web') {
                   1249: 	$currentstring .= $token->[4];
                   1250:     } 
                   1251:     return $currentstring;
                   1252: }
                   1253: 
                   1254: sub end_div {
                   1255:     my ($target,$token) = @_;
                   1256:     my $currentstring = '';
                   1257:     if ($target eq 'web') {
                   1258: 	$currentstring .= $token->[2];
                   1259:     } 
                   1260:     return $currentstring;
                   1261: }
                   1262: 
1.35      sakharuk 1263: #-- <a> tag
1.122     albertel 1264: sub start_a {
                   1265:     my ($target,$token) = @_;
                   1266:     my $currentstring = '';
                   1267:     if ($target eq 'web') {
                   1268: 	$currentstring .= $token->[4];
                   1269:     } elsif ($target eq 'tex') {
                   1270:     }
                   1271:     return $currentstring;
                   1272: }
                   1273: 
                   1274: sub end_a {
                   1275:     my ($target,$token,$tagstack,$stackref) = @_;
                   1276:     my $currentstring = '';
                   1277:     if ($target eq 'web') {
                   1278: 	$currentstring .= $token->[2];
                   1279:     } elsif ($target eq 'tex') {
                   1280: 	my  $tempor_var = $stackref->[$#$stackref];
                   1281: 	if (index($tempor_var,'name') != -1 ) {
                   1282: 	    $tempor_var =~ s/name=([^,]*),/$1/g;
                   1283: 	} elsif (index($tempor_var,'href') != -1 ) {
                   1284: 	    $tempor_var =~ s/href=([^,]*),/$1/g;
                   1285: 	    $currentstring .= " \\ref{$tempor_var}";
1.1       sakharuk 1286: 	}
1.122     albertel 1287:     }
                   1288:     return $currentstring;
                   1289: }
                   1290: 
1.35      sakharuk 1291: #-- <li> tag
1.122     albertel 1292: sub start_li {
                   1293:     my ($target,$token,$tagstack,$stackref) = @_;
                   1294:     my $currentstring = '';
                   1295:     if ($target eq 'web') {
                   1296: 	$currentstring = $token->[4];     
                   1297:     } elsif ($target eq 'tex') {
                   1298: 	my  $tempor_var = $stackref->[$#$stackref];
                   1299: 	if (index($tempor_var,'circle') != -1 ) {
                   1300: 	    $currentstring .= " \\item[o] ";
                   1301: 	} elsif (index($tempor_var,'square') != -1 ) {
                   1302: 	    $currentstring .= " \\item[$\Box$] ";
                   1303: 	} elsif ($tempor_var ne '') { 
                   1304: 	    $_ = $tempor_var;
                   1305: 	    m/my\s*([^=]*)=/;
                   1306: 	    $currentstring .= " \\item[$1] ";
                   1307: 	} else {
                   1308: 	    $currentstring .= " \\item ";
                   1309: 	}  
                   1310:     } 
                   1311:     return $currentstring;
                   1312: }
                   1313: 
                   1314: sub end_li {
                   1315:     my ($target,$token) = @_;
                   1316:     my $currentstring = '';
                   1317:     if ($target eq 'web') {
                   1318: 	$currentstring = $token->[2];     
                   1319:     } 
                   1320:     return $currentstring;
                   1321: }
                   1322: 
1.35      sakharuk 1323: #-- <u> tag
1.122     albertel 1324: sub start_u {
                   1325:     my ($target,$token) = @_;
                   1326:     my $currentstring = '';
                   1327:     if ($target eq 'web') {
                   1328: 	$currentstring .= $token->[4];
                   1329:     } elsif ($target eq 'tex') {
                   1330: 	&Apache::lonxml::startredirection();
                   1331:     } 
                   1332:     return $currentstring;
                   1333: }
                   1334: 
                   1335: sub end_u {
                   1336:     my ($target,$token) = @_;
                   1337:     my $currentstring = '';
                   1338:     if ($target eq 'web') {
                   1339: 	$currentstring .= $token->[2];
                   1340:     } elsif ($target eq 'tex') {
                   1341: 	$currentstring=&Apache::lonxml::endredirection();
                   1342: 	$currentstring=~s/(\S)(\s+)(\S)/$1\}$2\\underline\{$3/g;
                   1343: 	$currentstring=~s/^\s*(\S)/\\underline\{$1/;
                   1344: 	$currentstring=~s/(\S)\s*$/$1\}/;		
                   1345:     }
                   1346:     return $currentstring;
                   1347: }
                   1348: 
1.35      sakharuk 1349: #-- <ul> tag
1.122     albertel 1350: sub start_ul {
                   1351:     my ($target,$token) = @_;
                   1352:     my $currentstring = '';
                   1353:     if ($target eq 'web') {
                   1354: 	$currentstring = $token->[4];     
                   1355:     } elsif ($target eq 'tex') {
                   1356: 	$currentstring = '\begin{itemize}';  
                   1357:     } 
                   1358:     return $currentstring;
                   1359: }
                   1360: 
                   1361: sub end_ul {
                   1362:     my ($target,$token) = @_;
                   1363:     my $currentstring = '';
                   1364:     if ($target eq 'web') {
                   1365: 	$currentstring = $token->[2];     
                   1366:     } elsif ($target eq 'tex') {
                   1367: 	$currentstring = '\end{itemize}';  
                   1368:     } 
                   1369:     return $currentstring;
                   1370: }
                   1371: 
1.35      sakharuk 1372: #-- <menu> tag
1.122     albertel 1373: sub start_menu {
                   1374:     my ($target,$token) = @_;
                   1375:     my $currentstring = '';
                   1376:     if ($target eq 'web') {
                   1377: 	$currentstring = $token->[4];     
                   1378:     } elsif ($target eq 'tex') {
                   1379: 	$currentstring = " \\begin{itemize} ";  
                   1380:     } 
                   1381:     return $currentstring;
                   1382: }
                   1383: 
                   1384: sub end_menu {
                   1385:     my ($target,$token) = @_;
                   1386:     my $currentstring = '';
                   1387:     if ($target eq 'web') {
                   1388: 	$currentstring = $token->[2];     
                   1389:     } elsif ($target eq 'tex') {
                   1390: 	$currentstring = " \\end{itemize}";  
                   1391:     } 
                   1392:     return $currentstring;
                   1393: }
                   1394: 
1.35      sakharuk 1395: #-- <dir> tag
1.122     albertel 1396: sub start_dir {
                   1397:     my ($target,$token) = @_;
                   1398:     my $currentstring = '';
                   1399:     if ($target eq 'web') {
                   1400: 	$currentstring = $token->[4];     
                   1401:     } elsif ($target eq 'tex') {
                   1402: 	$currentstring = " \\begin{itemize} ";  
                   1403:     } 
                   1404:     return $currentstring;
                   1405: }
                   1406: 
                   1407: sub end_dir {
                   1408:     my ($target,$token) = @_;
                   1409:     my $currentstring = '';
                   1410:     if ($target eq 'web') {
                   1411: 	$currentstring = $token->[2];     
                   1412:     } elsif ($target eq 'tex') {
                   1413: 	$currentstring = " \\end{itemize}";  
                   1414:     } 
                   1415:     return $currentstring;
                   1416: }
                   1417: 
1.35      sakharuk 1418: #-- <ol> tag
1.122     albertel 1419: sub start_ol {
                   1420:     my ($target,$token) = @_;
                   1421:     my $currentstring = '';
                   1422:     if ($target eq 'web') {
                   1423: 	$currentstring = $token->[4];     
                   1424:     } elsif ($target eq 'tex') {
                   1425: 	$currentstring = '\begin{enumerate}';  
                   1426:     } 
                   1427:     return $currentstring;
                   1428: }
                   1429: 
                   1430: sub end_ol {
                   1431:     my ($target,$token) = @_;
                   1432:     my $currentstring = '';
                   1433:     if ($target eq 'web') {
                   1434: 	$currentstring = $token->[2];     
                   1435:     } elsif ($target eq 'tex') {
                   1436: 	$currentstring = '\end{enumerate}';  
                   1437:     } 
                   1438:     return $currentstring;
                   1439: }
                   1440: 
1.35      sakharuk 1441: #-- <dl> tag
1.122     albertel 1442: sub start_dl {
                   1443:     my ($target,$token) = @_;
                   1444:     my $currentstring = '';
                   1445:     if ($target eq 'web') {
                   1446: 	$currentstring = $token->[4];     
                   1447:     } elsif ($target eq 'tex') {
                   1448: 	$currentstring = '\begin{description}';  
                   1449:     } 
                   1450:     return $currentstring;
                   1451: }
                   1452: 
                   1453: sub end_dl {
                   1454:     my ($target,$token) = @_;
                   1455:     my $currentstring = '';
                   1456:     if ($target eq 'web') {
                   1457: 	$currentstring = $token->[2];     
                   1458:     } elsif ($target eq 'tex') {
                   1459: 	$currentstring = '\end{description}';  
                   1460:     } 
                   1461:     return $currentstring;
                   1462: }
                   1463: 
1.35      sakharuk 1464: #-- <dt> tag
1.122     albertel 1465: sub start_dt {
                   1466:     my ($target,$token) = @_;
                   1467:     my $currentstring = '';
                   1468:     if ($target eq 'web') {
                   1469: 	$currentstring = $token->[4];     
                   1470:     } elsif ($target eq 'tex') {
                   1471: 	$currentstring = '\item[';  
                   1472:     } 
                   1473:     return $currentstring;
                   1474: }
                   1475: 
                   1476: sub end_dt {
                   1477:     my ($target,$token) = @_;
                   1478:     my $currentstring = '';
                   1479:     if ($target eq 'web') {
                   1480: 	$currentstring = $token->[2];    
                   1481:     } elsif ($target eq 'tex') {
                   1482: 	$currentstring = ']';  
                   1483:     } 
                   1484:     return $currentstring;
                   1485: }
                   1486: 
1.35      sakharuk 1487: #-- <dd> tag
1.122     albertel 1488: sub start_dd {
                   1489:     my ($target,$token) = @_;
                   1490:     my $currentstring = '';
                   1491:     if ($target eq 'web') {
                   1492: 	$currentstring = $token->[4];     
                   1493:     } 
                   1494:     return $currentstring;
                   1495: }
                   1496: 
                   1497: sub end_dd {
                   1498:     my ($target,$token) = @_;
                   1499:     my $currentstring = '';
                   1500:     if ($target eq 'web') {
                   1501: 	$currentstring = $token->[2];    
                   1502:     } 
                   1503:     return $currentstring;
                   1504: }
                   1505: 
1.35      sakharuk 1506: #-- <table> tag
1.91      sakharuk 1507: sub start_table {
                   1508:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
                   1509:     my $currentstring = '';
                   1510:     if ($target eq 'web') {
                   1511: 	$currentstring = $token->[4];     
                   1512:     } elsif ($target eq 'tex') {
                   1513: 	my $aa = {};
                   1514: 	push @Apache::londefdef::table, $aa; 
                   1515: 	$Apache::londefdef::table[-1]{'row_number'} = -1;
                   1516: 	$Apache::londefdef::table[-1]{'output'} = ' \noindent \begin{tabular} ';
1.101     sakharuk 1517: 	my $border = &Apache::lonxml::get_param('border',$parstack,$safeeval,undef,1); 
1.91      sakharuk 1518: 	unless (defined $border) { $border = 0; }
                   1519: 	if ($border) { 
                   1520: 	    $Apache::londefdef::table[-1]{'hinc'} = '\hline '; 
                   1521: 	    $Apache::londefdef::table[-1]{'vinc'} = '&'; 
                   1522: 	    $Apache::londefdef::table[-1]{'vvinc'} = '|';
                   1523: 	} else {
                   1524: 	    $Apache::londefdef::table[-1]{'hinc'} = ''; 
                   1525: 	    $Apache::londefdef::table[-1]{'vinc'} = '&'; 
                   1526: 	    $Apache::londefdef::table[-1]{'vvinc'} = '';
                   1527: 	}
                   1528: 	my $width;
                   1529: 	foreach my $key (keys(%{$token->[2]})) {
                   1530: 	    if ($key =~ /^width$/i) {
1.101     sakharuk 1531: 		$width = &Apache::lonxml::get_param($key,$parstack,$safeeval,undef,1);
1.91      sakharuk 1532: 	    }
1.51      sakharuk 1533: 	}
1.91      sakharuk 1534: 	if (defined($width)) { $Apache::londefdef::table[-1]{'width'}=$width; }
                   1535:     }
                   1536:     return $currentstring;
                   1537: }
1.122     albertel 1538:  
                   1539: sub end_table {
                   1540:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
                   1541:     my $currentstring = '';
                   1542:     if ($target eq 'web') {
                   1543: 	$currentstring = $token->[2];     
                   1544:     } elsif ($target eq 'tex') {
                   1545: 	my $inmemory = '';
                   1546: 	my $output = '';
                   1547: 	#construct header of the table
                   1548: 	my $header_of_table = '{'.$Apache::londefdef::table[-1]{'vvinc'};
                   1549: 	my $in;
                   1550: 	for ($in=0;$in<=$Apache::londefdef::table[-1]{'counter_columns'};$in++) {
                   1551: 	    $header_of_table .= $Apache::londefdef::table[-1]{'columns'}[$in].$Apache::londefdef::table[-1]{'vvinc'};
                   1552: 	}
                   1553: 	$header_of_table .= '}';
                   1554: 	#fill the table
                   1555: 	for ($in=0;$in<=$Apache::londefdef::table[-1]{'row_number'};$in++) {
                   1556: 	    $output .=  $Apache::londefdef::table[-1]{'rowdata'}[$in];
                   1557: 	    chop $output;
                   1558: 	    $output .= ' \\\\ ';
                   1559: 	}
                   1560: 	#define the length of the table cells
                   1561: 	my @lengthforoutput = split(/,/,$Apache::londefdef::table[-1]{'lengthrow'}[0]);
                   1562: 	my $how_many_columns = $#lengthforoutput + 1; #total number of columns in the table 
                   1563: 	my $filled_columns = 0; #number of columns with information about width
                   1564: 	my $available_space = ' ';
                   1565: 	foreach my $tempo_length (@{ $Apache::londefdef::table[-1]{'lengthrow'} }) {
                   1566: 	    my @length = split(/,/,$tempo_length);
                   1567: 	    for (my $ico=0;$ico<=$#lengthforoutput;$ico++) {
                   1568: 		$lengthforoutput[$ico] =~ m/(\d*\.?\d*)\s*(\w+)/;
                   1569: 		my $old_value = $1;
                   1570: 		my $old_unit = $2; 
                   1571: 		if ($old_unit eq 'cm') { 
                   1572: 		    $old_value = $old_value * 10;
                   1573: 		} elsif ($old_unit eq 'in') { 
                   1574: 		    $old_value = $old_value * 25.4;
                   1575: 		} elsif ($old_unit eq 'pt') {
                   1576: 		    $old_value = $old_value * 25.4/72.27;
                   1577: 		} elsif ($old_unit eq 'pc') {
                   1578: 		    $old_value = $old_value * 25.4/6.022;
1.50      sakharuk 1579: 		}
1.122     albertel 1580: 		$old_unit = 'mm';
                   1581: 		$length[$ico] =~ m/(\d*\.?\d*)\s*(\w+)/;
                   1582: 		my $new_value = $1;
                   1583: 		my $new_unit = $2;
                   1584: 		if ($new_unit eq 'cm') { 
                   1585: 		    $new_value = $new_value * 10;
                   1586: 		} elsif ($old_unit eq 'in') { 
                   1587: 		    $new_value = $new_value * 25.4;
                   1588: 		} elsif ($old_unit eq 'pt') {
                   1589: 		    $new_value = $new_value * 25.4/72.27;
                   1590: 		} elsif ($old_unit eq 'pc') {
                   1591: 		    $new_value = $new_value * 25.4/6.022;
1.71      sakharuk 1592: 		}
1.122     albertel 1593: 		$new_unit = 'mm';
                   1594: 		if ($old_value < $new_value) {
                   1595: 		    $lengthforoutput[$ico] = $new_value.' mm';
1.91      sakharuk 1596: 		} else {
1.122     albertel 1597: 		    $lengthforoutput[$ico] = $old_value.' mm';
1.53      sakharuk 1598: 		}
1.51      sakharuk 1599: 	    }
                   1600: 	}
1.122     albertel 1601: 	for (my $ico=0;$ico<=$#lengthforoutput;$ico++) {
                   1602: 	    if (not $lengthforoutput[$ico]=~m/^\s*0\s*\w*\s*$/) {
                   1603: 		$filled_columns++;
                   1604: 		$available_space = $available_space.' - '.$lengthforoutput[$ico];
                   1605: 	    }
                   1606: 	}
                   1607: 	my $temp_file;
                   1608: 	my $filename = "/home/httpd/prtspool/$ENV{'user.name'}_$ENV{'user.domain'}_printout.tbl";
                   1609: 	if (-e $filename) {
                   1610: 	    $temp_file = Apache::File->new($filename); 
                   1611: 	    my @tbl_file_content = <$temp_file>;
                   1612: 	    my ($one,$two,$three) = split(/,/,$tbl_file_content[0]);
                   1613: 	    $how_many_columns+=$one-1;
                   1614: 	    $filled_columns+=$two;
                   1615: 	    if($three=~/\S/) {$available_space = $available_space.' - '.$three;}
                   1616: 	} else {
                   1617: 	    $temp_file = Apache::File->new('>>'.$filename); 
                   1618: 	}		
                   1619: 	print $temp_file "$how_many_columns,$filled_columns,$available_space\n";
                   1620: 	$output =~ s/\\parbox{TOBECHANGEDONNUMBER}{}/\\parbox{1 mm}{}/g;
                   1621: 	$output =~ s/\\parbox{TOBECHANGEDONNUMBER}/\\parbox{\$SpacePerColumn}/g;
                   1622: 	my @tagar = @$tagstack;
                   1623: 	my $signature = 1;
                   1624: 	for (my $ico=0;$ico<$#tagar;$ico++) {
                   1625: 	    if ($tagar[$ico] eq 'table') { $signature = 0; }
                   1626: 	}
                   1627: 	if ($signature) {
                   1628: 	    my $NumberEmptyLength = $how_many_columns - $filled_columns;		
                   1629: 	    my $SpacePerColumn = '(\textwidth '.$available_space.')/'.$NumberEmptyLength;
                   1630: 	    my $shorthand = ($filled_columns+1)*4;
                   1631: 	    $output =~ s/\$SpacePerColumn/$SpacePerColumn - $shorthand mm/g;
                   1632: 	}	
                   1633: 	if ($how_many_columns==1) {
                   1634: 	    #start of block with width correction for one column table
                   1635: 	    $output=~s/^\s*\\parbox\{([^\}]*)\}/\\parbox\{\\textwidth - 1 cm\}/;
                   1636: 	    #end of block with width correction for one column table
                   1637: 	}
                   1638: 	$Apache::londefdef::table[-1]{'output'} .= $header_of_table.$output.$Apache::londefdef::table[-1]{'hinc'}.'\end{tabular}\vskip 0 mm ';
                   1639: 	if ($#Apache::londefdef::table > 0) {
                   1640: 	    $inmemory = $Apache::londefdef::table[-1]{'output'};
                   1641: 	    pop @Apache::londefdef::table;
                   1642: 	    $Apache::londefdef::table[-1]{'rowdata'}[$Apache::londefdef::table[-1]{'row_number'}] .= $inmemory
                   1643: 	} else {
                   1644: 	    $currentstring = $Apache::londefdef::table[-1]{'output'};
                   1645: 	    $currentstring =~ s/\\\\\s+\\\\/\\\\/g; 
                   1646: 	    pop @Apache::londefdef::table;
                   1647: 	    if (-e $filename) {
                   1648: 		unlink $filename;
                   1649: 	    }
                   1650: 	}
                   1651:     }
                   1652:     return $currentstring;
                   1653: }
                   1654: 
1.51      sakharuk 1655: #-- <tr> tag
1.122     albertel 1656: sub start_tr {
                   1657:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
                   1658:     my $currentstring = '';
                   1659:     if ($target eq 'web') {
                   1660: 	$currentstring = $token->[4];     
                   1661:     } elsif ($target eq 'tex') {
                   1662: 	$Apache::londefdef::table[-1]{'row_number'}++;
                   1663: 	my $alignchar = substr(&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1),0,1);
                   1664: 	if ($alignchar ne '') {
                   1665: 	    push @ {$Apache::londefdef::table[-1]{'rows'} }, $alignchar;
                   1666: 	} else {
                   1667: 	    push @ {$Apache::londefdef::table[-1]{'rows'} }, 'l';
                   1668: 	}
                   1669: 	push ( @{ $Apache::londefdef::table[-1]{'rowdata'} }, $Apache::londefdef::table[-1]{'hinc'});
                   1670: 	$Apache::londefdef::table[-1]{'counter_columns'} = -1;
                   1671: 	$Apache::londefdef::table[-1]{'length'} = ''; 
                   1672:     } 
                   1673:     return $currentstring;
                   1674: }
                   1675:         
                   1676: sub end_tr {
                   1677:     my ($target,$token) = @_;
                   1678:     my $currentstring = '';
                   1679:     if ($target eq 'web') {
                   1680: 	$currentstring = $token->[2];     
                   1681:     } elsif ($target eq 'tex') {
                   1682: 	push @{ $Apache::londefdef::table[-1]{'lengthrow'} },$Apache::londefdef::table[-1]{'length'};
                   1683: 	
                   1684:     }
                   1685:     return $currentstring;
                   1686: }
                   1687: 
                   1688: #-- <td> tag
                   1689: sub start_td {
                   1690:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
                   1691:     my $currentstring = '';
                   1692:     if ($target eq 'web') {
                   1693: 	$currentstring = $token->[4];     
                   1694:     } elsif ($target eq 'tex') {
                   1695: 	my $what_to_push = substr(&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1),0,1);
                   1696: 	if ($what_to_push eq '') {
                   1697: 	    $what_to_push = substr($Apache::londefdef::table[-1]{'rows'}[0],0,1);;
                   1698: 	}
                   1699: 	push @{ $Apache::londefdef::table[-1]{'columns'} }, $what_to_push;
                   1700: 	$Apache::londefdef::table[-1]{'counter_columns'}++;
                   1701: 	&Apache::lonxml::startredirection();
                   1702:     } 
                   1703:     return $currentstring;
                   1704: }   
                   1705:      
                   1706: sub end_td {
                   1707:     my ($target,$token) = @_;
                   1708:     my $currentstring = '';
                   1709:     my $tempolen = '';
                   1710:     if ($target eq 'web') {
                   1711: 	$currentstring = $token->[2];     
                   1712:     } elsif ($target eq 'tex') {
                   1713: 	my $current_row = $Apache::londefdef::table[-1]{'row_number'};
                   1714: 	my $data=&Apache::lonxml::endredirection();
                   1715: 	if ($data=~m/width\s*=\s*(\d+\.?\d*\s*(mm|cm|in|pc|pt))/) {
                   1716: 	    $Apache::londefdef::table[-1]{'length'} .= $1.',';
                   1717: 	    $tempolen = $1;         
                   1718: 	} else {
                   1719: 	    if (length($data)<5) {
                   1720: 		$Apache::londefdef::table[-1]{'length'} .= '0 mm,';
                   1721: 		$tempolen = '6 mm';
                   1722: 	    } else {
                   1723: 		$Apache::londefdef::table[-1]{'length'} .= '0 mm,';
                   1724: 		$tempolen = 'TOBECHANGEDONNUMBER';
                   1725: 	    }
                   1726: 	}                                        
                   1727: 	@{ $Apache::londefdef::table[-1]{'rowdata'} }[$current_row] .= '\parbox{'.$tempolen.'}{'.$data.'} '.$Apache::londefdef::table[-1]{'vinc'};
                   1728:     }
                   1729:     return $currentstring;
                   1730: }
                   1731: 
                   1732: #-- <th> tag
                   1733: sub start_th {
                   1734:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
                   1735:     my $currentstring = '';
                   1736:     if ($target eq 'web') {
                   1737: 	$currentstring = $token->[4];     
                   1738:     } elsif ($target eq 'tex') {
                   1739: 	my $what_to_push = substr(&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1),0,1);
                   1740: 	if ($what_to_push eq '') {
                   1741: 	    $what_to_push = substr($Apache::londefdef::table[-1]{'rows'}[0],0,1);;
                   1742: 	}
                   1743: 	push @{ $Apache::londefdef::table[-1]{'columns'} }, $what_to_push;
                   1744: 	$Apache::londefdef::table[-1]{'counter_columns'}++;
                   1745: 	&Apache::lonxml::startredirection();
                   1746: 	;
                   1747:     } 
                   1748:     return $currentstring;
                   1749: }
                   1750:         
                   1751: sub end_th {
                   1752:     my ($target,$token) = @_;
                   1753:     my $currentstring = '';
                   1754:     if ($target eq 'web') {
                   1755: 	$currentstring = $token->[2];     
                   1756:     } elsif ($target eq 'tex') {
                   1757: 	my $current_row = $Apache::londefdef::table[-1]{'row_number'};
                   1758: 	my $data=&Apache::lonxml::endredirection();
                   1759: 	if ($data=~m/width\s*=\s*(\d+\.*\d*\s*(mm|cm))/) {                 
                   1760: 	    $Apache::londefdef::table[-1]{'length'} .= $1.',';             
                   1761: 	} else {
                   1762: 	    $Apache::londefdef::table[-1]{'length'} .= '0 mm,'; 
                   1763: 	}                                                           
                   1764: 	@{ $Apache::londefdef::table[-1]{'rowdata'} }[$current_row] .= '\parbox{'.$1.'}{\textbf{'.$data.'}} '.$Apache::londefdef::table[-1]{'vinc'};
                   1765:     }
                   1766:     return $currentstring;
                   1767: }
1.79      sakharuk 1768: 
1.122     albertel 1769: #-- <img> tag
                   1770: sub start_img {
                   1771:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
                   1772:     my $src = &Apache::lonxml::get_param('src',$parstack,$safeeval,
                   1773: 					 undef,1);
                   1774:     $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=$src;
                   1775:     my $currentstring = '';
                   1776:     my $width_param = '';
                   1777:     my $height_param = '';
                   1778:     my $scaling = .3;
                   1779:     
                   1780:     if ($target eq 'web') {
                   1781: 	if ($ENV{'browser.imagesuppress'} ne 'on') {
                   1782: 	    $currentstring = $token->[4];
                   1783: 	} else {
                   1784: 	    my $alttag= &Apache::lonxml::get_param
                   1785: 		('alt',$parstack,$safeeval,undef,1);
                   1786: 	    unless ($alttag) {
                   1787: 		$alttag=&Apache::lonmeta::alttag
                   1788: 		    ($Apache::lonxml::pwd[-1],$src);
1.51      sakharuk 1789: 	    }
1.122     albertel 1790: 	    $currentstring='[IMAGE: '.$alttag.']';
1.1       sakharuk 1791: 	}
1.122     albertel 1792:     } elsif ($target eq 'tex') {
                   1793: 	$src=&Apache::lonnet::filelocation($Apache::lonxml::pwd[-1],$src);
                   1794: 	&image_replication($src);
                   1795: 	
                   1796: 	#if original gif/jpg/png file exist do following:
                   1797: 	if (-e $src) {          
                   1798: 	    #defines the default size of image
                   1799: 	    my $image = Image::Magick->new;
                   1800: 	    my $current_figure = $image->Read($src);
                   1801: 	    $width_param = $image->Get('width') * $scaling;;
                   1802: 	    $height_param = $image->Get('height') * $scaling;;
                   1803: 	    undef $image;
                   1804: 	    #do we have any specified size of the picture?
                   1805: 	    my $TeXwidth = &Apache::lonxml::get_param('TeXwidth',$parstack,$safeeval);
                   1806: 	    my $TeXheight = &Apache::lonxml::get_param('TeXheight',$parstack,$safeeval);
                   1807: 	    my $width = &Apache::lonxml::get_param('width',$parstack,$safeeval,
                   1808: 						   undef,1);
                   1809: 	    if ($TeXwidth ne '') {  
                   1810: 		if ($TeXwidth=~/(\d+)\s*\%/) {
                   1811: 		    $width_param = $1*$ENV{'form.textwidth'}/100;
                   1812: 		} else { 
                   1813: 		    $width_param = $TeXwidth;
                   1814: 		}
                   1815: 	    } elsif ($TeXheight ne '') {
                   1816: 		$width_param = $TeXheight/$height_param*$width_param;
                   1817: 	    } elsif ($width ne '') {
                   1818: 		$width_param = $width*$scaling;      
                   1819: 	    }
                   1820: 	    my $file;
                   1821: 	    my $path;	
                   1822: 	    if ($src =~ m!(.*)/([^/]*)$!) {
                   1823: 		$file = $2; 
                   1824: 		$path = $1.'/'; 
                   1825: 	    } 
                   1826: 	    my $newsrc = $src;
                   1827: 	    $newsrc =~ s/\.(gif|jpg|png)$/.eps/i;
                   1828: 	    $file=~s/\.(gif|jpg|png)$/.eps/i;
                   1829: 	    #where can we find the picture?
                   1830: 	    if (-e $newsrc) {
                   1831: 		#eps counterpart for image exist 
                   1832: 		if ($path) {
                   1833: 		    $currentstring .= '\vskip 1 mm \noindent\graphicspath{{'.$path.'}}\includegraphics[width='.$width_param.' mm]{'.$file.'} ';
1.51      sakharuk 1834: 		}
1.122     albertel 1835: 	    } else {
                   1836: 		#there is no eps counterpart for image - check for ps one
                   1837: 		$newsrc =~ s/\.eps$/\.ps/;
                   1838: 		if (-e $newsrc) {
                   1839: 		    #ps counterpart for image exist 
                   1840: 		    $file =~ s/\.eps$/\.ps/;
                   1841: 		    if ($path) {
                   1842: 			$currentstring .= '\vskip 1 mm \noindent\graphicspath{{'.$path.'}}\includegraphics[width='.$width_param.' mm]{'.$file.'} ';
                   1843: 		    }
1.78      sakharuk 1844: 		} else {
1.122     albertel 1845: 		    #there aren't eps or ps - so create eps 
                   1846: 		    my $temp_file;
                   1847: 		    my $filename = "/home/httpd/prtspool/$ENV{'user.name'}_$ENV{'user.domain'}_printout.dat";
                   1848: 		    $temp_file = Apache::File->new('>>'.$filename); 
                   1849: 		    print $temp_file "$src\n";
                   1850: 		    $currentstring .= '\vskip 1 mm \graphicspath{{/home/httpd/prtspool/}}\includegraphics[width='.$width_param.' mm]{'.$file.'} ';
                   1851: 		}
                   1852: 	    }
                   1853: 	} else {
                   1854: 	    #original image file doesn't exist so check the alt attribute
                   1855: 	    my $alt = 
                   1856: 		&Apache::lonxml::get_param('alt',$parstack,$safeeval,undef,1);
                   1857: 	    unless ($alt) {
                   1858: 		$alt=&Apache::lonmeta::alttag($Apache::lonxml::pwd[-1],$src);
                   1859: 	    }
                   1860: 
                   1861: 	    if ($alt) {
                   1862: 		$currentstring .= ' '.$alt.' ';
                   1863: 	    } else {
                   1864: 		#<allow> tag will care about replication 
1.59      sakharuk 1865: 	    }
                   1866: 	}
1.122     albertel 1867:     }
                   1868:     return $currentstring;
                   1869: }
                   1870: 
                   1871: sub end_img {
                   1872:     my ($target,$token) = @_;
                   1873:     my $currentstring = '';
                   1874:     if ($target eq 'web') {
                   1875: 	$currentstring = $token->[2];
                   1876:     } elsif ($target eq 'tex') {
                   1877: 	$currentstring = '';
                   1878:     }
                   1879:     return $currentstring;
                   1880: }
                   1881: 
                   1882: #-- <applet> tag
                   1883: sub start_applet {
                   1884:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
                   1885:     
                   1886:     my $code=&Apache::lonxml::get_param('code',$parstack,$safeeval,undef,1);
                   1887:     $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=$code;
                   1888:     
                   1889:     my $archive=&Apache::lonxml::get_param('archive',$parstack,$safeeval,
                   1890: 					   undef,1);
                   1891:     $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=$archive;
                   1892:     
                   1893:     my $currentstring = '';
                   1894:     if ($target eq 'web') {
                   1895: 	if ($ENV{'browser.appletsuppress'} ne 'on') {
                   1896: 	    $currentstring = $token->[4];
                   1897: 	} else {
                   1898: 	    my $alttag= &Apache::lonxml::get_param('alt',$parstack,
                   1899: 						   $safeeval,undef,1);
                   1900: 	    unless ($alttag) {
                   1901: 		$alttag=&Apache::lonmeta::alttag($Apache::lonxml::pwd[-1],
                   1902: 						 $code);
1.44      sakharuk 1903: 	    }
1.122     albertel 1904: 	    $currentstring='[APPLET: '.$alttag.']';
1.1       sakharuk 1905: 	}
1.122     albertel 1906:     } elsif ($target eq 'tex') {
                   1907: 	$currentstring = " \\begin{figure} ";
                   1908:     } 
                   1909:     return $currentstring;
                   1910: }
                   1911: 
                   1912: sub end_applet {
                   1913:     my ($target,$token) = @_;
                   1914:     my $currentstring = '';
                   1915:     if ($target eq 'web') {
                   1916: 	$currentstring = $token->[2];
                   1917:     } elsif ($target eq 'tex') {
                   1918: 	$currentstring = " \\end{figure}";
                   1919:     } 
                   1920:     return $currentstring;
                   1921: }
                   1922: 
                   1923: #-- <embed> tag
                   1924: sub start_embed {    
                   1925:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
                   1926:     my $src=&Apache::lonxml::get_param('src',$parstack,$safeeval,undef,1);
                   1927:     $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=$src;
                   1928:     my $currentstring = '';
                   1929:     if ($target eq 'web') {
                   1930: 	if ($ENV{'browser.embedsuppress'} ne 'on') {
                   1931: 	    $currentstring = $token->[4];
                   1932: 	} else {
                   1933: 	    my $alttag=&Apache::lonxml::get_param
                   1934: 		('alt',$parstack,$safeeval,undef,1);
                   1935: 	    unless ($alttag) {
                   1936: 		$alttag=&Apache::lonmeta::alttag($Apache::lonxml::pwd[-1],$src);
1.42      albertel 1937: 	    }
1.122     albertel 1938: 	    $currentstring='[EMBED: '.$alttag.']';
1.10      www      1939: 	}
1.122     albertel 1940:     } elsif ($target eq 'tex') {
                   1941: 	$currentstring = " \\begin{figure} ";  
                   1942:     } 
                   1943:     return $currentstring;
                   1944: }
                   1945: 
                   1946: sub end_embed {
                   1947:     my ($target,$token) = @_;
                   1948:     my $currentstring = '';
                   1949:     if ($target eq 'web') {
                   1950: 	$currentstring = $token->[2];     
                   1951:     } elsif ($target eq 'tex') {
                   1952: 	$currentstring = " \\end{figure}";  
                   1953:     } 
                   1954:     return $currentstring;
                   1955: }
                   1956: 
                   1957: #-- <param> tag
                   1958: sub start_param {
                   1959:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
                   1960:     if (&Apache::lonxml::get_param
                   1961: 	('name',$parstack,$safeeval,undef,1)=~/^cabbase$/i) {
                   1962: 	$Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=
                   1963: 	    &Apache::lonxml::get_param('value',$parstack,$safeeval,undef,1);
                   1964:     }   
                   1965:     $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=   
                   1966: 	&Apache::lonxml::get_param('src',$parstack,$safeeval,undef,1);
                   1967:     my $currentstring = '';
                   1968:     if ($target eq 'web') {
                   1969: 	$currentstring = $token->[4];     
                   1970:     } elsif ($target eq 'tex') {
                   1971: 	$currentstring = " \\begin{figure} ";  
                   1972:     } 
                   1973:     return $currentstring;
                   1974: }
                   1975: 
                   1976: sub end_param {
                   1977:     my ($target,$token) = @_;
                   1978:     my $currentstring = '';
                   1979:     if ($target eq 'web') {
                   1980: 	$currentstring = $token->[2];     
                   1981:     } elsif ($target eq 'tex') {
                   1982: 	$currentstring = " \\end{figure}";  
                   1983:     } 
                   1984:     return $currentstring;
                   1985: }
                   1986: 
                   1987: #-- <allow> tag
                   1988: sub start_allow {
                   1989:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
                   1990:     my $src = &Apache::lonxml::get_param('src',$parstack,$safeeval,undef,1);
                   1991:     $src=&Apache::lonnet::filelocation($Apache::lonxml::pwd[-1],$src);
                   1992:     $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=$src;
                   1993:     &image_replication($src);
                   1994:     my $result;
                   1995:     if ($target eq 'edit') {
                   1996: 	$result .=&Apache::edit::tag_start($target,$token);
                   1997: 	$result .=&Apache::edit::text_arg('File Spec:','src',$token,70);
                   1998: 	$result .=&Apache::edit::end_row();#.&Apache::edit::start_spanning_row();
                   1999:     } elsif ($target eq 'modified') {
                   2000: 	my $constructtag=&Apache::edit::get_new_args($token,$parstack,
                   2001: 						     $safeeval,'src');
                   2002: 	if ($constructtag) { $result = &Apache::edit::rebuild_tag($token); }
                   2003:     }
                   2004:     return $result;
                   2005: }
                   2006: 
                   2007: sub end_allow {
                   2008:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
                   2009:     if ( $target eq 'edit') { return (&Apache::edit::end_table()); }
                   2010:     return '';
                   2011: }
1.119     www      2012: 
1.122     albertel 2013: #-- Frames
                   2014: sub start_frameset {
                   2015:     my ($target,$token) = @_;
                   2016:     my $currentstring = '';
                   2017:     if ($target eq 'web') { 
                   2018: 	if (!$Apache::lonxml::registered) {
                   2019: 	    $currentstring.='<head>'.
                   2020: 		&Apache::lonmenu::registerurl(undef,$target).'</head>';
1.10      www      2021: 	}
1.122     albertel 2022: 	$currentstring .= $token->[4];
                   2023:     }
                   2024:     return $currentstring;
                   2025: }
                   2026: 
                   2027: sub end_frameset {
                   2028:     my ($target,$token) = @_;
                   2029:     my $currentstring = '';
                   2030:     if ($target eq 'web') {
                   2031: 	$currentstring = $token->[2];
                   2032:     }
                   2033:     return $currentstring;
                   2034: }
                   2035: 
                   2036: #-- <pre>
                   2037: sub start_pre {
                   2038:     my ($target,$token) = @_;
                   2039:     my $currentstring = '';
                   2040:     if ($target eq 'web') {
                   2041: 	$currentstring .= $token->[4];
                   2042:     } elsif ($target eq 'tex') {
                   2043: 	$currentstring .= '\begin{verbatim}';
                   2044:     } 
                   2045:     return $currentstring;
                   2046: }
                   2047: 
                   2048: sub end_pre {
                   2049:     my ($target,$token) = @_;
                   2050:     my $currentstring = '';
                   2051:     if ($target eq 'web') {
                   2052: 	$currentstring .= $token->[2];
                   2053:     } elsif ($target eq 'tex') {
                   2054: 	$currentstring .= '\end{verbatim}';
                   2055:     }
                   2056:     return $currentstring;
                   2057: }
                   2058: 
                   2059: #-- <insert>
                   2060: sub start_insert {
                   2061:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
                   2062:     my $currentstring = '';
                   2063:     if ($target eq 'web') {
                   2064: 	my $display = &Apache::lonxml::get_param('display',$parstack,$safeeval,undef,1);
                   2065: 	$currentstring .= '<b>'.$display.'</b>';;
                   2066:     }
                   2067:     return $currentstring;
                   2068: }
                   2069: 
                   2070: sub end_insert {
                   2071:     my ($target,$token) = @_;
                   2072:     my $currentstring = '';
                   2073:     if ($target eq 'web') {
                   2074: 	$currentstring .= '';
                   2075:     }
                   2076:     return $currentstring;
                   2077: }
                   2078: 
                   2079: #-- <externallink>
                   2080: sub start_externallink {
                   2081:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
                   2082:     my $currentstring = '';
                   2083:     if ($target eq 'web') {
                   2084: 	my $display = &Apache::lonxml::get_param('display',$parstack,$safeeval,undef,1);
                   2085: 	$currentstring .= '<b>'.$display.'</b>';;
                   2086:     }
                   2087:     return $currentstring;
                   2088: }
                   2089: 
                   2090: sub end_externallink {
                   2091:     my ($target,$token) = @_;
                   2092:     my $currentstring = '';
                   2093:     if ($target eq 'web') {
                   2094: 	$currentstring .= '';
                   2095:     }
                   2096:     return $currentstring;
                   2097: }
                   2098: 
                   2099: #-- <blankspace heigth="">
                   2100: sub start_blankspace {
                   2101:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
                   2102:     my $currentstring = '';
                   2103:     if ($target eq 'tex') {
                   2104: 	my $howmuch = &Apache::lonxml::get_param('heigth',$parstack,$safeeval,undef,1);
                   2105: 	$currentstring .= '\vskip '.$howmuch.' ';
                   2106:     }
                   2107:     return $currentstring;
                   2108: }
                   2109: 
                   2110: sub end_blankspace {
                   2111:     my ($target,$token) = @_;
                   2112:     my $currentstring = '';
                   2113:     if ($target eq 'tex') {
                   2114: 	$currentstring .= '';
                   2115:     }
                   2116:     return $currentstring;
                   2117: }
                   2118: 
                   2119: #-- <abbr> tag
                   2120: sub start_abbr {
                   2121:     my ($target,$token) = @_;
                   2122:     my $currentstring = '';
                   2123:     if ($target eq 'web') {
                   2124: 	$currentstring = $token->[4];     
                   2125:     } 
                   2126:     return $currentstring;
                   2127: }
                   2128: 
                   2129: sub end_abbr {
                   2130:     my ($target,$token) = @_;
                   2131:     my $currentstring = '';
                   2132:     if ($target eq 'web') {
                   2133: 	$currentstring = $token->[2];    
                   2134:     } 
                   2135:     return $currentstring;
                   2136: }
                   2137: 
                   2138: #-- <acronym> tag
                   2139: sub start_acronym {
                   2140:     my ($target,$token) = @_;
                   2141:     my $currentstring = '';
                   2142:     if ($target eq 'web') {
                   2143: 	$currentstring = $token->[4];     
                   2144:     } 
                   2145:     return $currentstring;
                   2146: }
                   2147: 
                   2148: sub end_acronym {
                   2149:     my ($target,$token) = @_;
                   2150:     my $currentstring = '';
                   2151:     if ($target eq 'web') {
                   2152: 	$currentstring = $token->[2];    
                   2153:     } 
                   2154:     return $currentstring;
                   2155: }
                   2156: 
                   2157: #-- <area> tag
                   2158: sub start_area {
                   2159:     my ($target,$token) = @_;
                   2160:     my $currentstring = '';
                   2161:     if ($target eq 'web') {
                   2162: 	$currentstring = $token->[4];     
                   2163:     } 
                   2164:     return $currentstring;
                   2165: }
                   2166: 
                   2167: sub end_area {
                   2168:     my ($target,$token) = @_;
                   2169:     my $currentstring = '';
                   2170:     if ($target eq 'web') {
                   2171: 	$currentstring = $token->[2];    
                   2172:     } 
                   2173:     return $currentstring;
                   2174: }
                   2175: 
                   2176: #-- <base> tag
                   2177: sub start_base {
                   2178:     my ($target,$token) = @_;
                   2179:     my $currentstring = '';
                   2180:     if ($target eq 'web') {
                   2181: 	$currentstring = $token->[4];     
                   2182:     } 
                   2183:     return $currentstring;
                   2184: }
                   2185: 
                   2186: sub end_base {
                   2187:     my ($target,$token) = @_;
                   2188:     my $currentstring = '';
                   2189:     if ($target eq 'web') {
                   2190: 	$currentstring = $token->[2];    
                   2191:     } 
                   2192:     return $currentstring;
                   2193: }
                   2194: 
                   2195: #-- <bdo> tag
                   2196: sub start_bdo {
                   2197:     my ($target,$token) = @_;
                   2198:     my $currentstring = '';
                   2199:     if ($target eq 'web') {
                   2200: 	$currentstring = $token->[4];     
                   2201:     } 
                   2202:     return $currentstring;
                   2203: }
                   2204: 
                   2205: sub end_bdo {
                   2206:     my ($target,$token) = @_;
                   2207:     my $currentstring = '';
                   2208:     if ($target eq 'web') {
                   2209: 	$currentstring = $token->[2];    
                   2210:     } 
                   2211:     return $currentstring;
                   2212: }
                   2213: 
                   2214: #-- <bgsound> tag
                   2215: sub start_bgsound {
                   2216:     my ($target,$token) = @_;
                   2217:     my $currentstring = '';
                   2218:     if ($target eq 'web') {
                   2219: 	$currentstring = $token->[4];     
                   2220:     } 
                   2221:     return $currentstring;
                   2222: }
                   2223: 
                   2224: sub end_bgsound {
                   2225:     my ($target,$token) = @_;
                   2226:     my $currentstring = '';
                   2227:     if ($target eq 'web') {
                   2228: 	$currentstring = $token->[2];    
                   2229:     } 
                   2230:     return $currentstring;
                   2231: }
                   2232: 
                   2233: #-- <blink> tag
                   2234: sub start_blink {
                   2235:     my ($target,$token) = @_;
                   2236:     my $currentstring = '';
                   2237:     if ($target eq 'web') {
                   2238: 	$currentstring = $token->[4];     
                   2239:     } 
                   2240:     return $currentstring;
                   2241: }
                   2242: 
                   2243: sub end_blink {
                   2244:     my ($target,$token) = @_;
                   2245:     my $currentstring = '';
                   2246:     if ($target eq 'web') {
                   2247: 	$currentstring = $token->[2];    
                   2248:     } 
                   2249:     return $currentstring;
                   2250: }
                   2251: 
                   2252: #-- <blockquote> tag
                   2253: sub start_blockquote {
                   2254:     my ($target,$token) = @_;
                   2255:     my $currentstring = '';
                   2256:     if ($target eq 'web') {
                   2257: 	$currentstring = $token->[4];     
                   2258:     } 
                   2259:     return $currentstring;
                   2260: }
                   2261: 
                   2262: sub end_blockquote {
                   2263:     my ($target,$token) = @_;
                   2264:     my $currentstring = '';
                   2265:     if ($target eq 'web') {
                   2266: 	$currentstring = $token->[2];    
                   2267:     } 
                   2268:     return $currentstring;
                   2269: }
                   2270: 
                   2271: #-- <button> tag
                   2272: sub start_button {
                   2273:     my ($target,$token) = @_;
                   2274:     my $currentstring = '';
                   2275:     if ($target eq 'web') {
                   2276: 	$currentstring = $token->[4];     
                   2277:     } 
                   2278:     return $currentstring;
                   2279: }
                   2280: 
                   2281: sub end_button {
                   2282:     my ($target,$token) = @_;
                   2283:     my $currentstring = '';
                   2284:     if ($target eq 'web') {
                   2285: 	$currentstring = $token->[2];    
                   2286:     } 
                   2287:     return $currentstring;
                   2288: }
                   2289: 
                   2290: #-- <caption> tag
                   2291: sub start_caption {
                   2292:     my ($target,$token) = @_;
                   2293:     my $currentstring = '';
                   2294:     if ($target eq 'web') {
                   2295: 	$currentstring = $token->[4];     
                   2296:     } 
                   2297:     return $currentstring;
                   2298: }
                   2299: 
                   2300: sub end_caption {
                   2301:     my ($target,$token) = @_;
                   2302:     my $currentstring = '';
                   2303:     if ($target eq 'web') {
                   2304: 	$currentstring = $token->[2];    
                   2305:     } 
                   2306:     return $currentstring;
                   2307: }
                   2308: 
                   2309: #-- <col> tag
                   2310: sub start_col {
                   2311:     my ($target,$token) = @_;
                   2312:     my $currentstring = '';
                   2313:     if ($target eq 'web') {
                   2314: 	$currentstring = $token->[4];     
                   2315:     } 
                   2316:     return $currentstring;
                   2317: }
                   2318: 
                   2319: sub end_col {
                   2320:     my ($target,$token) = @_;
                   2321:     my $currentstring = '';
                   2322:     if ($target eq 'web') {
                   2323: 	$currentstring = $token->[2];    
                   2324:     } 
                   2325:     return $currentstring;
                   2326: }
                   2327: 
                   2328: #-- <colgroup> tag
                   2329: sub start_colgroup {
                   2330:     my ($target,$token) = @_;
                   2331:     my $currentstring = '';
                   2332:     if ($target eq 'web') {
                   2333: 	$currentstring = $token->[4];     
                   2334:     } 
                   2335:     return $currentstring;
                   2336: }
                   2337: 
                   2338: sub end_colgroup {
                   2339:     my ($target,$token) = @_;
                   2340:     my $currentstring = '';
                   2341:     if ($target eq 'web') {
                   2342: 	$currentstring = $token->[2];    
                   2343:     } 
                   2344:     return $currentstring;
                   2345: }
                   2346: 
                   2347: #-- <del> tag
                   2348: sub start_del {
                   2349:     my ($target,$token) = @_;
                   2350:     my $currentstring = '';
                   2351:     if ($target eq 'web') {
                   2352: 	$currentstring = $token->[4];     
                   2353:     } 
                   2354:     return $currentstring;
                   2355: }
                   2356: 
                   2357: sub end_del {
                   2358:     my ($target,$token) = @_;
                   2359:     my $currentstring = '';
                   2360:     if ($target eq 'web') {
                   2361: 	$currentstring = $token->[2];    
                   2362:     } 
                   2363:     return $currentstring;
                   2364: }
                   2365: 
                   2366: #-- <fieldset> tag
                   2367: sub start_fieldset {
                   2368:     my ($target,$token) = @_;
                   2369:     my $currentstring = '';
                   2370:     if ($target eq 'web') {
                   2371: 	$currentstring = $token->[4];     
                   2372:     } 
                   2373:     return $currentstring;
                   2374: }
                   2375: 
                   2376: sub end_fieldset {
                   2377:     my ($target,$token) = @_;
                   2378:     my $currentstring = '';
                   2379:     if ($target eq 'web') {
                   2380: 	$currentstring = $token->[2];    
                   2381:     } 
                   2382:     return $currentstring;
                   2383: }
                   2384: 
                   2385: #-- <frame> tag
                   2386: sub start_frame {
                   2387:     my ($target,$token) = @_;
                   2388:     my $currentstring = '';
                   2389:     if ($target eq 'web') {
                   2390: 	$currentstring = $token->[4];     
                   2391:     } 
                   2392:     return $currentstring;
                   2393: }
                   2394: 
                   2395: sub end_frame {
                   2396:     my ($target,$token) = @_;
                   2397:     my $currentstring = '';
                   2398:     if ($target eq 'web') {
                   2399: 	$currentstring = $token->[2];    
                   2400:     } 
                   2401:     return $currentstring;
                   2402: }
                   2403: 
                   2404: #-- <iframe> tag
                   2405: sub start_iframe {
                   2406:     my ($target,$token) = @_;
                   2407:     my $currentstring = '';
                   2408:     if ($target eq 'web') {
                   2409: 	$currentstring = $token->[4];     
                   2410:     } 
                   2411:     return $currentstring;
                   2412: }
                   2413: 
                   2414: sub end_iframe {
                   2415:     my ($target,$token) = @_;
                   2416:     my $currentstring = '';
                   2417:     if ($target eq 'web') {
                   2418: 	$currentstring = $token->[2];    
                   2419:     } 
                   2420:     return $currentstring;
                   2421: }
                   2422: 
                   2423: #-- <ins> tag
                   2424: sub start_ins {
                   2425:     my ($target,$token) = @_;
                   2426:     my $currentstring = '';
                   2427:     if ($target eq 'web') {
                   2428: 	$currentstring = $token->[4];     
                   2429:     } 
                   2430:     return $currentstring;
                   2431: }
                   2432: 
                   2433: sub end_ins {
                   2434:     my ($target,$token) = @_;
                   2435:     my $currentstring = '';
                   2436:     if ($target eq 'web') {
                   2437: 	$currentstring = $token->[2];    
                   2438:     } 
                   2439:     return $currentstring;
                   2440: }
                   2441: 
                   2442: #-- <isindex> tag
                   2443: sub start_isindex {
                   2444:     my ($target,$token) = @_;
                   2445:     my $currentstring = '';
                   2446:     if ($target eq 'web') {
                   2447: 	$currentstring = $token->[4];     
                   2448:     } 
                   2449:     return $currentstring;
                   2450: }
                   2451: 
                   2452: sub end_isindex {
                   2453:     my ($target,$token) = @_;
                   2454:     my $currentstring = '';
                   2455:     if ($target eq 'web') {
                   2456: 	$currentstring = $token->[2];    
                   2457:     } 
                   2458:     return $currentstring;
                   2459: }
                   2460: 
                   2461: #-- <keygen> tag
                   2462: sub start_keygen {
                   2463:     my ($target,$token) = @_;
                   2464:     my $currentstring = '';
                   2465:     if ($target eq 'web') {
                   2466: 	$currentstring = $token->[4];     
                   2467:     } 
                   2468:     return $currentstring;
                   2469: }
                   2470: 
                   2471: sub end_keygen {
                   2472:     my ($target,$token) = @_;
                   2473:     my $currentstring = '';
                   2474:     if ($target eq 'web') {
                   2475: 	$currentstring = $token->[2];    
                   2476:     } 
                   2477:     return $currentstring;
                   2478: }
                   2479: 
                   2480: #-- <label> tag
                   2481: sub start_label {
                   2482:     my ($target,$token) = @_;
                   2483:     my $currentstring = '';
                   2484:     if ($target eq 'web') {
                   2485: 	$currentstring = $token->[4];     
                   2486:     } 
                   2487:     return $currentstring;
                   2488: }
                   2489: 
                   2490: sub end_label {
                   2491:     my ($target,$token) = @_;
                   2492:     my $currentstring = '';
                   2493:     if ($target eq 'web') {
                   2494: 	$currentstring = $token->[2];    
                   2495:     } 
                   2496:     return $currentstring;
                   2497: }
                   2498: 
                   2499: #-- <layer> tag
                   2500: sub start_layer {
                   2501:     my ($target,$token) = @_;
                   2502:     my $currentstring = '';
                   2503:     if ($target eq 'web') {
                   2504: 	$currentstring = $token->[4];     
                   2505:     } 
                   2506:     return $currentstring;
                   2507: }
                   2508: 
                   2509: sub end_layer {
                   2510:     my ($target,$token) = @_;
                   2511:     my $currentstring = '';
                   2512:     if ($target eq 'web') {
                   2513: 	$currentstring = $token->[2];    
                   2514:     } 
                   2515:     return $currentstring;
                   2516: }
                   2517: 
                   2518: #-- <legend> tag
                   2519: sub start_legend {
                   2520:     my ($target,$token) = @_;
                   2521:     my $currentstring = '';
                   2522:     if ($target eq 'web') {
                   2523: 	$currentstring = $token->[4];     
                   2524:     } 
                   2525:     return $currentstring;
                   2526: }
                   2527: 
                   2528: sub end_legend {
                   2529:     my ($target,$token) = @_;
                   2530:     my $currentstring = '';
                   2531:     if ($target eq 'web') {
                   2532: 	$currentstring = $token->[2];    
                   2533:     } 
                   2534:     return $currentstring;
                   2535: }
                   2536: 
                   2537: #-- <link> tag
                   2538: sub start_link {
                   2539:     my ($target,$token) = @_;
                   2540:     my $currentstring = '';
                   2541:     if ($target eq 'web') {
                   2542: 	$currentstring = $token->[4];     
                   2543:     } 
                   2544:     return $currentstring;
                   2545: }
                   2546: 
                   2547: sub end_link {
                   2548:     my ($target,$token) = @_;
                   2549:     my $currentstring = '';
                   2550:     if ($target eq 'web') {
                   2551: 	$currentstring = $token->[2];    
                   2552:     } 
                   2553:     return $currentstring;
                   2554: }
                   2555: 
                   2556: #-- <marquee> tag
                   2557: sub start_marquee {
                   2558:     my ($target,$token) = @_;
                   2559:     my $currentstring = '';
                   2560:     if ($target eq 'web') {
                   2561: 	$currentstring = $token->[4];     
                   2562:     } 
                   2563:     return $currentstring;
                   2564: }
                   2565: 
                   2566: sub end_marquee {
                   2567:     my ($target,$token) = @_;
                   2568:     my $currentstring = '';
                   2569:     if ($target eq 'web') {
                   2570: 	$currentstring = $token->[2];    
                   2571:     } 
                   2572:     return $currentstring;
                   2573: }
                   2574: 
                   2575: #-- <malticol> tag
                   2576: sub start_malticol {
                   2577:     my ($target,$token) = @_;
                   2578:     my $currentstring = '';
                   2579:     if ($target eq 'web') {
                   2580: 	$currentstring = $token->[4];     
                   2581:     } 
                   2582:     return $currentstring;
                   2583: }
                   2584: 
                   2585: sub end_malticol {
                   2586:     my ($target,$token) = @_;
                   2587:     my $currentstring = '';
                   2588:     if ($target eq 'web') {
                   2589: 	$currentstring = $token->[2];    
                   2590:     } 
                   2591:     return $currentstring;
                   2592: }
                   2593: 
                   2594: #-- <nobr> tag
                   2595: sub start_nobr {
                   2596:     my ($target,$token) = @_;
                   2597:     my $currentstring = '';
                   2598:     if ($target eq 'web') {
                   2599: 	$currentstring = $token->[4];     
                   2600:     } 
                   2601:     return $currentstring;
                   2602: }
                   2603: 
                   2604: sub end_nobr {
                   2605:     my ($target,$token) = @_;
                   2606:     my $currentstring = '';
                   2607:     if ($target eq 'web') {
                   2608: 	$currentstring = $token->[2];    
                   2609:     } 
                   2610:     return $currentstring;
                   2611: }
                   2612: 
                   2613: #-- <noembed> tag
                   2614: sub start_noembed {
                   2615:     my ($target,$token) = @_;
                   2616:     my $currentstring = '';
                   2617:     if ($target eq 'web') {
                   2618: 	$currentstring = $token->[4];     
                   2619:     } 
                   2620:     return $currentstring;
                   2621: }
                   2622: 
                   2623: sub end_noembed {
                   2624:     my ($target,$token) = @_;
                   2625:     my $currentstring = '';
                   2626:     if ($target eq 'web') {
                   2627: 	$currentstring = $token->[2];    
                   2628:     } 
                   2629:     return $currentstring;
                   2630: }
                   2631: 
                   2632: #-- <noframes> tag
                   2633: sub start_noframes {
                   2634:     my ($target,$token) = @_;
                   2635:     my $currentstring = '';
                   2636:     if ($target eq 'web') {
                   2637: 	$currentstring = $token->[4];     
                   2638:     } 
                   2639:     return $currentstring;
                   2640: }
                   2641: 
                   2642: sub end_noframes {
                   2643:     my ($target,$token) = @_;
                   2644:     my $currentstring = '';
                   2645:     if ($target eq 'web') {
                   2646: 	$currentstring = $token->[2];    
                   2647:     } 
                   2648:     return $currentstring;
                   2649: }
                   2650: 
                   2651: #-- <nolayer> tag
                   2652: sub start_nolayer {
                   2653:     my ($target,$token) = @_;
                   2654:     my $currentstring = '';
                   2655:     if ($target eq 'web') {
                   2656: 	$currentstring = $token->[4];     
                   2657:     } 
                   2658:     return $currentstring;
                   2659: }
                   2660: 
                   2661: sub end_nolayer {
                   2662:     my ($target,$token) = @_;
                   2663:     my $currentstring = '';
                   2664:     if ($target eq 'web') {
                   2665: 	$currentstring = $token->[2];    
                   2666:     } 
                   2667:     return $currentstring;
                   2668: }
                   2669: 
                   2670: #-- <noscript> tag
                   2671: sub start_noscript {
                   2672:     my ($target,$token) = @_;
                   2673:     my $currentstring = '';
                   2674:     if ($target eq 'web') {
                   2675: 	$currentstring = $token->[4];     
                   2676:     } 
                   2677:     return $currentstring;
                   2678: }
                   2679: 
                   2680: sub end_noscript {
                   2681:     my ($target,$token) = @_;
                   2682:     my $currentstring = '';
                   2683:     if ($target eq 'web') {
                   2684: 	$currentstring = $token->[2];    
                   2685:     } 
                   2686:     return $currentstring;
                   2687: }
                   2688: 
                   2689: #-- <object> tag
                   2690: sub start_object {
                   2691:     my ($target,$token) = @_;
                   2692:     my $currentstring = '';
                   2693:     if ($target eq 'web') {
                   2694: 	$currentstring = $token->[4];     
                   2695:     } 
                   2696:     return $currentstring;
                   2697: }
                   2698: 
                   2699: sub end_object {
                   2700:     my ($target,$token) = @_;
                   2701:     my $currentstring = '';
                   2702:     if ($target eq 'web') {
                   2703: 	$currentstring = $token->[2];    
                   2704:     } 
                   2705:     return $currentstring;
                   2706: }
                   2707: 
                   2708: #-- <optgroup> tag
                   2709: sub start_optgroup {
                   2710:     my ($target,$token) = @_;
                   2711:     my $currentstring = '';
                   2712:     if ($target eq 'web') {
                   2713: 	$currentstring = $token->[4];     
                   2714:     } 
                   2715:     return $currentstring;
                   2716: }
                   2717: 
                   2718: sub end_optgroup {
                   2719:     my ($target,$token) = @_;
                   2720:     my $currentstring = '';
                   2721:     if ($target eq 'web') {
                   2722: 	$currentstring = $token->[2];    
                   2723:     } 
                   2724:     return $currentstring;
                   2725: }
                   2726: 
                   2727: #-- <samp> tag
                   2728: sub start_samp {
                   2729:     my ($target,$token) = @_;
                   2730:     my $currentstring = '';
                   2731:     if ($target eq 'web') {
                   2732: 	$currentstring = $token->[4];     
                   2733:     } 
                   2734:     return $currentstring;
                   2735: }
                   2736: 
                   2737: sub end_samp {
                   2738:     my ($target,$token) = @_;
                   2739:     my $currentstring = '';
                   2740:     if ($target eq 'web') {
                   2741: 	$currentstring = $token->[2];    
                   2742:     } 
                   2743:     return $currentstring;
                   2744: }
                   2745: 
                   2746: #-- <server> tag
                   2747: sub start_server {
                   2748:     my ($target,$token) = @_;
                   2749:     my $currentstring = '';
                   2750:     if ($target eq 'web') {
                   2751: 	$currentstring = $token->[4];     
                   2752:     } 
                   2753:     return $currentstring;
                   2754: }
                   2755: 
                   2756: sub end_server {
                   2757:     my ($target,$token) = @_;
                   2758:     my $currentstring = '';
                   2759:     if ($target eq 'web') {
                   2760: 	$currentstring = $token->[2];    
                   2761:     } 
                   2762:     return $currentstring;
                   2763: }
                   2764: 
                   2765: #-- <spacer> tag
                   2766: sub start_spacer {
                   2767:     my ($target,$token) = @_;
                   2768:     my $currentstring = '';
                   2769:     if ($target eq 'web') {
                   2770: 	$currentstring = $token->[4];     
                   2771:     } 
                   2772:     return $currentstring;
                   2773: }
                   2774: 
                   2775: sub end_spacer {
                   2776:     my ($target,$token) = @_;
                   2777:     my $currentstring = '';
                   2778:     if ($target eq 'web') {
                   2779: 	$currentstring = $token->[2];    
                   2780:     } 
                   2781:     return $currentstring;
                   2782: }
                   2783: 
                   2784: #-- <span> tag
                   2785: sub start_span {
                   2786:     my ($target,$token) = @_;
                   2787:     my $currentstring = '';
                   2788:     if ($target eq 'web') {
                   2789: 	$currentstring = $token->[4];     
                   2790:     } 
                   2791:     return $currentstring;
                   2792: }
                   2793: 
                   2794: sub end_span {
                   2795:     my ($target,$token) = @_;
                   2796:     my $currentstring = '';
                   2797:     if ($target eq 'web') {
                   2798: 	$currentstring = $token->[2];    
                   2799:     } 
                   2800:     return $currentstring;
                   2801: }
                   2802: 
                   2803: #-- <tbody> tag
                   2804: sub start_tbody {
                   2805:     my ($target,$token) = @_;
                   2806:     my $currentstring = '';
                   2807:     if ($target eq 'web') {
                   2808: 	$currentstring = $token->[4];     
                   2809:     } 
                   2810:     return $currentstring;
                   2811: }
                   2812: 
                   2813: sub end_tbody {
                   2814:     my ($target,$token) = @_;
                   2815:     my $currentstring = '';
                   2816:     if ($target eq 'web') {
                   2817: 	$currentstring = $token->[2];    
                   2818:     } 
                   2819:     return $currentstring;
                   2820: }
                   2821: 
                   2822: #-- <tfoot> tag
                   2823: sub start_tfoot {
                   2824:     my ($target,$token) = @_;
                   2825:     my $currentstring = '';
                   2826:     if ($target eq 'web') {
                   2827: 	$currentstring = $token->[4];     
                   2828:     } 
                   2829:     return $currentstring;
                   2830: }
                   2831: 
                   2832: sub end_tfoot {
                   2833:     my ($target,$token) = @_;
                   2834:     my $currentstring = '';
                   2835:     if ($target eq 'web') {
                   2836: 	$currentstring = $token->[2];    
                   2837:     } 
                   2838:     return $currentstring;
                   2839: }
                   2840: 
                   2841: #-- <thead> tag
                   2842: sub start_thead {
                   2843:     my ($target,$token) = @_;
                   2844:     my $currentstring = '';
                   2845:     if ($target eq 'web') {
                   2846: 	$currentstring = $token->[4];     
                   2847:     } 
                   2848:     return $currentstring;
                   2849: }
1.10      www      2850: 
1.122     albertel 2851: sub end_thead {
                   2852:     my ($target,$token) = @_;
                   2853:     my $currentstring = '';
                   2854:     if ($target eq 'web') {
                   2855: 	$currentstring = $token->[2];    
                   2856:     } 
                   2857:     return $currentstring;
                   2858: }
1.119     www      2859: 
1.122     albertel 2860: #-- <var> tag
                   2861: sub start_var {
1.44      sakharuk 2862:     my ($target,$token) = @_;
                   2863:     my $currentstring = '';
                   2864:     if ($target eq 'web') {
1.122     albertel 2865: 	$currentstring = $token->[4];     
1.44      sakharuk 2866:     } 
                   2867:     return $currentstring;
                   2868: }
1.10      www      2869: 
1.122     albertel 2870: sub end_var {
                   2871:     my ($target,$token) = @_;
1.44      sakharuk 2872:     my $currentstring = '';
                   2873:     if ($target eq 'web') {
1.122     albertel 2874: 	$currentstring = $token->[2];    
1.44      sakharuk 2875:     } 
                   2876:     return $currentstring;
                   2877: }
1.119     www      2878: 
1.122     albertel 2879: #-- <wbr> tag
                   2880: sub start_wbr {
                   2881:     my ($target,$token) = @_;
                   2882:     my $currentstring = '';
                   2883:     if ($target eq 'web') {
                   2884: 	$currentstring = $token->[4];     
                   2885:     } 
                   2886:     return $currentstring;
1.98      albertel 2887: }
                   2888: 
1.122     albertel 2889: sub end_wbr {
                   2890:     my ($target,$token) = @_;
                   2891:     my $currentstring = '';
                   2892:     if ($target eq 'web') {
                   2893: 	$currentstring = $token->[2];    
                   2894:     } 
                   2895:     return $currentstring;
1.98      albertel 2896: }
1.94      sakharuk 2897: 
                   2898: sub image_replication {
                   2899:     my $src = shift;
1.118     www      2900:     if (not -e $src) {
1.94      sakharuk 2901: 	#replicates image itself
1.118     www      2902: 	&Apache::lonnet::repcopy($src);
1.94      sakharuk 2903: 	#replicates eps or ps 
                   2904: 	my $newsrc = $src;
1.118     www      2905: 	$newsrc =~ s/\.(gif|jpg|jpeg|png)$/.eps/i;
                   2906: 	if (not -e $newsrc) {
1.122     albertel 2907: 	    if (&Apache::lonnet::repcopy($newsrc) ne 'OK') {
                   2908: 		$newsrc =~ s/\.eps$/\.ps/;
                   2909: 		&Apache::lonnet::repcopy($newsrc);
                   2910: 	    }
1.94      sakharuk 2911: 	}
                   2912:     }
                   2913:     return '';
                   2914: }
                   2915: 
1.1       sakharuk 2916: 1;
                   2917: __END__

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