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