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