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