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