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