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