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