Annotation of loncom/xml/londefdef.pm, revision 1.31
1.1 sakharuk 1: # The LearningOnline Network with CAPA
2: # Tags Default Definition Module
3: #
4: # last modified 06/26/00 by Alexander Sakharuk
1.28 www 5: # 11/6,11/30,02/01/01,5/4 Gerd Kortemeyer
1.1 sakharuk 6:
1.2 albertel 7: package Apache::londefdef;
1.1 sakharuk 8:
9: use strict;
1.3 sakharuk 10: use Apache::lonxml;
1.1 sakharuk 11:
1.3 sakharuk 12: sub BEGIN {
1.15 sakharuk 13:
1.31 ! albertel 14: &Apache::lonxml::register('Apache::londefdef',('m','html','head','map','select','option','input','textarea','form','meta','title','body','center','b','strong','table','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','tr','td','allow','frameset'));
1.15 sakharuk 15:
1.3 sakharuk 16: }
1.1 sakharuk 17:
18: #===================================================================== TAG SUBROUTINES
1.8 sakharuk 19: #-- <output>
1.21 albertel 20: sub start_output {
21: my ($target) = @_;
1.22 albertel 22: if ($target eq 'meta') { $Apache::lonxml::metamode--; }
1.21 albertel 23: return '';
24: }
25: sub end_output {
26: my ($target) = @_;
1.22 albertel 27: if ($target eq 'meta') { $Apache::lonxml::metamode++; }
1.21 albertel 28: return '';
29: }
1.4 sakharuk 30: #-- <m> tag
1.1 sakharuk 31: sub start_m {
1.30 albertel 32: my ($target,$token,$tagstack,$parstack,$parser) = @_;
1.1 sakharuk 33: my $currentstring = '';
34: if ($target eq 'web') {
1.5 sakharuk 35: my $inside = &Apache::lonxml::get_all_text("/m",$$parser[$#$parser]);
36: $inside ='\\documentstyle{article}'.$inside;
37: # &Apache::lonxml::debug($inside);
38: $currentstring = &Apache::lontexconvert::converted(\$inside);
39: # &Apache::lonxml::debug($currentstring);
40:
1.1 sakharuk 41: } elsif ($target eq 'tex') {
1.7 sakharuk 42: $currentstring = "";
1.1 sakharuk 43: }
44: return $currentstring;
45: }
46: sub end_m {
47: my ($target,$token) = @_;
48: my $currentstring = '';
49: if ($target eq 'web') {
50: } elsif ($target eq 'tex') {
1.7 sakharuk 51: $currentstring = "";
1.6 sakharuk 52: } elsif ($target eq 'meta') {
1.1 sakharuk 53: }
54: return $currentstring;
55: }
56: #-------------------------------------------------------------------------- <html> tag
57: sub start_html {
58: my ($target,$token) = @_;
59: my $currentstring = '';
60: if ($target eq 'web') {
1.29 www 61: $currentstring = &Apache::lonxml::xmlbegin().
62: &Apache::lonxml::fontsettings();
1.1 sakharuk 63: }
64: return $currentstring;
65: }
66: sub end_html {
67: my ($target,$token) = @_;
68: my $currentstring = '';
69: if ($target eq 'web') {
1.28 www 70: $currentstring = &Apache::lonxml::xmlend();
1.1 sakharuk 71: }
72: return $currentstring;
73: }
74: #-------------------------------------------------------------------------- <head> tag
75: sub start_head {
76: my ($target,$token) = @_;
77: my $currentstring = '';
78: if ($target eq 'web') {
79: $currentstring = $token->[4];
80: }
81: return $currentstring;
82: }
83: sub end_head {
84: my ($target,$token) = @_;
85: my $currentstring = '';
86: if ($target eq 'web') {
1.29 www 87: $currentstring = &Apache::lonxml::registerurl().
88: $token->[2];
1.1 sakharuk 89: }
90: return $currentstring;
91: }
92: #--------------------------------------------------------------------------- <map> tag
93: sub start_map {
94: my ($target,$token) = @_;
95: my $currentstring = '';
96: if ($target eq 'web') {
97: $currentstring = $token->[4];
98: }
99: return $currentstring;
100: }
101: sub end_map {
102: my ($target,$token) = @_;
103: my $currentstring = '';
104: if ($target eq 'web') {
105: $currentstring = $token->[2];
106: }
107: return $currentstring;
108: }
1.19 www 109:
1.1 sakharuk 110: #------------------------------------------------------------------------ <select> tag
111: sub start_select {
112: my ($target,$token) = @_;
113: my $currentstring = '';
114: if ($target eq 'web') {
115: $currentstring = $token->[4];
116: }
117: return $currentstring;
118: }
119: sub end_select {
120: my ($target,$token) = @_;
121: my $currentstring = '';
122: if ($target eq 'web') {
123: $currentstring = $token->[2];
124: }
125: return $currentstring;
126: }
127: #------------------------------------------------------------------------ <option> tag
128: sub start_option {
129: my ($target,$token) = @_;
130: my $currentstring = '';
131: if ($target eq 'web') {
132: $currentstring = $token->[4];
133: }
134: return $currentstring;
135: }
136: sub end_option {
137: my ($target,$token) = @_;
138: my $currentstring = '';
139: if ($target eq 'web') {
140: $currentstring = $token->[2];
141: }
142: return $currentstring;
143: }
144: #------------------------------------------------------------------------- <input> tag
145: sub start_input {
146: my ($target,$token) = @_;
147: my $currentstring = '';
148: if ($target eq 'web') {
149: $currentstring = $token->[4];
150: }
151: return $currentstring;
152: }
153: sub end_input {
154: my ($target,$token) = @_;
155: my $currentstring = '';
156: if ($target eq 'web') {
157: $currentstring = $token->[2];
158: }
159: return $currentstring;
160: }
161: #---------------------------------------------------------------------- <textarea> tag
162: sub start_textarea {
163: my ($target,$token) = @_;
164: my $currentstring = '';
165: if ($target eq 'web') {
166: $currentstring = $token->[4];
167: }
168: return $currentstring;
169: }
170: sub end_textarea {
171: my ($target,$token) = @_;
172: my $currentstring = '';
173: if ($target eq 'web') {
174: $currentstring = $token->[2];
175: }
176: return $currentstring;
177: }
178: #-------------------------------------------------------------------------- <form> tag
179: sub start_form {
180: my ($target,$token) = @_;
181: my $currentstring = '';
182: if ($target eq 'web') {
183: $currentstring = $token->[4];
184: }
185: return $currentstring;
186: }
187: sub end_form {
188: my ($target,$token) = @_;
189: my $currentstring = '';
190: if ($target eq 'web') {
191: $currentstring = $token->[2];
192: }
193: return $currentstring;
194: }
195: #------------------------------------------------------------------------- <title> tag
196: sub start_title {
197: my ($target,$token) = @_;
198: my $currentstring = '';
199: if ($target eq 'web') {
200: $currentstring = $token->[4];
201: }
1.13 www 202: if ($target eq 'meta') {
203: $currentstring='<title>';
204: &start_output();
205: }
1.1 sakharuk 206: return $currentstring;
207: }
208: sub end_title {
209: my ($target,$token) = @_;
210: my $currentstring = '';
211: if ($target eq 'web') {
212: $currentstring = $token->[2];
1.13 www 213: }
214: if ($target eq 'meta') {
215: &end_output();
216: $currentstring='</title>';
1.1 sakharuk 217: }
218: return $currentstring;
219: }
220: #-------------------------------------------------------------------------- <meta> tag
221: sub start_meta {
1.30 albertel 222: my ($target,$token,$tagstack,$parstack,$parser) = @_;
1.1 sakharuk 223: my $currentstring = '';
224: if ($target eq 'web') {
1.25 albertel 225: my $args='';
226: if ( $#$parstack > -1 ) { $args=$$parstack[$#$parstack]; }
227: if ($args eq '') {
228: &Apache::lonxml::get_all_text("/meta",$$parser[$#$parser]);
229: } else {
230: $currentstring = $token->[4];
231: }
1.12 www 232: }
233: if ($target eq 'meta') {
234: unless ($token->[2]->{'http-equiv'}) {
235: my $name=$token->[2]->{'name'};
236: $name=~tr/A-Z/a-z/;
237: $name=~s/\s/\_/g;
238: if ($name) {
239: $currentstring='<'.$name.'>'.
240: $token->[2]->{'content'}.
241: '</'.$name.'>';
242: }
243: }
1.1 sakharuk 244: }
245: return $currentstring;
246: }
1.26 albertel 247: sub end_meta {
1.30 albertel 248: my ($target,$token,$tagstack,$parstack,$parser) = @_;
1.26 albertel 249: my $currentstring = '';
250: if ($target eq 'web') {
251: my $args='';
252: if ( $#$parstack > -1 ) { $args=$$parstack[$#$parstack]; }
253: if ($args ne '') {
254: $currentstring = $token->[4];
255: }
256: }
257: return $currentstring;
258: }
1.1 sakharuk 259: #-------------------------------------------------------------------------- <body> tag
260: sub start_body {
261: my ($target,$token) = @_;
262: my $currentstring = '';
263: if ($target eq 'web') {
1.31 ! albertel 264: if (!$Apache::lonxml::registered) {
! 265: $currentstring.='<head>'.&Apache::lonxml::registerurl().'</head>';
! 266: }
! 267: $token->[2]->{'onLoad'}.=&Apache::lonxml::loadevents();
! 268: $token->[2]->{'onUnload'}.=&Apache::lonxml::unloadevents();
! 269:
! 270: $currentstring .= '<'.$token->[1];
! 271: map {
! 272: $currentstring.=' '.$_.'="'.$token->[2]->{$_}.'"';
! 273: } keys %{$token->[2]};
! 274: $currentstring.='>';
1.28 www 275: } elsif ($target eq 'tex') {
1.1 sakharuk 276: $currentstring = " \\begin{document} ";
277: }
278: return $currentstring;
279: }
280: sub end_body {
281: my ($target,$token) = @_;
282: my $currentstring = '';
283: if ($target eq 'web') {
284: $currentstring = $token->[2];
285: } elsif ($target eq 'tex') {
286: $currentstring = " \\end{document}";
287: }
288: return $currentstring;
289: }
290: #------------------------------------------------------------------------ <center> tag
291: sub start_center {
292: my ($target,$token) = @_;
293: my $currentstring = '';
294: if ($target eq 'web') {
295: $currentstring = $token->[4];
296: } elsif ($target eq 'tex') {
297: $currentstring = " \\begin{center} ";
1.18 sakharuk 298: } elsif ($target eq 'latexsource') {
299: $currentstring = " \\begin{center} ";
1.1 sakharuk 300: }
301: return $currentstring;
302: }
303: sub end_center {
304: my ($target,$token) = @_;
305: my $currentstring = '';
306: if ($target eq 'web') {
307: $currentstring = $token->[2];
308: } elsif ($target eq 'tex') {
309: $currentstring = " \\end{center}";
1.18 sakharuk 310: } elsif ($target eq 'latexsource') {
311: $currentstring = " \\end{center}";
1.1 sakharuk 312: }
313: return $currentstring;
314: }
315: #----------------------------------------------------------------------------- <b> tag
316: sub start_b {
317: my ($target,$token) = @_;
318: my $currentstring = '';
319: if ($target eq 'web') {
320: $currentstring = $token->[4];
321: } elsif ($target eq 'tex') {
1.18 sakharuk 322: $currentstring = " \\textbf{";
323: } elsif ($target eq 'latexsource') {
324: $currentstring = " \\textbf{";
1.1 sakharuk 325: }
326: return $currentstring;
327: }
328: sub end_b {
329: my ($target,$token) = @_;
330: my $currentstring = '';
331: if ($target eq 'web') {
332: $currentstring = $token->[2];
333: } elsif ($target eq 'tex') {
334: $currentstring = "}";
1.18 sakharuk 335: } elsif ($target eq 'latexsource') {
336: $currentstring = "}";
1.1 sakharuk 337: }
338: return $currentstring;
339: }
340: #------------------------------------------------------------------------ <strong> tag
341: sub start_strong {
342: my ($target,$token) = @_;
343: my $currentstring = '';
344: if ($target eq 'web') {
345: $currentstring = $token->[4];
346: } elsif ($target eq 'tex') {
1.18 sakharuk 347: $currentstring = " \\textbf{";
348: } elsif ($target eq 'latexsource') {
349: $currentstring = " \\textbf{";
1.1 sakharuk 350: }
351: return $currentstring;
352: }
353: sub end_strong {
354: my ($target,$token) = @_;
355: my $currentstring = '';
356: if ($target eq 'web') {
357:
358: $currentstring = $token->[2];
359: } elsif ($target eq 'tex') {
360: $currentstring = "}";
1.18 sakharuk 361: } elsif ($target eq 'latexsource') {
362: $currentstring = "}";
1.1 sakharuk 363: }
364: return $currentstring;
365: }
366: #---------------------------------------------------------------------------- <h1> tag
367: sub start_h1 {
368: my ($target,$token) = @_;
369: my $currentstring = '';
370: if ($target eq 'web') {
371: $currentstring .= $token->[4];
372: } elsif ($target eq 'tex') {
373: $currentstring .= "\\chapter{ ";
1.13 www 374: } elsif ($target eq 'meta') {
375: $currentstring='<subject>';
376: &start_output();
377: }
1.1 sakharuk 378: return $currentstring;
379: }
380: sub end_h1 {
381: my ($target,$token) = @_;
382: my $currentstring = '';
383: if ($target eq 'web') {
384: $currentstring .= $token->[2];
385: } elsif ($target eq 'tex') {
386: $currentstring .= "}";
1.13 www 387: } elsif ($target eq 'meta') {
388: &end_output();
389: $currentstring='</subject>';
390: }
1.1 sakharuk 391: return $currentstring;
392: }
393: #---------------------------------------------------------------------------- <h2> tag
394: sub start_h2 {
395: my ($target,$token) = @_;
396: my $currentstring = '';
397: if ($target eq 'web') {
398: $currentstring .= $token->[4];
399: } elsif ($target eq 'tex') {
400: $currentstring .= "\\section{ ";
401: }
402: return $currentstring;
403: }
404: sub end_h2 {
405: my ($target,$token) = @_;
406: my $currentstring = '';
407: if ($target eq 'web') {
408: $currentstring .= $token->[2];
409: } elsif ($target eq 'tex') {
410: $currentstring .= "}";
411: }
412: return $currentstring;
413: }
414: #---------------------------------------------------------------------------- <h3> tag
415: sub start_h3 {
416: my ($target,$token) = @_;
417: my $currentstring = '';
418: if ($target eq 'web') {
419: $currentstring .= $token->[4];
420: } elsif ($target eq 'tex') {
421: $currentstring .= "\\subsection{ ";
422: }
423: return $currentstring;
424: }
425: sub end_h3 {
426: my ($target,$token) = @_;
427: my $currentstring = '';
428: if ($target eq 'web') {
429: $currentstring .= $token->[2];
430: } elsif ($target eq 'tex') {
431: $currentstring .= "}";
432: }
433: return $currentstring;
434: }
435: #---------------------------------------------------------------------------- <h4> tag
436: sub start_h4 {
437: my ($target,$token) = @_;
438: my $currentstring = '';
439: if ($target eq 'web') {
440: $currentstring .= $token->[4];
441: } elsif ($target eq 'tex') {
442: $currentstring .= "\\subsubsection{ ";
443: }
444: return $currentstring;
445: }
446: sub end_h4 {
447: my ($target,$token) = @_;
448: my $currentstring = '';
449: if ($target eq 'web') {
450: $currentstring .= $token->[2];
451: } elsif ($target eq 'tex') {
452: $currentstring .= "}";
453: }
454: return $currentstring;
455: }
456: #---------------------------------------------------------------------------- <h5> tag
457: sub start_h5 {
458: my ($target,$token) = @_;
459: my $currentstring = '';
460: if ($target eq 'web') {
461: $currentstring .= $token->[4];
462: } elsif ($target eq 'tex') {
463: $currentstring .= "\\paragraph{ ";
464: }
465: return $currentstring;
466: }
467: sub end_h5 {
468: my ($target,$token) = @_;
469: my $currentstring = '';
470: if ($target eq 'web') {
471: $currentstring .= $token->[2];
472: } elsif ($target eq 'tex') {
473: $currentstring .= "}";
474: }
475: return $currentstring;
476: }
477: #---------------------------------------------------------------------------- <h6> tag
478: sub start_h6 {
479: my ($target,$token) = @_;
480: my $currentstring = '';
481: if ($target eq 'web') {
482: $currentstring .= $token->[4];
483: } elsif ($target eq 'tex') {
484: $currentstring .= "\\subparagraph{ ";
485: }
486: return $currentstring;
487: }
488: sub end_h6 {
489: my ($target,$token) = @_;
490: my $currentstring = '';
491: if ($target eq 'web') {
492: $currentstring .= $token->[2];
493: } elsif ($target eq 'tex') {
494: $currentstring .= "}";
495: }
496: return $currentstring;
497: }
498: #-------------------------------------------------------------------------- <cite> tag
499: sub start_cite {
500: my ($target,$token) = @_;
501: my $currentstring = '';
502: if ($target eq 'web') {
503: $currentstring .= $token->[4];
504: } elsif ($target eq 'tex') {
1.18 sakharuk 505: $currentstring .= "\\textit{";
506: } elsif ($target eq 'latexsource') {
507: $currentstring .= "\\textit{";
1.1 sakharuk 508: }
509: return $currentstring;
510: }
511: sub end_cite {
512: my ($target,$token) = @_;
513: my $currentstring = '';
514: if ($target eq 'web') {
515: $currentstring .= $token->[2];
516: } elsif ($target eq 'tex') {
517: $currentstring .= "}";
1.18 sakharuk 518: } elsif ($target eq 'latexsource') {
519: $currentstring .= "}";
1.1 sakharuk 520: }
521: return $currentstring;
522: }
523: #----------------------------------------------------------------------------- <i> tag
524: sub start_i {
525: my ($target,$token) = @_;
526: my $currentstring = '';
527: if ($target eq 'web') {
528: $currentstring .= $token->[4];
529: } elsif ($target eq 'tex') {
1.18 sakharuk 530: $currentstring .= "\\textit{";
531: } elsif ($target eq 'latexsource') {
532: $currentstring .= "\\textit{";
1.1 sakharuk 533: }
534: return $currentstring;
535: }
536: sub end_i {
537: my ($target,$token) = @_;
538: my $currentstring = '';
539: if ($target eq 'web') {
540: $currentstring .= $token->[2];
541: } elsif ($target eq 'tex') {
542: $currentstring .= "}";
1.18 sakharuk 543: } elsif ($target eq 'latexsource') {
544: $currentstring .= "}";
1.1 sakharuk 545: }
546: return $currentstring;
547: }
548: #----------------------------------------------------------------------- <address> tag
549: sub start_address {
550: my ($target,$token) = @_;
551: my $currentstring = '';
552: if ($target eq 'web') {
553: $currentstring .= $token->[4];
554: } elsif ($target eq 'tex') {
1.18 sakharuk 555: $currentstring .= "\\textit{";
556: } elsif ($target eq 'latexsource') {
557: $currentstring .= "\\textit{";
1.1 sakharuk 558: }
559: return $currentstring;
560: }
561: sub end_address {
562: my ($target,$token) = @_;
563: my $currentstring = '';
564: if ($target eq 'web') {
565: $currentstring .= $token->[2];
566: } elsif ($target eq 'tex') {
567: $currentstring .= "}";
1.18 sakharuk 568: } elsif ($target eq 'latexsource') {
569: $currentstring .= "}";
1.1 sakharuk 570: }
571: return $currentstring;
572: }
573: #--------------------------------------------------------------------------- <dfn> tag
574: sub start_dfn {
575: my ($target,$token) = @_;
576: my $currentstring = '';
577: if ($target eq 'web') {
578: $currentstring .= $token->[4];
579: } elsif ($target eq 'tex') {
1.18 sakharuk 580: $currentstring .= "\\textit{";
581: } elsif ($target eq 'latexsource') {
582: $currentstring .= "\\textit{";
1.1 sakharuk 583: }
584: return $currentstring;
585: }
586: sub end_dfn {
587: my ($target,$token) = @_;
588: my $currentstring = '';
589: if ($target eq 'web') {
590: $currentstring .= $token->[2];
591: } elsif ($target eq 'tex') {
592: $currentstring .= "}";
1.18 sakharuk 593: } elsif ($target eq 'latexsource') {
594: $currentstring .= "}";
1.1 sakharuk 595: }
596: return $currentstring;
597: }
598: #---------------------------------------------------------------------------- <tt> tag
599: sub start_tt {
600: my ($target,$token) = @_;
601: my $currentstring = '';
602: if ($target eq 'web') {
603: $currentstring .= $token->[4];
604: } elsif ($target eq 'tex') {
1.18 sakharuk 605: $currentstring .= "\\texttt{";
606: } elsif ($target eq 'latexsource') {
607: $currentstring .= "\\texttt{";
1.1 sakharuk 608: }
609: return $currentstring;
610: }
611: sub end_tt {
612: my ($target,$token) = @_;
613: my $currentstring = '';
614: if ($target eq 'web') {
615: $currentstring .= $token->[2];
616: } elsif ($target eq 'tex') {
617: $currentstring .= "}";
1.18 sakharuk 618: } elsif ($target eq 'latexsource') {
619: $currentstring .= "}";
620: }
1.1 sakharuk 621: return $currentstring;
622: }
623: #---------------------------------------------------------------------------- <kbd> tag
624: sub start_kbd {
625: my ($target,$token) = @_;
626: my $currentstring = '';
627: if ($target eq 'web') {
628: $currentstring .= $token->[4];
629: } elsif ($target eq 'tex') {
1.18 sakharuk 630: $currentstring .= "\\texttt";
631: } elsif ($target eq 'latexsource') {
632: $currentstring .= "\\texttt{";
1.1 sakharuk 633: }
634: return $currentstring;
635: }
636: sub end_kbd {
637: my ($target,$token) = @_;
638: my $currentstring = '';
639: if ($target eq 'web') {
640: $currentstring .= $token->[2];
641: } elsif ($target eq 'tex') {
642: $currentstring .= "}";
1.18 sakharuk 643: } elsif ($target eq 'latexsource') {
644: $currentstring .= "}";
1.1 sakharuk 645: }
646: return $currentstring;
647: }
648: #-------------------------------------------------------------------------- <code> tag
649: sub start_code {
650: my ($target,$token) = @_;
651: my $currentstring = '';
652: if ($target eq 'web') {
653: $currentstring .= $token->[4];
654: } elsif ($target eq 'tex') {
655: $currentstring .= "{ \\tt ";
656: }
657: return $currentstring;
658: }
659: sub end_code {
660: my ($target,$token) = @_;
661: my $currentstring = '';
662: if ($target eq 'web') {
663: $currentstring .= $token->[2];
664: } elsif ($target eq 'tex') {
665: $currentstring .= "}";
666: }
667: return $currentstring;
668: }
669: #---------------------------------------------------------------------------- <em> tag
670: sub start_em {
671: my ($target,$token) = @_;
672: my $currentstring = '';
673: if ($target eq 'web') {
674: $currentstring .= $token->[4];
675: } elsif ($target eq 'tex') {
1.15 sakharuk 676: $currentstring .= "\\emph{";
1.18 sakharuk 677: } elsif ($target eq 'latexsource') {
678: $currentstring .= "\\emph{";
1.1 sakharuk 679: }
680: return $currentstring;
681: }
682: sub end_em {
683: my ($target,$token) = @_;
684: my $currentstring = '';
685: if ($target eq 'web') {
686: $currentstring .= $token->[2];
687: } elsif ($target eq 'tex') {
688: $currentstring .= "}";
1.18 sakharuk 689: } elsif ($target eq 'latexsource') {
690: $currentstring .= "}";
691: }
1.1 sakharuk 692: return $currentstring;
693: }
694: #----------------------------------------------------------------------------- <q> tag
695: sub start_q {
696: my ($target,$token) = @_;
697: my $currentstring = '';
698: if ($target eq 'web') {
699: $currentstring .= $token->[4];
700: } elsif ($target eq 'tex') {
1.18 sakharuk 701: $currentstring .= "\\emph{";
702: } elsif ($target eq 'latexsource') {
703: $currentstring .= "\\emph{";
704: }
1.1 sakharuk 705: return $currentstring;
706: }
707: sub end_q {
708: my ($target,$token) = @_;
709: my $currentstring = '';
710: if ($target eq 'web') {
711: $currentstring .= $token->[2];
712: } elsif ($target eq 'tex') {
713: $currentstring .= "}";
1.18 sakharuk 714: } elsif ($target eq 'latexsource') {
715: $currentstring .= "}";
716: }
1.1 sakharuk 717: return $currentstring;
718: }
719: #----------------------------------------------------------------------------- <p> tag
720: sub start_p {
721: my ($target,$token) = @_;
722: my $currentstring = '';
723: if ($target eq 'web') {
724: $currentstring .= $token->[4];
725: } elsif ($target eq 'tex') {
726: $currentstring .= "{\\par ";
1.18 sakharuk 727: } elsif ($target eq 'latexsource') {
728: $currentstring .= "{\\par ";
1.1 sakharuk 729: }
730: return $currentstring;
731: }
732: sub end_p {
733: my ($target,$token) = @_;
734: my $currentstring = '';
735: if ($target eq 'web') {
736: $currentstring .= $token->[2];
737: } elsif ($target eq 'tex') {
1.18 sakharuk 738: $currentstring .= "}";
739: } elsif ($target eq 'latexsource') {
740: $currentstring .= "}";
1.1 sakharuk 741: }
742: return $currentstring;
743: }
744: #---------------------------------------------------------------------------- <br> tag
745: sub start_br {
746: my ($target,$token) = @_;
747: my $currentstring = '';
748: if ($target eq 'web') {
749: $currentstring .= $token->[4];
750: } elsif ($target eq 'tex') {
751: $currentstring .= "\\\\";
1.18 sakharuk 752: } elsif ($target eq 'latexsource') {
753: $currentstring .= "\\\\";
1.1 sakharuk 754: }
755: return $currentstring;
756: }
757: sub end_br {
758: my ($target,$token) = @_;
759: my $currentstring = '';
760: if ($target eq 'web') {
761: $currentstring .= $token->[2];
762: }
763: return $currentstring;
764: }
765: #--------------------------------------------------------------------------- <big> tag
766: sub start_big {
767: my ($target,$token) = @_;
768: my $currentstring = '';
769: if ($target eq 'web') {
770: $currentstring .= $token->[4];
771: } elsif ($target eq 'tex') {
772: $currentstring .= "{\\large ";
1.18 sakharuk 773: } elsif ($target eq 'latexsource') {
774: $currentstring .= "{\\large ";
775: }
1.1 sakharuk 776: return $currentstring;
777: }
778: sub end_big {
779: my ($target,$token) = @_;
780: my $currentstring = '';
781: if ($target eq 'web') {
782: $currentstring .= $token->[2];
783: } elsif ($target eq 'tex') {
784: $currentstring .= " }";
1.18 sakharuk 785: } elsif ($target eq 'latexsource') {
786: $currentstring .= " }";
1.1 sakharuk 787: }
788: return $currentstring;
789: }
790: #------------------------------------------------------------------------- <small> tag
791: sub start_small {
792: my ($target,$token) = @_;
793: my $currentstring = '';
794: if ($target eq 'web') {
795: $currentstring .= $token->[4];
796: } elsif ($target eq 'tex') {
797: $currentstring .= "{\\footnotesize ";
1.18 sakharuk 798: } elsif ($target eq 'latexsource') {
799: $currentstring .= "{\\footnotesize ";
1.1 sakharuk 800: }
801: return $currentstring;
802: }
803: sub end_small {
804: my ($target,$token) = @_;
805: my $currentstring = '';
806: if ($target eq 'web') {
807: $currentstring .= $token->[2];
808: } elsif ($target eq 'tex') {
1.18 sakharuk 809: $currentstring .= " }";
810: } elsif ($target eq 'latexsource') {
1.1 sakharuk 811: $currentstring .= " }";
812: }
813: return $currentstring;
814: }
815: #---------------------------------------------------------------------- <basefont> tag
816: sub start_basefont {
1.14 albertel 817: my ($target,$token) = @_;
818: my $currentstring = '';
819: if ($target eq 'web') {
820: $currentstring = $token->[4];
821: }
822: return $currentstring;
823: }
824: sub end_basefont {
825: my ($target,$token) = @_;
826: my $currentstring = '';
827: if ($target eq 'web') {
828: $currentstring = $token->[4];
829: }
830: return $currentstring;
831: }
1.1 sakharuk 832: #-------------------------------------------------------------------------- <font> tag
833: sub start_font {
834: my ($target,$token) = @_;
835: my $currentstring = '';
836: if ($target eq 'web') {
837: $currentstring = $token->[4];
838: }
839: return $currentstring;
840: }
841: sub end_font {
842: my ($target,$token) = @_;
843: my $currentstring = '';
844: if ($target eq 'web') {
845: $currentstring = $token->[2];
846: }
847: return $currentstring;
848: }
849: #------------------------------------------------------------------------ <strike> tag
850: sub start_strike {
851: my ($target,$token) = @_;
852: my $currentstring = '';
853: if ($target eq 'web') {
854: $currentstring .= $token->[4];
855: } elsif ($target eq 'tex') {
856: $currentstring .= "{\\underline ";
857: }
858: return $currentstring;
859: }
860: sub end_strike {
861: my ($target,$token) = @_;
862: my $currentstring = '';
863: if ($target eq 'web') {
864: $currentstring .= $token->[2];
865: } elsif ($target eq 'tex') {
866: $currentstring .= " }";
867: }
868: return $currentstring;
869: }
870: #----------------------------------------------------------------------------- <s> tag
871: sub start_s {
872: my ($target,$token) = @_;
873: my $currentstring = '';
874: if ($target eq 'web') {
875: $currentstring .= $token->[4];
876: } elsif ($target eq 'tex') {
877: $currentstring .= "{\\underline ";
878: }
879: return $currentstring;
880: }
881: sub end_s {
882: my ($target,$token) = @_;
883: my $currentstring = '';
884: if ($target eq 'web') {
885: $currentstring .= $token->[2];
886: } elsif ($target eq 'tex') {
887: $currentstring .= " }";
888: }
889: return $currentstring;
890: }
891: #--------------------------------------------------------------------------- <sub> tag
892: sub start_sub {
893: my ($target,$token) = @_;
894: my $currentstring = '';
895: if ($target eq 'web') {
896: $currentstring .= $token->[4];
897: } elsif ($target eq 'tex') {
898: $currentstring .= "\$_{ ";
899: }
900: return $currentstring;
901: }
902: sub end_sub {
903: my ($target,$token) = @_;
904: my $currentstring = '';
905: if ($target eq 'web') {
906: $currentstring .= $token->[2];
907: } elsif ($target eq 'tex') {
908: $currentstring .= " }\$";
909: }
910: return $currentstring;
911: }
912: #--------------------------------------------------------------------------- <sup> tag
913: sub start_sup {
914: my ($target,$token) = @_;
915: my $currentstring = '';
916: if ($target eq 'web') {
917: $currentstring .= $token->[4];
918: } elsif ($target eq 'tex') {
919: $currentstring .= "\$^{ ";
920: }
921: return $currentstring;
922: }
923: sub end_sup {
924: my ($target,$token) = @_;
925: my $currentstring = '';
926: if ($target eq 'web') {
927: $currentstring .= $token->[2];
928: } elsif ($target eq 'tex') {
929: $currentstring .= " }\$";
930: }
931: return $currentstring;
932: }
933: #---------------------------------------------------------------------------- <hr> tag
934: sub start_hr {
935: my ($target,$token) = @_;
936: my $currentstring = '';
937: if ($target eq 'web') {
938: $currentstring .= $token->[4];
939: } elsif ($target eq 'tex') {
940: $currentstring .= "\\hline ";
1.6 sakharuk 941: }
942: return $currentstring;
943: }
944: sub end_hr {
945: my ($target,$token) = @_;
946: my $currentstring = '';
947: if ($target eq 'web') {
948: $currentstring .= $token->[2];
949: } elsif ($target eq 'tex') {
1.1 sakharuk 950: }
951: return $currentstring;
952: }
953: #----------------------------------------------------------------------------- <a> tag
954: sub start_a {
955: my ($target,$token) = @_;
956: my $currentstring = '';
957: if ($target eq 'web') {
958: $currentstring .= $token->[4];
959: } elsif ($target eq 'tex') {
960: }
961: return $currentstring;
962: }
963: sub end_a {
1.30 albertel 964: my ($target,$token,$tagstack,$stackref) = @_;
1.1 sakharuk 965: my $currentstring = '';
966: if ($target eq 'web') {
967: $currentstring .= $token->[2];
968: } elsif ($target eq 'tex') {
969: my $tempor_var = $stackref->[$#$stackref];
970: if (index($tempor_var,'name') != -1 ) {
971: $tempor_var =~ s/name=([^,]*),/$1/g;
1.15 sakharuk 972: # $currentstring .= " \\label{$tempor_var}";
1.1 sakharuk 973: } elsif (index($tempor_var,'href') != -1 ) {
974: $tempor_var =~ s/href=([^,]*),/$1/g;
975: $currentstring .= " \\ref{$tempor_var}";
976: }
977: }
978: return $currentstring;
979: }
980: #---------------------------------------------------------------------------- <li> tag
981: sub start_li {
1.30 albertel 982: my ($target,$token,$tagstack,$stackref) = @_;
1.1 sakharuk 983: my $currentstring = '';
984: if ($target eq 'web') {
985: $currentstring = $token->[4];
986: } elsif ($target eq 'tex') {
1.15 sakharuk 987: my $tempor_var = $stackref->[$#$stackref];
1.1 sakharuk 988: if (index($tempor_var,'circle') != -1 ) {
989: $currentstring .= " \\item[o] ";
990: } elsif (index($tempor_var,'square') != -1 ) {
991: $currentstring .= " \\item[$\Box$] ";
1.15 sakharuk 992: } elsif ($tempor_var ne '') {
993: $_ = $tempor_var;
994: m/my\s*([^=]*)=/;
995: $currentstring .= " \\item[$1] ";
996: } else {
1.1 sakharuk 997: $currentstring .= " \\item ";
998: }
999: }
1000: return $currentstring;
1001: }
1002: sub end_li {
1003: my ($target,$token) = @_;
1004: my $currentstring = '';
1005: if ($target eq 'web') {
1006: $currentstring = $token->[2];
1007: }
1008: return $currentstring;
1009: }
1010: #----------------------------------------------------------------------------- <u> tag
1011: sub start_u {
1012: my ($target,$token) = @_;
1013: my $currentstring = '';
1014: if ($target eq 'web') {
1015: $currentstring .= $token->[4];
1016: } elsif ($target eq 'tex') {
1017: $currentstring .= "{\\underline ";
1018: }
1019: return $currentstring;
1020: }
1021: sub end_u {
1022: my ($target,$token) = @_;
1023: my $currentstring = '';
1024: if ($target eq 'web') {
1025: $currentstring .= $token->[2];
1026: } elsif ($target eq 'tex') {
1027: $currentstring .= " }";
1028: }
1029: return $currentstring;
1030: }
1031: #---------------------------------------------------------------------------- <ul> tag
1032: sub start_ul {
1033: my ($target,$token) = @_;
1034: my $currentstring = '';
1035: if ($target eq 'web') {
1036: $currentstring = $token->[4];
1037: } elsif ($target eq 'tex') {
1038: $currentstring = " \\begin{itemize} ";
1039: }
1040: return $currentstring;
1041: }
1042: sub end_ul {
1043: my ($target,$token) = @_;
1044: my $currentstring = '';
1045: if ($target eq 'web') {
1046: $currentstring = $token->[2];
1047: } elsif ($target eq 'tex') {
1048: $currentstring = " \\end{itemize}";
1049: }
1050: return $currentstring;
1051: }
1052: #-------------------------------------------------------------------------- <menu> tag
1053: sub start_menu {
1054: my ($target,$token) = @_;
1055: my $currentstring = '';
1056: if ($target eq 'web') {
1057: $currentstring = $token->[4];
1058: } elsif ($target eq 'tex') {
1059: $currentstring = " \\begin{itemize} ";
1060: }
1061: return $currentstring;
1062: }
1063: sub end_menu {
1064: my ($target,$token) = @_;
1065: my $currentstring = '';
1066: if ($target eq 'web') {
1067: $currentstring = $token->[2];
1068: } elsif ($target eq 'tex') {
1069: $currentstring = " \\end{itemize}";
1070: }
1071: return $currentstring;
1072: }
1073: #--------------------------------------------------------------------------- <dir> tag
1074: sub start_dir {
1075: my ($target,$token) = @_;
1076: my $currentstring = '';
1077: if ($target eq 'web') {
1078: $currentstring = $token->[4];
1079: } elsif ($target eq 'tex') {
1080: $currentstring = " \\begin{itemize} ";
1081: }
1082: return $currentstring;
1083: }
1084: sub end_dir {
1085: my ($target,$token) = @_;
1086: my $currentstring = '';
1087: if ($target eq 'web') {
1088: $currentstring = $token->[2];
1089: } elsif ($target eq 'tex') {
1090: $currentstring = " \\end{itemize}";
1091: }
1092: return $currentstring;
1093: }
1094: #---------------------------------------------------------------------------- <ol> tag
1095: sub start_ol {
1096: my ($target,$token) = @_;
1097: my $currentstring = '';
1098: if ($target eq 'web') {
1099: $currentstring = $token->[4];
1100: } elsif ($target eq 'tex') {
1101: $currentstring = " \\begin{enumerate} ";
1102: }
1103: return $currentstring;
1104: }
1105: sub end_ol {
1106: my ($target,$token) = @_;
1107: my $currentstring = '';
1108: if ($target eq 'web') {
1109: $currentstring = $token->[2];
1110: } elsif ($target eq 'tex') {
1111: $currentstring = " \\end{enumerate}";
1112: }
1113: return $currentstring;
1114: }
1115: #---------------------------------------------------------------------------- <dl> tag
1116: sub start_dl {
1117: my ($target,$token) = @_;
1118: my $currentstring = '';
1119: if ($target eq 'web') {
1120: $currentstring = $token->[4];
1121: } elsif ($target eq 'tex') {
1122: $currentstring = " \\begin{description} ";
1123: }
1124: return $currentstring;
1125: }
1126: sub end_dl {
1127: my ($target,$token) = @_;
1128: my $currentstring = '';
1129: if ($target eq 'web') {
1130: $currentstring = $token->[2];
1131: } elsif ($target eq 'tex') {
1132: $currentstring = " \\end{description}";
1133: }
1134: return $currentstring;
1135: }
1136: #---------------------------------------------------------------------------- <dt> tag
1137: sub start_dt {
1138: my ($target,$token) = @_;
1139: my $currentstring = '';
1140: if ($target eq 'web') {
1141: $currentstring = $token->[4];
1142: } elsif ($target eq 'tex') {
1143: $currentstring = "\\item[ ";
1144: }
1145: return $currentstring;
1146: }
1147: sub end_dt {
1148: my ($target,$token) = @_;
1149: my $currentstring = '';
1150: if ($target eq 'web') {
1151: $currentstring = $token->[2];
1152: } elsif ($target eq 'tex') {
1153: $currentstring = "]";
1154: }
1155: return $currentstring;
1156: }
1157: #---------------------------------------------------------------------------- <dd> tag
1158: sub start_dd {
1159: my ($target,$token) = @_;
1160: my $currentstring = '';
1161: if ($target eq 'web') {
1162: $currentstring = $token->[4];
1163: }
1164: return $currentstring;
1165: }
1166: sub end_dd {
1167: my ($target,$token) = @_;
1168: my $currentstring = '';
1169: if ($target eq 'web') {
1170: $currentstring = $token->[2];
1171: }
1172: return $currentstring;
1173: }
1174: #------------------------------------------------------------------------- <table> tag
1175: sub start_table {
1176: my ($target,$token) = @_;
1177: my $currentstring = '';
1178: if ($target eq 'web') {
1179: $currentstring = $token->[4];
1180: } elsif ($target eq 'tex') {
1.15 sakharuk 1181: $currentstring = "";
1.1 sakharuk 1182: }
1183: return $currentstring;
1184: }
1185: sub end_table {
1186: my ($target,$token) = @_;
1187: my $currentstring = '';
1188: if ($target eq 'web') {
1189: $currentstring = $token->[2];
1190: } elsif ($target eq 'tex') {
1.15 sakharuk 1191: $currentstring = "";
1192: }
1193: return $currentstring;
1194: }
1195: #------------------------------------------------------------------------- <tr> tag
1196: sub start_tr {
1197: my ($target,$token) = @_;
1198: my $currentstring = '';
1199: if ($target eq 'web') {
1200: $currentstring = $token->[4];
1201: } elsif ($target eq 'tex') {
1202: $currentstring = '';
1203: }
1204: return $currentstring;
1205: }
1206: sub end_tr {
1207: my ($target,$token) = @_;
1208: my $currentstring = '';
1209: if ($target eq 'web') {
1210: $currentstring = $token->[2];
1211: } elsif ($target eq 'tex') {
1212: $currentstring = "";
1213: }
1214: return $currentstring;
1215: }
1216: #------------------------------------------------------------------------- <td> tag
1217: sub start_td {
1218: my ($target,$token) = @_;
1219: my $currentstring = '';
1220: if ($target eq 'web') {
1221: $currentstring = $token->[4];
1222: } elsif ($target eq 'tex') {
1223: $currentstring = '';
1224: }
1225: return $currentstring;
1226: }
1227: sub end_td {
1228: my ($target,$token) = @_;
1229: my $currentstring = '';
1230: if ($target eq 'web') {
1231: $currentstring = $token->[2];
1232: } elsif ($target eq 'tex') {
1233: $currentstring = "";
1.1 sakharuk 1234: }
1235: return $currentstring;
1236: }
1.10 www 1237: # -------------------------------------------------------------------------- <img> tag
1238:
1239: sub start_img {
1240: my ($target,$token) = @_;
1241: $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=
1242: $token->[2]->{'src'};
1243: my $currentstring = '';
1244: if ($target eq 'web') {
1245: $currentstring = $token->[4];
1246: } elsif ($target eq 'tex') {
1247: $currentstring = " \\begin{figure} ";
1248: }
1249: return $currentstring;
1250: }
1251: sub end_img {
1252: my ($target,$token) = @_;
1253: my $currentstring = '';
1254: if ($target eq 'web') {
1255: $currentstring = $token->[2];
1256: } elsif ($target eq 'tex') {
1257: $currentstring = " \\end{figure}";
1258: }
1259: return $currentstring;
1260: }
1261: # ----------------------------------------------------------------------- <applet> tag
1262:
1263: sub start_applet {
1264: my ($target,$token) = @_;
1265: $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=
1266: $token->[2]->{'code'};
1267: $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=
1268: $token->[2]->{'archive'};
1269: my $currentstring = '';
1270: if ($target eq 'web') {
1271: $currentstring = $token->[4];
1272: } elsif ($target eq 'tex') {
1273: $currentstring = " \\begin{figure} ";
1274: }
1275: return $currentstring;
1276: }
1277: sub end_applet {
1278: my ($target,$token) = @_;
1279: my $currentstring = '';
1280: if ($target eq 'web') {
1281: $currentstring = $token->[2];
1282: } elsif ($target eq 'tex') {
1283: $currentstring = " \\end{figure}";
1284: }
1285: return $currentstring;
1286: }
1287:
1288: # ------------------------------------------------------------------------ <embed> tag
1289:
1290: sub start_embed {
1291: my ($target,$token) = @_;
1292: $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=
1293: $token->[2]->{'src'};
1294: my $currentstring = '';
1295: if ($target eq 'web') {
1296: $currentstring = $token->[4];
1297: } elsif ($target eq 'tex') {
1298: $currentstring = " \\begin{figure} ";
1299: }
1300: return $currentstring;
1301: }
1302: sub end_embed {
1303: my ($target,$token) = @_;
1304: my $currentstring = '';
1305: if ($target eq 'web') {
1306: $currentstring = $token->[2];
1307: } elsif ($target eq 'tex') {
1308: $currentstring = " \\end{figure}";
1309: }
1310: return $currentstring;
1311: }
1312:
1313: # ------------------------------------------------------------------------ <param> tag
1314:
1.11 www 1315: sub start_param {
1.10 www 1316: my ($target,$token) = @_;
1317: if ($token->[2]->{'name'} eq 'cabbase') {
1318: $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=
1319: $token->[2]->{'value'};
1320: }
1.20 www 1321: $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=
1.10 www 1322: $token->[2]->{'src'};
1323: my $currentstring = '';
1324: if ($target eq 'web') {
1325: $currentstring = $token->[4];
1326: } elsif ($target eq 'tex') {
1327: $currentstring = " \\begin{figure} ";
1328: }
1329: return $currentstring;
1330: }
1.11 www 1331: sub end_param {
1.10 www 1332: my ($target,$token) = @_;
1333: my $currentstring = '';
1334: if ($target eq 'web') {
1335: $currentstring = $token->[2];
1336: } elsif ($target eq 'tex') {
1337: $currentstring = " \\end{figure}";
1338: }
1339: return $currentstring;
1340: }
1341:
1342: # ------------------------------------------------------------------------ <allow> tag
1343:
1344: sub start_allow {
1345: my ($target,$token) = @_;
1346:
1.20 www 1347: $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=
1.10 www 1348: $token->[2]->{'src'};
1349:
1350: return '';
1351: }
1352: sub end_allow {
1353: return '';
1354: }
1355:
1.31 ! albertel 1356: # ------------------------------------------------------------------------- Frames
! 1357: sub start_frameset {
! 1358: my ($target,$token) = @_;
! 1359: my $currentstring = '';
! 1360: if ($target eq 'web') {
! 1361: if (!$Apache::lonxml::registered) {
! 1362: $currentstring.='<head>'.&Apache::lonxml::registerurl().'</head>';
! 1363: }
! 1364: $currentstring .= $token->[4];
! 1365: }
! 1366: return $currentstring;
! 1367: }
! 1368: sub end_frameset {
! 1369: my ($target,$token) = @_;
! 1370: my $currentstring = '';
! 1371: if ($target eq 'web') {
! 1372: $currentstring = $token->[2];
! 1373: }
! 1374: return $currentstring;
! 1375: }
1.1 sakharuk 1376: 1;
1377: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>