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