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