Annotation of loncom/xml/londefdef.pm, revision 1.55
1.44 sakharuk 1:
1.1 sakharuk 2: # The LearningOnline Network with CAPA
3: # Tags Default Definition Module
4: #
1.55 ! sakharuk 5: # $Id: londefdef.pm,v 1.54 2002/04/26 18:18:37 sakharuk Exp $
1.41 sakharuk 6: #
1.34 www 7: #
8: # Copyright Michigan State University Board of Trustees
9: #
10: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
11: #
12: # LON-CAPA is free software; you can redistribute it and/or modify
13: # it under the terms of the GNU General Public License as published by
14: # the Free Software Foundation; either version 2 of the License, or
15: # (at your option) any later version.
16: #
17: # LON-CAPA is distributed in the hope that it will be useful,
18: # but WITHOUT ANY WARRANTY; without even the implied warranty of
19: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20: # GNU General Public License for more details.
21: #
22: # You should have received a copy of the GNU General Public License
23: # along with LON-CAPA; if not, write to the Free Software
24: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25: #
26: # /home/httpd/html/adm/gpl.txt
27: #
28: # http://www.lon-capa.org/
29: #
30: # Copyright for TtHfunc and TtMfunc by Ian Hutchinson.
31: # TtHfunc and TtMfunc (the "Code") may be compiled and linked into
32: # binary executable programs or libraries distributed by the
33: # Michigan State University (the "Licensee"), but any binaries so
34: # distributed are hereby licensed only for use in the context
35: # of a program or computational system for which the Licensee is the
36: # primary author or distributor, and which performs substantial
37: # additional tasks beyond the translation of (La)TeX into HTML.
38: # The C source of the Code may not be distributed by the Licensee
39: # to any other parties under any circumstances.
40: #
41: #
1.1 sakharuk 42: # last modified 06/26/00 by Alexander Sakharuk
1.28 www 43: # 11/6,11/30,02/01/01,5/4 Gerd Kortemeyer
1.41 sakharuk 44: # 01/18 Alex Sakharuk
1.1 sakharuk 45:
1.2 albertel 46: package Apache::londefdef;
1.1 sakharuk 47:
1.54 sakharuk 48: use Apache::lonnet;
1.1 sakharuk 49: use strict;
1.3 sakharuk 50: use Apache::lonxml;
1.1 sakharuk 51:
1.54 sakharuk 52:
1.38 harris41 53: BEGIN {
1.15 sakharuk 54:
1.51 sakharuk 55: &Apache::lonxml::register('Apache::londefdef',('m','html','head','map','select','option','input','textarea','form','meta','title','body','center','b','strong','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','allow','frameset','pre','insert','externallink','table','tr','td'));
1.15 sakharuk 56:
1.3 sakharuk 57: }
1.1 sakharuk 58:
1.35 sakharuk 59: #======================= TAG SUBROUTINES =====================
1.8 sakharuk 60: #-- <output>
1.21 albertel 61: sub start_output {
62: my ($target) = @_;
1.22 albertel 63: if ($target eq 'meta') { $Apache::lonxml::metamode--; }
1.21 albertel 64: return '';
65: }
66: sub end_output {
67: my ($target) = @_;
1.22 albertel 68: if ($target eq 'meta') { $Apache::lonxml::metamode++; }
1.21 albertel 69: return '';
70: }
1.4 sakharuk 71: #-- <m> tag
1.33 albertel 72: sub start_m {
73: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
74: my $currentstring = '';
75: if ($target eq 'web') {
76: my $inside = &Apache::lonxml::get_all_text("/m",$$parser[-1]);
77: $inside ='\\documentstyle{article}'.$inside;
1.37 albertel 78: &Apache::lonxml::debug("M is starting with:$inside:");
1.33 albertel 79: my $eval=&Apache::lonxml::get_param('eval',$parstack,$safeeval);
80: if ($eval eq 'on') {
81: $inside=&Apache::run::evaluate($inside,$safeeval,$$parstack[-1]);
82: #&Apache::lonxml::debug("M is evaulated to:$inside:");
83: }
84: $currentstring = &Apache::lontexconvert::converted(\$inside);
1.37 albertel 85: if ($Apache::lontexconvert::errorstring) {
86: &Apache::lonxml::warning("tth error: ".
87: $Apache::lontexconvert::errorstring);
88: $Apache::lontexconvert::errorstring='';
89: }
1.33 albertel 90: #&Apache::lonxml::debug("M is ends with:$currentstring:");
91: } elsif ($target eq 'tex') {
92: $currentstring = "";
93: }
94: return $currentstring;
95: }
96: sub end_m {
97: my ($target,$token) = @_;
98: my $currentstring = '';
99: if ($target eq 'web') {
100: } elsif ($target eq 'tex') {
101: $currentstring = "";
102: } elsif ($target eq 'meta') {
103: }
104: return $currentstring;
105: }
1.35 sakharuk 106: #-- <html> tag
1.1 sakharuk 107: sub start_html {
108: my ($target,$token) = @_;
1.41 sakharuk 109: my $currentstring = '';
1.39 albertel 110: if ($ENV{'browser.mathml'}) {
111: &tth::ttminit();
112: } else {
113: &tth::tthinit();
114: }
1.1 sakharuk 115: if ($target eq 'web') {
1.29 www 116: $currentstring = &Apache::lonxml::xmlbegin().
117: &Apache::lonxml::fontsettings();
1.35 sakharuk 118: } elsif ($target eq 'tex') {
1.53 sakharuk 119: @Apache::londefdef::table = ();
1.35 sakharuk 120: $currentstring .= '\documentclass[letterpaper]{article}
1.41 sakharuk 121: \newcommand{\keephidden}[1]{}
1.44 sakharuk 122: \usepackage[dvips]{graphicx}
123: \usepackage{epsfig}';
1.35 sakharuk 124: }
1.1 sakharuk 125: return $currentstring;
126: }
127: sub end_html {
128: my ($target,$token) = @_;
129: my $currentstring = '';
130: if ($target eq 'web') {
1.28 www 131: $currentstring = &Apache::lonxml::xmlend();
1.35 sakharuk 132: }
1.1 sakharuk 133: return $currentstring;
134: }
1.35 sakharuk 135: #-- <head> tag
1.1 sakharuk 136: sub start_head {
137: my ($target,$token) = @_;
138: my $currentstring = '';
139: if ($target eq 'web') {
140: $currentstring = $token->[4];
141: }
142: return $currentstring;
143: }
144: sub end_head {
145: my ($target,$token) = @_;
146: my $currentstring = '';
147: if ($target eq 'web') {
1.47 matthew 148: $currentstring = &Apache::lonxml::registerurl(undef,$target).
1.29 www 149: $token->[2];
1.1 sakharuk 150: }
151: return $currentstring;
152: }
1.35 sakharuk 153: #-- <map> tag
1.1 sakharuk 154: sub start_map {
155: my ($target,$token) = @_;
156: my $currentstring = '';
157: if ($target eq 'web') {
158: $currentstring = $token->[4];
159: }
160: return $currentstring;
161: }
162: sub end_map {
163: my ($target,$token) = @_;
164: my $currentstring = '';
165: if ($target eq 'web') {
166: $currentstring = $token->[2];
167: }
168: return $currentstring;
169: }
1.35 sakharuk 170: #-- <select> tag
1.1 sakharuk 171: sub start_select {
172: my ($target,$token) = @_;
173: my $currentstring = '';
174: if ($target eq 'web') {
175: $currentstring = $token->[4];
176: }
177: return $currentstring;
178: }
179: sub end_select {
180: my ($target,$token) = @_;
181: my $currentstring = '';
182: if ($target eq 'web') {
183: $currentstring = $token->[2];
184: }
185: return $currentstring;
186: }
1.35 sakharuk 187: #-- <option> tag
1.1 sakharuk 188: sub start_option {
189: my ($target,$token) = @_;
190: my $currentstring = '';
191: if ($target eq 'web') {
192: $currentstring = $token->[4];
193: }
194: return $currentstring;
195: }
196: sub end_option {
197: my ($target,$token) = @_;
198: my $currentstring = '';
199: if ($target eq 'web') {
200: $currentstring = $token->[2];
201: }
202: return $currentstring;
203: }
1.35 sakharuk 204: #-- <input> tag
1.1 sakharuk 205: sub start_input {
206: my ($target,$token) = @_;
207: my $currentstring = '';
208: if ($target eq 'web') {
209: $currentstring = $token->[4];
210: }
211: return $currentstring;
212: }
213: sub end_input {
214: my ($target,$token) = @_;
215: my $currentstring = '';
216: if ($target eq 'web') {
217: $currentstring = $token->[2];
218: }
219: return $currentstring;
220: }
1.35 sakharuk 221: #-- <textarea> tag
1.1 sakharuk 222: sub start_textarea {
223: my ($target,$token) = @_;
224: my $currentstring = '';
225: if ($target eq 'web') {
226: $currentstring = $token->[4];
227: }
228: return $currentstring;
229: }
230: sub end_textarea {
231: my ($target,$token) = @_;
232: my $currentstring = '';
233: if ($target eq 'web') {
234: $currentstring = $token->[2];
235: }
236: return $currentstring;
237: }
1.35 sakharuk 238: #-- <form> tag
1.1 sakharuk 239: sub start_form {
240: my ($target,$token) = @_;
241: my $currentstring = '';
242: if ($target eq 'web') {
243: $currentstring = $token->[4];
244: }
245: return $currentstring;
246: }
247: sub end_form {
248: my ($target,$token) = @_;
249: my $currentstring = '';
250: if ($target eq 'web') {
251: $currentstring = $token->[2];
252: }
253: return $currentstring;
254: }
1.35 sakharuk 255: #-- <title> tag
1.1 sakharuk 256: sub start_title {
257: my ($target,$token) = @_;
258: my $currentstring = '';
259: if ($target eq 'web') {
260: $currentstring = $token->[4];
1.35 sakharuk 261: } elsif ($target eq 'tex') {
262: $currentstring .= '\keephidden{'
1.1 sakharuk 263: }
1.13 www 264: if ($target eq 'meta') {
265: $currentstring='<title>';
266: &start_output();
267: }
1.1 sakharuk 268: return $currentstring;
269: }
270: sub end_title {
271: my ($target,$token) = @_;
272: my $currentstring = '';
273: if ($target eq 'web') {
274: $currentstring = $token->[2];
1.35 sakharuk 275: } elsif ($target eq 'tex') {
276: $currentstring .= '}';
277: }
1.13 www 278: if ($target eq 'meta') {
279: &end_output();
280: $currentstring='</title>';
1.1 sakharuk 281: }
282: return $currentstring;
283: }
1.35 sakharuk 284: #-- <meta> tag
1.1 sakharuk 285: sub start_meta {
1.30 albertel 286: my ($target,$token,$tagstack,$parstack,$parser) = @_;
1.1 sakharuk 287: my $currentstring = '';
288: if ($target eq 'web') {
1.25 albertel 289: my $args='';
290: if ( $#$parstack > -1 ) { $args=$$parstack[$#$parstack]; }
291: if ($args eq '') {
292: &Apache::lonxml::get_all_text("/meta",$$parser[$#$parser]);
293: } else {
294: $currentstring = $token->[4];
295: }
1.12 www 296: }
297: if ($target eq 'meta') {
298: unless ($token->[2]->{'http-equiv'}) {
299: my $name=$token->[2]->{'name'};
300: $name=~tr/A-Z/a-z/;
301: $name=~s/\s/\_/g;
302: if ($name) {
303: $currentstring='<'.$name.'>'.
304: $token->[2]->{'content'}.
305: '</'.$name.'>';
306: }
307: }
1.1 sakharuk 308: }
309: return $currentstring;
310: }
1.26 albertel 311: sub end_meta {
1.30 albertel 312: my ($target,$token,$tagstack,$parstack,$parser) = @_;
1.26 albertel 313: my $currentstring = '';
314: if ($target eq 'web') {
315: my $args='';
316: if ( $#$parstack > -1 ) { $args=$$parstack[$#$parstack]; }
317: if ($args ne '') {
318: $currentstring = $token->[4];
319: }
320: }
321: return $currentstring;
322: }
1.35 sakharuk 323: #-- <body> tag
1.1 sakharuk 324: sub start_body {
1.41 sakharuk 325: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
326: # my ($target,$token) = @_;
1.1 sakharuk 327: my $currentstring = '';
328: if ($target eq 'web') {
1.31 albertel 329: if (!$Apache::lonxml::registered) {
1.47 matthew 330: $currentstring.='<head>'.
331: &Apache::lonxml::registerurl(undef,$target).'</head>';
1.31 albertel 332: }
1.32 albertel 333: my $onLoad='';
334: foreach my $key (keys(%{$token->[2]})) {
335: if ($key =~ /^onload$/i) {
336: $onLoad.=$token->[2]->{$key}.';';
337: delete($token->[2]->{$key});
338: }
339: }
340: $token->[2]->{'onLoad'}=$onLoad.&Apache::lonxml::loadevents();
341: my $onUnload='';
342: foreach my $key (keys(%{$token->[2]})) {
343: if ($key =~ /^onunload$/i) {
344: $onUnload.=$token->[2]->{$key}.';';
345: delete($token->[2]->{$key});
346: }
347: }
348: $token->[2]->{'onUnload'}=$onUnload.
349: &Apache::lonxml::unloadevents();
1.31 albertel 350:
351: $currentstring .= '<'.$token->[1];
1.37 albertel 352: foreach (keys %{$token->[2]}) {
353: $currentstring.=' '.$_.'="'.$token->[2]->{$_}.'"';
354: }
1.31 albertel 355: $currentstring.='>';
1.40 albertel 356: if ($ENV{'request.state'} ne 'published') {
357: $currentstring.=(<<EDITBUTTON);
358: <form method="post">
1.49 albertel 359: <input type="submit" name="editmode" value="Edit" />
1.40 albertel 360: </form>
361: EDITBUTTON
362: }
1.28 www 363: } elsif ($target eq 'tex') {
1.35 sakharuk 364: $currentstring = '\begin{document}';
1.1 sakharuk 365: }
366: return $currentstring;
367: }
368: sub end_body {
369: my ($target,$token) = @_;
370: my $currentstring = '';
371: if ($target eq 'web') {
372: $currentstring = $token->[2];
373: } elsif ($target eq 'tex') {
1.35 sakharuk 374: $currentstring = '\end{document}';
1.1 sakharuk 375: }
376: return $currentstring;
377: }
1.35 sakharuk 378: #-- <center> tag
1.1 sakharuk 379: sub start_center {
380: my ($target,$token) = @_;
381: my $currentstring = '';
382: if ($target eq 'web') {
383: $currentstring = $token->[4];
384: } elsif ($target eq 'tex') {
1.35 sakharuk 385: $currentstring = '\begin{center}';
1.18 sakharuk 386: } elsif ($target eq 'latexsource') {
1.35 sakharuk 387: $currentstring = '\begin{center}';
1.1 sakharuk 388: }
389: return $currentstring;
390: }
391: sub end_center {
392: my ($target,$token) = @_;
393: my $currentstring = '';
394: if ($target eq 'web') {
395: $currentstring = $token->[2];
396: } elsif ($target eq 'tex') {
1.35 sakharuk 397: $currentstring = '\end{center}';
1.18 sakharuk 398: } elsif ($target eq 'latexsource') {
1.35 sakharuk 399: $currentstring = '\end{center}';
1.1 sakharuk 400: }
401: return $currentstring;
402: }
1.35 sakharuk 403: #-- <b> tag
1.1 sakharuk 404: sub start_b {
405: my ($target,$token) = @_;
406: my $currentstring = '';
407: if ($target eq 'web') {
408: $currentstring = $token->[4];
409: } elsif ($target eq 'tex') {
1.35 sakharuk 410: $currentstring = '\textbf{';
1.18 sakharuk 411: } elsif ($target eq 'latexsource') {
1.35 sakharuk 412: $currentstring = '\textbf{';
1.1 sakharuk 413: }
414: return $currentstring;
415: }
416: sub end_b {
417: my ($target,$token) = @_;
418: my $currentstring = '';
419: if ($target eq 'web') {
420: $currentstring = $token->[2];
421: } elsif ($target eq 'tex') {
1.35 sakharuk 422: $currentstring = '}';
423:
1.18 sakharuk 424: } elsif ($target eq 'latexsource') {
1.35 sakharuk 425: $currentstring = '}';
1.1 sakharuk 426: }
427: return $currentstring;
428: }
1.35 sakharuk 429: #-- <strong> tag
1.1 sakharuk 430: sub start_strong {
431: my ($target,$token) = @_;
432: my $currentstring = '';
433: if ($target eq 'web') {
434: $currentstring = $token->[4];
435: } elsif ($target eq 'tex') {
1.35 sakharuk 436: $currentstring = '\textbf{';
1.18 sakharuk 437: } elsif ($target eq 'latexsource') {
1.35 sakharuk 438: $currentstring = '\textbf{';
1.1 sakharuk 439: }
440: return $currentstring;
441: }
442: sub end_strong {
443: my ($target,$token) = @_;
444: my $currentstring = '';
445: if ($target eq 'web') {
446:
447: $currentstring = $token->[2];
448: } elsif ($target eq 'tex') {
1.35 sakharuk 449: $currentstring = '}';
1.18 sakharuk 450: } elsif ($target eq 'latexsource') {
1.35 sakharuk 451: $currentstring = '}';
1.1 sakharuk 452: }
453: return $currentstring;
454: }
1.35 sakharuk 455: #-- <h1> tag
1.1 sakharuk 456: sub start_h1 {
457: my ($target,$token) = @_;
458: my $currentstring = '';
459: if ($target eq 'web') {
460: $currentstring .= $token->[4];
461: } elsif ($target eq 'tex') {
1.35 sakharuk 462: $currentstring .= '\large{\textbf{';
1.13 www 463: } elsif ($target eq 'meta') {
464: $currentstring='<subject>';
465: &start_output();
466: }
1.1 sakharuk 467: return $currentstring;
468: }
469: sub end_h1 {
470: my ($target,$token) = @_;
471: my $currentstring = '';
472: if ($target eq 'web') {
473: $currentstring .= $token->[2];
474: } elsif ($target eq 'tex') {
1.35 sakharuk 475: $currentstring .= '}}';
1.13 www 476: } elsif ($target eq 'meta') {
477: &end_output();
478: $currentstring='</subject>';
479: }
1.1 sakharuk 480: return $currentstring;
481: }
1.35 sakharuk 482: #-- <h2> tag
1.1 sakharuk 483: sub start_h2 {
484: my ($target,$token) = @_;
485: my $currentstring = '';
486: if ($target eq 'web') {
487: $currentstring .= $token->[4];
488: } elsif ($target eq 'tex') {
1.35 sakharuk 489: $currentstring .= '\large{\textbf{';
1.1 sakharuk 490: }
491: return $currentstring;
492: }
493: sub end_h2 {
494: my ($target,$token) = @_;
495: my $currentstring = '';
496: if ($target eq 'web') {
497: $currentstring .= $token->[2];
498: } elsif ($target eq 'tex') {
1.35 sakharuk 499: $currentstring .= '}}';
1.1 sakharuk 500: }
501: return $currentstring;
502: }
1.35 sakharuk 503: #-- <h3> tag
1.1 sakharuk 504: sub start_h3 {
505: my ($target,$token) = @_;
506: my $currentstring = '';
507: if ($target eq 'web') {
508: $currentstring .= $token->[4];
509: } elsif ($target eq 'tex') {
1.35 sakharuk 510: $currentstring .= '\large{\textbf{';
1.1 sakharuk 511: }
512: return $currentstring;
513: }
514: sub end_h3 {
515: my ($target,$token) = @_;
516: my $currentstring = '';
517: if ($target eq 'web') {
518: $currentstring .= $token->[2];
519: } elsif ($target eq 'tex') {
1.35 sakharuk 520: $currentstring .= '}}';
1.1 sakharuk 521: }
522: return $currentstring;
523: }
1.35 sakharuk 524: #-- <h4> tag
1.1 sakharuk 525: sub start_h4 {
526: my ($target,$token) = @_;
527: my $currentstring = '';
528: if ($target eq 'web') {
529: $currentstring .= $token->[4];
530: } elsif ($target eq 'tex') {
1.41 sakharuk 531: $currentstring .= '\large{\textbf{';
1.1 sakharuk 532: }
533: return $currentstring;
534: }
535: sub end_h4 {
536: my ($target,$token) = @_;
537: my $currentstring = '';
538: if ($target eq 'web') {
539: $currentstring .= $token->[2];
540: } elsif ($target eq 'tex') {
1.35 sakharuk 541: $currentstring .= '}}';
1.1 sakharuk 542: }
543: return $currentstring;
544: }
1.35 sakharuk 545: #-- <h5> tag
1.1 sakharuk 546: sub start_h5 {
547: my ($target,$token) = @_;
548: my $currentstring = '';
549: if ($target eq 'web') {
550: $currentstring .= $token->[4];
551: } elsif ($target eq 'tex') {
1.35 sakharuk 552: $currentstring .= '\large{\textbf{';
1.1 sakharuk 553: }
554: return $currentstring;
555: }
556: sub end_h5 {
557: my ($target,$token) = @_;
558: my $currentstring = '';
559: if ($target eq 'web') {
560: $currentstring .= $token->[2];
561: } elsif ($target eq 'tex') {
1.35 sakharuk 562: $currentstring .= '}}';
1.1 sakharuk 563: }
564: return $currentstring;
565: }
1.35 sakharuk 566: #-- <h6> tag
1.1 sakharuk 567: sub start_h6 {
568: my ($target,$token) = @_;
569: my $currentstring = '';
570: if ($target eq 'web') {
571: $currentstring .= $token->[4];
572: } elsif ($target eq 'tex') {
1.35 sakharuk 573: $currentstring .= '\large{\textbf{';
1.1 sakharuk 574: }
575: return $currentstring;
576: }
577: sub end_h6 {
578: my ($target,$token) = @_;
579: my $currentstring = '';
580: if ($target eq 'web') {
581: $currentstring .= $token->[2];
582: } elsif ($target eq 'tex') {
1.35 sakharuk 583: $currentstring .= '}}';
1.1 sakharuk 584: }
585: return $currentstring;
586: }
1.35 sakharuk 587: #--- <cite> tag
1.1 sakharuk 588: sub start_cite {
589: my ($target,$token) = @_;
590: my $currentstring = '';
591: if ($target eq 'web') {
592: $currentstring .= $token->[4];
593: } elsif ($target eq 'tex') {
1.18 sakharuk 594: $currentstring .= "\\textit{";
595: } elsif ($target eq 'latexsource') {
596: $currentstring .= "\\textit{";
1.1 sakharuk 597: }
598: return $currentstring;
599: }
600: sub end_cite {
601: my ($target,$token) = @_;
602: my $currentstring = '';
603: if ($target eq 'web') {
604: $currentstring .= $token->[2];
605: } elsif ($target eq 'tex') {
606: $currentstring .= "}";
1.18 sakharuk 607: } elsif ($target eq 'latexsource') {
608: $currentstring .= "}";
1.1 sakharuk 609: }
610: return $currentstring;
611: }
1.35 sakharuk 612: #-- <i> tag
1.1 sakharuk 613: sub start_i {
614: my ($target,$token) = @_;
615: my $currentstring = '';
616: if ($target eq 'web') {
617: $currentstring .= $token->[4];
618: } elsif ($target eq 'tex') {
1.35 sakharuk 619: $currentstring .= '\textit{';
1.18 sakharuk 620: } elsif ($target eq 'latexsource') {
1.35 sakharuk 621: $currentstring .= '\textit{';
1.1 sakharuk 622: }
623: return $currentstring;
624: }
625: sub end_i {
626: my ($target,$token) = @_;
627: my $currentstring = '';
628: if ($target eq 'web') {
629: $currentstring .= $token->[2];
630: } elsif ($target eq 'tex') {
1.35 sakharuk 631: $currentstring .= '}';
1.18 sakharuk 632: } elsif ($target eq 'latexsource') {
1.35 sakharuk 633: $currentstring .= '}';
1.1 sakharuk 634: }
635: return $currentstring;
636: }
1.35 sakharuk 637: #-- <address> tag
1.1 sakharuk 638: sub start_address {
639: my ($target,$token) = @_;
640: my $currentstring = '';
641: if ($target eq 'web') {
642: $currentstring .= $token->[4];
643: } elsif ($target eq 'tex') {
1.18 sakharuk 644: $currentstring .= "\\textit{";
645: } elsif ($target eq 'latexsource') {
646: $currentstring .= "\\textit{";
1.1 sakharuk 647: }
648: return $currentstring;
649: }
650: sub end_address {
651: my ($target,$token) = @_;
652: my $currentstring = '';
653: if ($target eq 'web') {
654: $currentstring .= $token->[2];
655: } elsif ($target eq 'tex') {
656: $currentstring .= "}";
1.18 sakharuk 657: } elsif ($target eq 'latexsource') {
658: $currentstring .= "}";
1.1 sakharuk 659: }
660: return $currentstring;
661: }
1.35 sakharuk 662: #-- <dfn> tag
1.1 sakharuk 663: sub start_dfn {
664: my ($target,$token) = @_;
665: my $currentstring = '';
666: if ($target eq 'web') {
667: $currentstring .= $token->[4];
668: } elsif ($target eq 'tex') {
1.18 sakharuk 669: $currentstring .= "\\textit{";
670: } elsif ($target eq 'latexsource') {
671: $currentstring .= "\\textit{";
1.1 sakharuk 672: }
673: return $currentstring;
674: }
675: sub end_dfn {
676: my ($target,$token) = @_;
677: my $currentstring = '';
678: if ($target eq 'web') {
679: $currentstring .= $token->[2];
680: } elsif ($target eq 'tex') {
681: $currentstring .= "}";
1.18 sakharuk 682: } elsif ($target eq 'latexsource') {
683: $currentstring .= "}";
1.1 sakharuk 684: }
685: return $currentstring;
686: }
1.35 sakharuk 687: #-- <tt> tag
1.1 sakharuk 688: sub start_tt {
689: my ($target,$token) = @_;
690: my $currentstring = '';
691: if ($target eq 'web') {
692: $currentstring .= $token->[4];
693: } elsif ($target eq 'tex') {
1.35 sakharuk 694: $currentstring .= '\texttt{';
1.18 sakharuk 695: } elsif ($target eq 'latexsource') {
1.35 sakharuk 696: $currentstring .= '\texttt{';
1.1 sakharuk 697: }
698: return $currentstring;
699: }
700: sub end_tt {
701: my ($target,$token) = @_;
702: my $currentstring = '';
703: if ($target eq 'web') {
704: $currentstring .= $token->[2];
705: } elsif ($target eq 'tex') {
1.35 sakharuk 706: $currentstring .= '}';
1.18 sakharuk 707: } elsif ($target eq 'latexsource') {
1.35 sakharuk 708: $currentstring .= '}';
1.18 sakharuk 709: }
1.1 sakharuk 710: return $currentstring;
711: }
1.35 sakharuk 712: #-- <kbd> tag
1.1 sakharuk 713: sub start_kbd {
714: my ($target,$token) = @_;
715: my $currentstring = '';
716: if ($target eq 'web') {
717: $currentstring .= $token->[4];
718: } elsif ($target eq 'tex') {
1.18 sakharuk 719: $currentstring .= "\\texttt";
720: } elsif ($target eq 'latexsource') {
721: $currentstring .= "\\texttt{";
1.1 sakharuk 722: }
723: return $currentstring;
724: }
725: sub end_kbd {
726: my ($target,$token) = @_;
727: my $currentstring = '';
728: if ($target eq 'web') {
729: $currentstring .= $token->[2];
730: } elsif ($target eq 'tex') {
731: $currentstring .= "}";
1.18 sakharuk 732: } elsif ($target eq 'latexsource') {
733: $currentstring .= "}";
1.1 sakharuk 734: }
735: return $currentstring;
736: }
1.35 sakharuk 737: #-- <code> tag
1.1 sakharuk 738: sub start_code {
739: my ($target,$token) = @_;
740: my $currentstring = '';
741: if ($target eq 'web') {
742: $currentstring .= $token->[4];
743: } elsif ($target eq 'tex') {
1.35 sakharuk 744: $currentstring .= '\texttt{';
1.1 sakharuk 745: }
746: return $currentstring;
747: }
748: sub end_code {
749: my ($target,$token) = @_;
750: my $currentstring = '';
751: if ($target eq 'web') {
752: $currentstring .= $token->[2];
753: } elsif ($target eq 'tex') {
1.35 sakharuk 754: $currentstring .= '}';
1.1 sakharuk 755: }
756: return $currentstring;
757: }
1.35 sakharuk 758: #-- <em> tag
1.1 sakharuk 759: sub start_em {
760: my ($target,$token) = @_;
761: my $currentstring = '';
762: if ($target eq 'web') {
763: $currentstring .= $token->[4];
764: } elsif ($target eq 'tex') {
1.35 sakharuk 765: $currentstring .= '\emph{';
1.18 sakharuk 766: } elsif ($target eq 'latexsource') {
1.35 sakharuk 767: $currentstring .= '\emph{';
1.1 sakharuk 768: }
769: return $currentstring;
770: }
771: sub end_em {
772: my ($target,$token) = @_;
773: my $currentstring = '';
774: if ($target eq 'web') {
775: $currentstring .= $token->[2];
776: } elsif ($target eq 'tex') {
1.35 sakharuk 777: $currentstring .= '}';
1.18 sakharuk 778: } elsif ($target eq 'latexsource') {
1.35 sakharuk 779: $currentstring .= '}';
1.18 sakharuk 780: }
1.1 sakharuk 781: return $currentstring;
782: }
1.35 sakharuk 783: #-- <q> tag
1.1 sakharuk 784: sub start_q {
785: my ($target,$token) = @_;
786: my $currentstring = '';
787: if ($target eq 'web') {
788: $currentstring .= $token->[4];
789: } elsif ($target eq 'tex') {
1.18 sakharuk 790: $currentstring .= "\\emph{";
791: } elsif ($target eq 'latexsource') {
792: $currentstring .= "\\emph{";
793: }
1.1 sakharuk 794: return $currentstring;
795: }
796: sub end_q {
797: my ($target,$token) = @_;
798: my $currentstring = '';
799: if ($target eq 'web') {
800: $currentstring .= $token->[2];
801: } elsif ($target eq 'tex') {
802: $currentstring .= "}";
1.18 sakharuk 803: } elsif ($target eq 'latexsource') {
804: $currentstring .= "}";
805: }
1.1 sakharuk 806: return $currentstring;
807: }
1.35 sakharuk 808: #-- <p> tag
1.1 sakharuk 809: sub start_p {
810: my ($target,$token) = @_;
811: my $currentstring = '';
812: if ($target eq 'web') {
813: $currentstring .= $token->[4];
814: } elsif ($target eq 'tex') {
1.35 sakharuk 815: $currentstring .= '{\par ';
1.18 sakharuk 816: } elsif ($target eq 'latexsource') {
1.35 sakharuk 817: $currentstring .= '{\par ';
1.1 sakharuk 818: }
819: return $currentstring;
820: }
821: sub end_p {
822: my ($target,$token) = @_;
823: my $currentstring = '';
824: if ($target eq 'web') {
825: $currentstring .= $token->[2];
826: } elsif ($target eq 'tex') {
1.35 sakharuk 827: $currentstring .= '}';
1.18 sakharuk 828: } elsif ($target eq 'latexsource') {
1.35 sakharuk 829: $currentstring .= '}';
1.1 sakharuk 830: }
831: return $currentstring;
832: }
1.35 sakharuk 833: #-- <br> tag
1.1 sakharuk 834: sub start_br {
835: my ($target,$token) = @_;
836: my $currentstring = '';
837: if ($target eq 'web') {
838: $currentstring .= $token->[4];
839: } elsif ($target eq 'tex') {
1.41 sakharuk 840: $currentstring .= '\\\\';
1.18 sakharuk 841: } elsif ($target eq 'latexsource') {
1.35 sakharuk 842: $currentstring .= '\\';
1.1 sakharuk 843: }
844: return $currentstring;
845: }
846: sub end_br {
847: my ($target,$token) = @_;
848: my $currentstring = '';
849: if ($target eq 'web') {
850: $currentstring .= $token->[2];
851: }
852: return $currentstring;
853: }
1.35 sakharuk 854: #-- <big> tag
1.1 sakharuk 855: sub start_big {
856: my ($target,$token) = @_;
857: my $currentstring = '';
858: if ($target eq 'web') {
859: $currentstring .= $token->[4];
860: } elsif ($target eq 'tex') {
1.36 albertel 861: $currentstring .= '\large{';
1.18 sakharuk 862: } elsif ($target eq 'latexsource') {
1.41 sakharuk 863: $currentstring .= '{\Large ';
1.18 sakharuk 864: }
1.1 sakharuk 865: return $currentstring;
866: }
867: sub end_big {
868: my ($target,$token) = @_;
869: my $currentstring = '';
870: if ($target eq 'web') {
871: $currentstring .= $token->[2];
872: } elsif ($target eq 'tex') {
1.35 sakharuk 873: $currentstring .= '}';
1.18 sakharuk 874: } elsif ($target eq 'latexsource') {
1.35 sakharuk 875: $currentstring .= '}';
1.1 sakharuk 876: }
877: return $currentstring;
878: }
1.35 sakharuk 879: #-- <small> tag
1.1 sakharuk 880: sub start_small {
881: my ($target,$token) = @_;
882: my $currentstring = '';
883: if ($target eq 'web') {
884: $currentstring .= $token->[4];
885: } elsif ($target eq 'tex') {
1.41 sakharuk 886: $currentstring .= '{\footnotesize ';
1.18 sakharuk 887: } elsif ($target eq 'latexsource') {
1.41 sakharuk 888: $currentstring .= '{\footnotesize ';
1.1 sakharuk 889: }
890: return $currentstring;
891: }
892: sub end_small {
893: my ($target,$token) = @_;
894: my $currentstring = '';
895: if ($target eq 'web') {
896: $currentstring .= $token->[2];
897: } elsif ($target eq 'tex') {
1.35 sakharuk 898: $currentstring .= '}';
1.18 sakharuk 899: } elsif ($target eq 'latexsource') {
1.35 sakharuk 900: $currentstring .= '}';
1.1 sakharuk 901: }
902: return $currentstring;
903: }
1.35 sakharuk 904: #-- <basefont> tag
1.1 sakharuk 905: sub start_basefont {
1.14 albertel 906: my ($target,$token) = @_;
907: my $currentstring = '';
908: if ($target eq 'web') {
909: $currentstring = $token->[4];
910: }
911: return $currentstring;
912: }
913: sub end_basefont {
914: my ($target,$token) = @_;
915: my $currentstring = '';
916: if ($target eq 'web') {
917: $currentstring = $token->[4];
918: }
919: return $currentstring;
920: }
1.35 sakharuk 921: #-- <font> tag
1.1 sakharuk 922: sub start_font {
923: my ($target,$token) = @_;
924: my $currentstring = '';
925: if ($target eq 'web') {
926: $currentstring = $token->[4];
927: }
928: return $currentstring;
929: }
930: sub end_font {
931: my ($target,$token) = @_;
932: my $currentstring = '';
933: if ($target eq 'web') {
934: $currentstring = $token->[2];
935: }
936: return $currentstring;
937: }
1.35 sakharuk 938: #-- <strike> tag
1.1 sakharuk 939: sub start_strike {
940: my ($target,$token) = @_;
941: my $currentstring = '';
942: if ($target eq 'web') {
943: $currentstring .= $token->[4];
944: } elsif ($target eq 'tex') {
945: $currentstring .= "{\\underline ";
946: }
947: return $currentstring;
948: }
949: sub end_strike {
950: my ($target,$token) = @_;
951: my $currentstring = '';
952: if ($target eq 'web') {
953: $currentstring .= $token->[2];
954: } elsif ($target eq 'tex') {
955: $currentstring .= " }";
956: }
957: return $currentstring;
958: }
1.35 sakharuk 959: #-- <s> tag
1.1 sakharuk 960: sub start_s {
961: my ($target,$token) = @_;
962: my $currentstring = '';
963: if ($target eq 'web') {
964: $currentstring .= $token->[4];
965: } elsif ($target eq 'tex') {
966: $currentstring .= "{\\underline ";
967: }
968: return $currentstring;
969: }
970: sub end_s {
971: my ($target,$token) = @_;
972: my $currentstring = '';
973: if ($target eq 'web') {
974: $currentstring .= $token->[2];
975: } elsif ($target eq 'tex') {
976: $currentstring .= " }";
977: }
978: return $currentstring;
979: }
1.35 sakharuk 980: #-- <sub> tag
1.1 sakharuk 981: sub start_sub {
982: my ($target,$token) = @_;
983: my $currentstring = '';
984: if ($target eq 'web') {
985: $currentstring .= $token->[4];
986: } elsif ($target eq 'tex') {
987: $currentstring .= "\$_{ ";
988: }
989: return $currentstring;
990: }
991: sub end_sub {
992: my ($target,$token) = @_;
993: my $currentstring = '';
994: if ($target eq 'web') {
995: $currentstring .= $token->[2];
996: } elsif ($target eq 'tex') {
997: $currentstring .= " }\$";
998: }
999: return $currentstring;
1000: }
1.35 sakharuk 1001: #-- <sup> tag
1.1 sakharuk 1002: sub start_sup {
1003: my ($target,$token) = @_;
1004: my $currentstring = '';
1005: if ($target eq 'web') {
1006: $currentstring .= $token->[4];
1007: } elsif ($target eq 'tex') {
1008: $currentstring .= "\$^{ ";
1009: }
1010: return $currentstring;
1011: }
1012: sub end_sup {
1013: my ($target,$token) = @_;
1014: my $currentstring = '';
1015: if ($target eq 'web') {
1016: $currentstring .= $token->[2];
1017: } elsif ($target eq 'tex') {
1018: $currentstring .= " }\$";
1019: }
1020: return $currentstring;
1021: }
1.35 sakharuk 1022: #-- <hr> tag
1.1 sakharuk 1023: sub start_hr {
1024: my ($target,$token) = @_;
1025: my $currentstring = '';
1026: if ($target eq 'web') {
1027: $currentstring .= $token->[4];
1028: } elsif ($target eq 'tex') {
1029: $currentstring .= "\\hline ";
1.6 sakharuk 1030: }
1031: return $currentstring;
1032: }
1033: sub end_hr {
1034: my ($target,$token) = @_;
1035: my $currentstring = '';
1036: if ($target eq 'web') {
1037: $currentstring .= $token->[2];
1038: } elsif ($target eq 'tex') {
1.1 sakharuk 1039: }
1040: return $currentstring;
1041: }
1.35 sakharuk 1042: #-- <a> tag
1.1 sakharuk 1043: sub start_a {
1044: my ($target,$token) = @_;
1045: my $currentstring = '';
1046: if ($target eq 'web') {
1047: $currentstring .= $token->[4];
1048: } elsif ($target eq 'tex') {
1049: }
1050: return $currentstring;
1051: }
1052: sub end_a {
1.30 albertel 1053: my ($target,$token,$tagstack,$stackref) = @_;
1.1 sakharuk 1054: my $currentstring = '';
1055: if ($target eq 'web') {
1056: $currentstring .= $token->[2];
1057: } elsif ($target eq 'tex') {
1058: my $tempor_var = $stackref->[$#$stackref];
1059: if (index($tempor_var,'name') != -1 ) {
1060: $tempor_var =~ s/name=([^,]*),/$1/g;
1.15 sakharuk 1061: # $currentstring .= " \\label{$tempor_var}";
1.1 sakharuk 1062: } elsif (index($tempor_var,'href') != -1 ) {
1063: $tempor_var =~ s/href=([^,]*),/$1/g;
1064: $currentstring .= " \\ref{$tempor_var}";
1065: }
1066: }
1067: return $currentstring;
1068: }
1.35 sakharuk 1069: #-- <li> tag
1.1 sakharuk 1070: sub start_li {
1.30 albertel 1071: my ($target,$token,$tagstack,$stackref) = @_;
1.1 sakharuk 1072: my $currentstring = '';
1073: if ($target eq 'web') {
1074: $currentstring = $token->[4];
1075: } elsif ($target eq 'tex') {
1.15 sakharuk 1076: my $tempor_var = $stackref->[$#$stackref];
1.1 sakharuk 1077: if (index($tempor_var,'circle') != -1 ) {
1078: $currentstring .= " \\item[o] ";
1079: } elsif (index($tempor_var,'square') != -1 ) {
1080: $currentstring .= " \\item[$\Box$] ";
1.15 sakharuk 1081: } elsif ($tempor_var ne '') {
1082: $_ = $tempor_var;
1083: m/my\s*([^=]*)=/;
1084: $currentstring .= " \\item[$1] ";
1085: } else {
1.1 sakharuk 1086: $currentstring .= " \\item ";
1087: }
1088: }
1089: return $currentstring;
1090: }
1091: sub end_li {
1092: my ($target,$token) = @_;
1093: my $currentstring = '';
1094: if ($target eq 'web') {
1095: $currentstring = $token->[2];
1096: }
1097: return $currentstring;
1098: }
1.35 sakharuk 1099: #-- <u> tag
1.1 sakharuk 1100: sub start_u {
1101: my ($target,$token) = @_;
1102: my $currentstring = '';
1103: if ($target eq 'web') {
1104: $currentstring .= $token->[4];
1105: } elsif ($target eq 'tex') {
1106: $currentstring .= "{\\underline ";
1107: }
1108: return $currentstring;
1109: }
1110: sub end_u {
1111: my ($target,$token) = @_;
1112: my $currentstring = '';
1113: if ($target eq 'web') {
1114: $currentstring .= $token->[2];
1115: } elsif ($target eq 'tex') {
1116: $currentstring .= " }";
1117: }
1118: return $currentstring;
1119: }
1.35 sakharuk 1120: #-- <ul> tag
1.1 sakharuk 1121: sub start_ul {
1122: my ($target,$token) = @_;
1123: my $currentstring = '';
1124: if ($target eq 'web') {
1125: $currentstring = $token->[4];
1126: } elsif ($target eq 'tex') {
1.41 sakharuk 1127: $currentstring = '\begin{itemize}';
1.1 sakharuk 1128: }
1129: return $currentstring;
1130: }
1131: sub end_ul {
1132: my ($target,$token) = @_;
1133: my $currentstring = '';
1134: if ($target eq 'web') {
1135: $currentstring = $token->[2];
1136: } elsif ($target eq 'tex') {
1.41 sakharuk 1137: $currentstring = '\end{itemize}';
1.1 sakharuk 1138: }
1139: return $currentstring;
1140: }
1.35 sakharuk 1141: #-- <menu> tag
1.1 sakharuk 1142: sub start_menu {
1143: my ($target,$token) = @_;
1144: my $currentstring = '';
1145: if ($target eq 'web') {
1146: $currentstring = $token->[4];
1147: } elsif ($target eq 'tex') {
1148: $currentstring = " \\begin{itemize} ";
1149: }
1150: return $currentstring;
1151: }
1152: sub end_menu {
1153: my ($target,$token) = @_;
1154: my $currentstring = '';
1155: if ($target eq 'web') {
1156: $currentstring = $token->[2];
1157: } elsif ($target eq 'tex') {
1158: $currentstring = " \\end{itemize}";
1159: }
1160: return $currentstring;
1161: }
1.35 sakharuk 1162: #-- <dir> tag
1.1 sakharuk 1163: sub start_dir {
1164: my ($target,$token) = @_;
1165: my $currentstring = '';
1166: if ($target eq 'web') {
1167: $currentstring = $token->[4];
1168: } elsif ($target eq 'tex') {
1169: $currentstring = " \\begin{itemize} ";
1170: }
1171: return $currentstring;
1172: }
1173: sub end_dir {
1174: my ($target,$token) = @_;
1175: my $currentstring = '';
1176: if ($target eq 'web') {
1177: $currentstring = $token->[2];
1178: } elsif ($target eq 'tex') {
1179: $currentstring = " \\end{itemize}";
1180: }
1181: return $currentstring;
1182: }
1.35 sakharuk 1183: #-- <ol> tag
1.1 sakharuk 1184: sub start_ol {
1185: my ($target,$token) = @_;
1186: my $currentstring = '';
1187: if ($target eq 'web') {
1188: $currentstring = $token->[4];
1189: } elsif ($target eq 'tex') {
1.41 sakharuk 1190: $currentstring = '\begin{enumerate}';
1.1 sakharuk 1191: }
1192: return $currentstring;
1193: }
1194: sub end_ol {
1195: my ($target,$token) = @_;
1196: my $currentstring = '';
1197: if ($target eq 'web') {
1198: $currentstring = $token->[2];
1199: } elsif ($target eq 'tex') {
1.41 sakharuk 1200: $currentstring = '\end{enumerate}';
1.1 sakharuk 1201: }
1202: return $currentstring;
1203: }
1.35 sakharuk 1204: #-- <dl> tag
1.1 sakharuk 1205: sub start_dl {
1206: my ($target,$token) = @_;
1207: my $currentstring = '';
1208: if ($target eq 'web') {
1209: $currentstring = $token->[4];
1210: } elsif ($target eq 'tex') {
1.41 sakharuk 1211: $currentstring = '\begin{description}';
1.1 sakharuk 1212: }
1213: return $currentstring;
1214: }
1215: sub end_dl {
1216: my ($target,$token) = @_;
1217: my $currentstring = '';
1218: if ($target eq 'web') {
1219: $currentstring = $token->[2];
1220: } elsif ($target eq 'tex') {
1.41 sakharuk 1221: $currentstring = '\end{description}';
1.1 sakharuk 1222: }
1223: return $currentstring;
1224: }
1.35 sakharuk 1225: #-- <dt> tag
1.1 sakharuk 1226: sub start_dt {
1227: my ($target,$token) = @_;
1228: my $currentstring = '';
1229: if ($target eq 'web') {
1230: $currentstring = $token->[4];
1231: } elsif ($target eq 'tex') {
1.41 sakharuk 1232: $currentstring = '\item[';
1.1 sakharuk 1233: }
1234: return $currentstring;
1235: }
1236: sub end_dt {
1237: my ($target,$token) = @_;
1238: my $currentstring = '';
1239: if ($target eq 'web') {
1240: $currentstring = $token->[2];
1241: } elsif ($target eq 'tex') {
1.41 sakharuk 1242: $currentstring = ']';
1.1 sakharuk 1243: }
1244: return $currentstring;
1245: }
1.35 sakharuk 1246: #-- <dd> tag
1.1 sakharuk 1247: sub start_dd {
1248: my ($target,$token) = @_;
1249: my $currentstring = '';
1250: if ($target eq 'web') {
1251: $currentstring = $token->[4];
1252: }
1253: return $currentstring;
1254: }
1255: sub end_dd {
1256: my ($target,$token) = @_;
1257: my $currentstring = '';
1258: if ($target eq 'web') {
1259: $currentstring = $token->[2];
1260: }
1261: return $currentstring;
1262: }
1.35 sakharuk 1263: #-- <table> tag
1.1 sakharuk 1264: sub start_table {
1.50 sakharuk 1265: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1.1 sakharuk 1266: my $currentstring = '';
1267: if ($target eq 'web') {
1268: $currentstring = $token->[4];
1269: } elsif ($target eq 'tex') {
1.53 sakharuk 1270: my $aa = {};
1271: push @Apache::londefdef::table, $aa;
1272: $Apache::londefdef::table[-1]{'row_number'} = -1;
1273: $Apache::londefdef::table[-1]{'output'} = '\begin{tabular} ';
1.50 sakharuk 1274: my $border = &Apache::lonxml::get_param('border',$parstack,$safeeval);
1275: unless (defined $border) { $border = 0; }
1.51 sakharuk 1276: if ($border) {
1.53 sakharuk 1277: $Apache::londefdef::table[-1]{'hinc'} = '\hline ';
1278: $Apache::londefdef::table[-1]{'vinc'} = '&';
1279: $Apache::londefdef::table[-1]{'vvinc'} = '|';
1.52 sakharuk 1280: } else {
1.53 sakharuk 1281: $Apache::londefdef::table[-1]{'hinc'} = '';
1282: $Apache::londefdef::table[-1]{'vinc'} = '';
1283: $Apache::londefdef::table[-1]{'vvinc'} = '';
1.50 sakharuk 1284: }
1.51 sakharuk 1285: }
1286: return $currentstring;
1287: }
1288: sub end_table {
1289: my ($target,$token) = @_;
1290: my $currentstring = '';
1291: if ($target eq 'web') {
1292: $currentstring = $token->[2];
1293: } elsif ($target eq 'tex') {
1.53 sakharuk 1294: my $inmemory = '';
1.52 sakharuk 1295: my $output = '';
1.53 sakharuk 1296: my $header_of_table = '{'.$Apache::londefdef::table[-1]{'vvinc'};
1.50 sakharuk 1297: my $in;
1.53 sakharuk 1298: for ($in=0;$in<=$Apache::londefdef::table[-1]{'counter_columns'};$in++) {
1299: $header_of_table .= $Apache::londefdef::table[-1]{'columns'}[$in].$Apache::londefdef::table[-1]{'vvinc'};
1300: }
1301: $header_of_table .= '}';
1302: for ($in=0;$in<=$Apache::londefdef::table[-1]{'row_number'};$in++) {
1303: $output .= $Apache::londefdef::table[-1]{'rowdata'}[$in];
1.52 sakharuk 1304: chop $output;
1305: $output .= ' \\\\ ';
1.50 sakharuk 1306: }
1.53 sakharuk 1307: $Apache::londefdef::table[-1]{'output'} .= $header_of_table.$output.$Apache::londefdef::table[-1]{'hinc'}.'\end{tabular}';
1308: if ($#Apache::londefdef::table > 0) {
1309: $inmemory = $Apache::londefdef::table[-1]{'output'};
1310: pop @Apache::londefdef::table;
1311: $Apache::londefdef::table[-1]{'rowdata'}[$Apache::londefdef::table[-1]{'row_number'}] .= $inmemory;
1312: } else {
1313: $currentstring = $Apache::londefdef::table[-1]{'output'};
1314: $currentstring =~ s/\\\\\s+\\\\/\\\\/g;
1315: pop @Apache::londefdef::table;
1316: }
1.51 sakharuk 1317: }
1318: return $currentstring;
1319: }
1320: #-- <tr> tag
1321: sub start_tr {
1322: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1323: my $currentstring = '';
1324: if ($target eq 'web') {
1325: $currentstring = $token->[4];
1326: } elsif ($target eq 'tex') {
1.53 sakharuk 1327: $Apache::londefdef::table[-1]{'row_number'}++;
1328: my $alignchar = substr(&Apache::lonxml::get_param('align',$parstack,$safeeval),0,1);
1329: if ($alignchar ne '') {
1330: push @ {$Apache::londefdef::table[-1]{'rows'} }, $alignchar;
1.51 sakharuk 1331: } else {
1.53 sakharuk 1332: push @ {$Apache::londefdef::table[-1]{'rows'} }, 'c';
1.51 sakharuk 1333: }
1.53 sakharuk 1334: push ( @{ $Apache::londefdef::table[-1]{'rowdata'} }, $Apache::londefdef::table[-1]{'hinc'});
1335: $Apache::londefdef::table[-1]{'counter_columns'} = -1;
1.52 sakharuk 1336:
1.1 sakharuk 1337: }
1338: return $currentstring;
1.51 sakharuk 1339: }
1340: sub end_tr {
1341: my ($target,$token) = @_;
1342: my $currentstring = '';
1343: if ($target eq 'web') {
1344: $currentstring = $token->[2];
1345: } elsif ($target eq 'tex') {
1.53 sakharuk 1346: # $currentstring .= ' START ROW '. $Apache::londefdef::table[-1]{'rowdata'}[$Apache::londefdef::table[-1]{'row_number'}].' END ROW ';
1.51 sakharuk 1347: }
1348: return $currentstring;
1.1 sakharuk 1349: }
1.51 sakharuk 1350: #-- <td> tag
1351: sub start_td {
1352: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1353: my $currentstring = '';
1354: if ($target eq 'web') {
1355: $currentstring = $token->[4];
1356: } elsif ($target eq 'tex') {
1357: my $what_to_push = substr(&Apache::lonxml::get_param('align',$parstack,$safeeval),0,1);
1358: if ($what_to_push eq '') {
1.53 sakharuk 1359: $what_to_push = substr($Apache::londefdef::table[-1]{'rows'}[0],0,1);;
1.51 sakharuk 1360: }
1.53 sakharuk 1361: push @{ $Apache::londefdef::table[-1]{'columns'} }, $what_to_push;
1362: $Apache::londefdef::table[-1]{'counter_columns'}++;
1.52 sakharuk 1363: &Apache::lonxml::startredirection();
1364: ;
1.51 sakharuk 1365: }
1366: return $currentstring;
1367: }
1368: sub end_td {
1.1 sakharuk 1369: my ($target,$token) = @_;
1370: my $currentstring = '';
1371: if ($target eq 'web') {
1.51 sakharuk 1372: $currentstring = $token->[2];
1373: } elsif ($target eq 'tex') {
1.53 sakharuk 1374: my $current_row = $Apache::londefdef::table[-1]{'row_number'};
1.52 sakharuk 1375: my $data=&Apache::lonxml::endredirection();
1.53 sakharuk 1376: @{ $Apache::londefdef::table[-1]{'rowdata'} }[$current_row] .= $data.' '.$Apache::londefdef::table[-1]{'vinc'};
1.44 sakharuk 1377: }
1.1 sakharuk 1378: return $currentstring;
1379: }
1.35 sakharuk 1380: #-- <img> tag
1.10 www 1381: sub start_img {
1.41 sakharuk 1382: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1.44 sakharuk 1383: $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=
1.10 www 1384: $token->[2]->{'src'};
1385: my $currentstring = '';
1.44 sakharuk 1386:
1.42 albertel 1387: if ($target eq 'web') {
1.10 www 1388: $currentstring = $token->[4];
1389: } elsif ($target eq 'tex') {
1.42 albertel 1390: my $src = &Apache::lonxml::get_param('src',$parstack,$safeeval);
1.54 sakharuk 1391: $src=&Apache::lonnet::filelocation($Apache::lonxml::pwd[-1],$src);
1.42 albertel 1392: my $file;
1.55 ! sakharuk 1393: my $path;
! 1394: if ($src =~ m!(.*)/([^/]*)$!) {
! 1395: $file = $2;
! 1396: $path = $1;
! 1397: } else {
! 1398: $path = $Apache::lonxml::pwd[-1];
! 1399: $file = $src;
! 1400: }
1.43 albertel 1401: $file=~s/(\.gif|\.jpg)$/\.eps/;
1.42 albertel 1402: if ($path) {
1.54 sakharuk 1403: $currentstring .= '\graphicspath{{'.$path.'/}}\fbox{\includegraphics{'.$file.'}}';
1.42 albertel 1404: } else {
1.54 sakharuk 1405: $currentstring .= 'See the image at \tt{'.$src.'}';
1.42 albertel 1406: }
1407: }
1408: return $currentstring;
1.10 www 1409: }
1410: sub end_img {
1411: my ($target,$token) = @_;
1412: my $currentstring = '';
1413: if ($target eq 'web') {
1.44 sakharuk 1414: $currentstring = $token->[2];
1.10 www 1415: } elsif ($target eq 'tex') {
1.44 sakharuk 1416: $currentstring = '';
1417: }
1.10 www 1418: return $currentstring;
1419: }
1.35 sakharuk 1420: #-- <applet> tag
1.10 www 1421:
1422: sub start_applet {
1423: my ($target,$token) = @_;
1424: $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=
1425: $token->[2]->{'code'};
1.44 sakharuk 1426: $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=
1.10 www 1427: $token->[2]->{'archive'};
1428: my $currentstring = '';
1429: if ($target eq 'web') {
1.44 sakharuk 1430: $currentstring = $token->[4];
1.10 www 1431: } elsif ($target eq 'tex') {
1.44 sakharuk 1432: $currentstring = " \\begin{figure} ";
1.10 www 1433: }
1434: return $currentstring;
1435: }
1.44 sakharuk 1436: sub end_applet {
1437: my ($target,$token) = @_;
1438: my $currentstring = '';
1439: if ($target eq 'web') {
1440: $currentstring = $token->[2];
1441: } elsif ($target eq 'tex') {
1442: $currentstring = " \\end{figure}";
1443: }
1444: return $currentstring;
1445: }
1.10 www 1446:
1.35 sakharuk 1447: #-- <embed> tag
1.10 www 1448:
1.45 sakharuk 1449: sub start_embed {
1.44 sakharuk 1450: my ($target,$token) = @_;
1451: $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=
1452: $token->[2]->{'src'};
1453: my $currentstring = '';
1454: if ($target eq 'web') {
1455: $currentstring = $token->[4];
1456: } elsif ($target eq 'tex') {
1457: $currentstring = " \\begin{figure} ";
1458: }
1459: return $currentstring;
1460: }
1.10 www 1461: sub end_embed {
1462: my ($target,$token) = @_;
1463: my $currentstring = '';
1464: if ($target eq 'web') {
1465: $currentstring = $token->[2];
1466: } elsif ($target eq 'tex') {
1467: $currentstring = " \\end{figure}";
1468: }
1469: return $currentstring;
1470: }
1471:
1.35 sakharuk 1472: #-- <param> tag
1.10 www 1473:
1.11 www 1474: sub start_param {
1.10 www 1475: my ($target,$token) = @_;
1476: if ($token->[2]->{'name'} eq 'cabbase') {
1477: $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=
1478: $token->[2]->{'value'};
1479: }
1.20 www 1480: $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=
1.10 www 1481: $token->[2]->{'src'};
1482: my $currentstring = '';
1483: if ($target eq 'web') {
1484: $currentstring = $token->[4];
1485: } elsif ($target eq 'tex') {
1486: $currentstring = " \\begin{figure} ";
1487: }
1488: return $currentstring;
1489: }
1.11 www 1490: sub end_param {
1.10 www 1491: my ($target,$token) = @_;
1492: my $currentstring = '';
1493: if ($target eq 'web') {
1494: $currentstring = $token->[2];
1495: } elsif ($target eq 'tex') {
1496: $currentstring = " \\end{figure}";
1497: }
1498: return $currentstring;
1499: }
1500:
1.35 sakharuk 1501: #-- <allow> tag
1.10 www 1502:
1503: sub start_allow {
1504: my ($target,$token) = @_;
1505:
1.20 www 1506: $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=
1.10 www 1507: $token->[2]->{'src'};
1508:
1509: return '';
1510: }
1511: sub end_allow {
1512: return '';
1513: }
1.35 sakharuk 1514: #-- Frames
1.31 albertel 1515: sub start_frameset {
1516: my ($target,$token) = @_;
1517: my $currentstring = '';
1518: if ($target eq 'web') {
1519: if (!$Apache::lonxml::registered) {
1.47 matthew 1520: $currentstring.='<head>'.
1521: &Apache::lonxml::registerurl(undef,$target).'</head>';
1.31 albertel 1522: }
1523: $currentstring .= $token->[4];
1524: }
1525: return $currentstring;
1526: }
1527: sub end_frameset {
1528: my ($target,$token) = @_;
1529: my $currentstring = '';
1530: if ($target eq 'web') {
1531: $currentstring = $token->[2];
1532: }
1533: return $currentstring;
1.41 sakharuk 1534: }
1535: #-- <pre>
1536: sub start_pre {
1537: my ($target,$token) = @_;
1538: my $currentstring = '';
1539: if ($target eq 'web') {
1540: $currentstring .= $token->[4];
1541: } elsif ($target eq 'tex') {
1542: $currentstring .= '\begin{verbatim}';
1543: }
1544: return $currentstring;
1545: }
1546: sub end_pre {
1547: my ($target,$token) = @_;
1548: my $currentstring = '';
1549: if ($target eq 'web') {
1550: $currentstring .= $token->[2];
1551: } elsif ($target eq 'tex') {
1552: $currentstring .= '\end{verbatim}';
1.44 sakharuk 1553: }
1554: return $currentstring;
1555: }
1556: #-- <insert>
1557: sub start_insert {
1.46 sakharuk 1558: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1.44 sakharuk 1559: my $currentstring = '';
1560: if ($target eq 'web') {
1.46 sakharuk 1561: my $display = &Apache::lonxml::get_param('display',$parstack,$safeeval);
1562: $currentstring .= '<b>'.$display.'</b>';;
1.44 sakharuk 1563: }
1564: return $currentstring;
1565: }
1566: sub end_insert {
1.48 sakharuk 1567: my ($target,$token) = @_;
1568: my $currentstring = '';
1569: if ($target eq 'web') {
1570: $currentstring .= '';
1571: }
1572: return $currentstring;
1573: }
1574: #-- <externallink>
1575: sub start_externallink {
1576: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1577: my $currentstring = '';
1578: if ($target eq 'web') {
1579: my $display = &Apache::lonxml::get_param('display',$parstack,$safeeval);
1580: $currentstring .= '<b>'.$display.'</b>';;
1581: }
1582: return $currentstring;
1583: }
1584: sub end_externallink {
1.44 sakharuk 1585: my ($target,$token) = @_;
1586: my $currentstring = '';
1587: if ($target eq 'web') {
1588: $currentstring .= '';
1.41 sakharuk 1589: }
1590: return $currentstring;
1.31 albertel 1591: }
1.1 sakharuk 1592: 1;
1593: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>