Annotation of loncom/xml/londefdef.pm, revision 1.59
1.44 sakharuk 1:
1.1 sakharuk 2: # The LearningOnline Network with CAPA
3: # Tags Default Definition Module
4: #
1.59 ! sakharuk 5: # $Id: londefdef.pm,v 1.58 2002/05/09 18:55:47 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.57 sakharuk 51: use Apache::File();
1.54 sakharuk 52:
1.38 harris41 53: BEGIN {
1.15 sakharuk 54:
1.59 ! 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','th','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: }
1.56 albertel 340: $token->[2]->{'onLoad'}=&Apache::lonxml::loadevents().
341: ';'.$onLoad;
1.32 albertel 342: my $onUnload='';
343: foreach my $key (keys(%{$token->[2]})) {
344: if ($key =~ /^onunload$/i) {
345: $onUnload.=$token->[2]->{$key}.';';
346: delete($token->[2]->{$key});
347: }
348: }
1.56 albertel 349: $token->[2]->{'onUnload'}=&Apache::lonxml::unloadevents().
350: ';'.$onUnload;
1.31 albertel 351:
352: $currentstring .= '<'.$token->[1];
1.37 albertel 353: foreach (keys %{$token->[2]}) {
354: $currentstring.=' '.$_.'="'.$token->[2]->{$_}.'"';
355: }
1.31 albertel 356: $currentstring.='>';
1.40 albertel 357: if ($ENV{'request.state'} ne 'published') {
358: $currentstring.=(<<EDITBUTTON);
359: <form method="post">
1.49 albertel 360: <input type="submit" name="editmode" value="Edit" />
1.40 albertel 361: </form>
362: EDITBUTTON
363: }
1.28 www 364: } elsif ($target eq 'tex') {
1.35 sakharuk 365: $currentstring = '\begin{document}';
1.1 sakharuk 366: }
367: return $currentstring;
368: }
369: sub end_body {
370: my ($target,$token) = @_;
371: my $currentstring = '';
372: if ($target eq 'web') {
373: $currentstring = $token->[2];
374: } elsif ($target eq 'tex') {
1.35 sakharuk 375: $currentstring = '\end{document}';
1.1 sakharuk 376: }
377: return $currentstring;
378: }
1.35 sakharuk 379: #-- <center> tag
1.1 sakharuk 380: sub start_center {
381: my ($target,$token) = @_;
382: my $currentstring = '';
383: if ($target eq 'web') {
384: $currentstring = $token->[4];
385: } elsif ($target eq 'tex') {
1.35 sakharuk 386: $currentstring = '\begin{center}';
1.18 sakharuk 387: } elsif ($target eq 'latexsource') {
1.35 sakharuk 388: $currentstring = '\begin{center}';
1.1 sakharuk 389: }
390: return $currentstring;
391: }
392: sub end_center {
393: my ($target,$token) = @_;
394: my $currentstring = '';
395: if ($target eq 'web') {
396: $currentstring = $token->[2];
397: } elsif ($target eq 'tex') {
1.35 sakharuk 398: $currentstring = '\end{center}';
1.18 sakharuk 399: } elsif ($target eq 'latexsource') {
1.35 sakharuk 400: $currentstring = '\end{center}';
1.1 sakharuk 401: }
402: return $currentstring;
403: }
1.35 sakharuk 404: #-- <b> tag
1.1 sakharuk 405: sub start_b {
406: my ($target,$token) = @_;
407: my $currentstring = '';
408: if ($target eq 'web') {
409: $currentstring = $token->[4];
410: } elsif ($target eq 'tex') {
1.35 sakharuk 411: $currentstring = '\textbf{';
1.18 sakharuk 412: } elsif ($target eq 'latexsource') {
1.35 sakharuk 413: $currentstring = '\textbf{';
1.1 sakharuk 414: }
415: return $currentstring;
416: }
417: sub end_b {
418: my ($target,$token) = @_;
419: my $currentstring = '';
420: if ($target eq 'web') {
421: $currentstring = $token->[2];
422: } elsif ($target eq 'tex') {
1.35 sakharuk 423: $currentstring = '}';
424:
1.18 sakharuk 425: } elsif ($target eq 'latexsource') {
1.35 sakharuk 426: $currentstring = '}';
1.1 sakharuk 427: }
428: return $currentstring;
429: }
1.35 sakharuk 430: #-- <strong> tag
1.1 sakharuk 431: sub start_strong {
432: my ($target,$token) = @_;
433: my $currentstring = '';
434: if ($target eq 'web') {
435: $currentstring = $token->[4];
436: } elsif ($target eq 'tex') {
1.35 sakharuk 437: $currentstring = '\textbf{';
1.18 sakharuk 438: } elsif ($target eq 'latexsource') {
1.35 sakharuk 439: $currentstring = '\textbf{';
1.1 sakharuk 440: }
441: return $currentstring;
442: }
443: sub end_strong {
444: my ($target,$token) = @_;
445: my $currentstring = '';
446: if ($target eq 'web') {
447:
448: $currentstring = $token->[2];
449: } elsif ($target eq 'tex') {
1.35 sakharuk 450: $currentstring = '}';
1.18 sakharuk 451: } elsif ($target eq 'latexsource') {
1.35 sakharuk 452: $currentstring = '}';
1.1 sakharuk 453: }
454: return $currentstring;
455: }
1.35 sakharuk 456: #-- <h1> tag
1.1 sakharuk 457: sub start_h1 {
458: my ($target,$token) = @_;
459: my $currentstring = '';
460: if ($target eq 'web') {
461: $currentstring .= $token->[4];
462: } elsif ($target eq 'tex') {
1.35 sakharuk 463: $currentstring .= '\large{\textbf{';
1.13 www 464: } elsif ($target eq 'meta') {
465: $currentstring='<subject>';
466: &start_output();
467: }
1.1 sakharuk 468: return $currentstring;
469: }
470: sub end_h1 {
471: my ($target,$token) = @_;
472: my $currentstring = '';
473: if ($target eq 'web') {
474: $currentstring .= $token->[2];
475: } elsif ($target eq 'tex') {
1.35 sakharuk 476: $currentstring .= '}}';
1.13 www 477: } elsif ($target eq 'meta') {
478: &end_output();
479: $currentstring='</subject>';
480: }
1.1 sakharuk 481: return $currentstring;
482: }
1.35 sakharuk 483: #-- <h2> tag
1.1 sakharuk 484: sub start_h2 {
485: my ($target,$token) = @_;
486: my $currentstring = '';
487: if ($target eq 'web') {
488: $currentstring .= $token->[4];
489: } elsif ($target eq 'tex') {
1.35 sakharuk 490: $currentstring .= '\large{\textbf{';
1.1 sakharuk 491: }
492: return $currentstring;
493: }
494: sub end_h2 {
495: my ($target,$token) = @_;
496: my $currentstring = '';
497: if ($target eq 'web') {
498: $currentstring .= $token->[2];
499: } elsif ($target eq 'tex') {
1.35 sakharuk 500: $currentstring .= '}}';
1.1 sakharuk 501: }
502: return $currentstring;
503: }
1.35 sakharuk 504: #-- <h3> tag
1.1 sakharuk 505: sub start_h3 {
506: my ($target,$token) = @_;
507: my $currentstring = '';
508: if ($target eq 'web') {
509: $currentstring .= $token->[4];
510: } elsif ($target eq 'tex') {
1.35 sakharuk 511: $currentstring .= '\large{\textbf{';
1.1 sakharuk 512: }
513: return $currentstring;
514: }
515: sub end_h3 {
516: my ($target,$token) = @_;
517: my $currentstring = '';
518: if ($target eq 'web') {
519: $currentstring .= $token->[2];
520: } elsif ($target eq 'tex') {
1.35 sakharuk 521: $currentstring .= '}}';
1.1 sakharuk 522: }
523: return $currentstring;
524: }
1.35 sakharuk 525: #-- <h4> tag
1.1 sakharuk 526: sub start_h4 {
527: my ($target,$token) = @_;
528: my $currentstring = '';
529: if ($target eq 'web') {
530: $currentstring .= $token->[4];
531: } elsif ($target eq 'tex') {
1.41 sakharuk 532: $currentstring .= '\large{\textbf{';
1.1 sakharuk 533: }
534: return $currentstring;
535: }
536: sub end_h4 {
537: my ($target,$token) = @_;
538: my $currentstring = '';
539: if ($target eq 'web') {
540: $currentstring .= $token->[2];
541: } elsif ($target eq 'tex') {
1.35 sakharuk 542: $currentstring .= '}}';
1.1 sakharuk 543: }
544: return $currentstring;
545: }
1.35 sakharuk 546: #-- <h5> tag
1.1 sakharuk 547: sub start_h5 {
548: my ($target,$token) = @_;
549: my $currentstring = '';
550: if ($target eq 'web') {
551: $currentstring .= $token->[4];
552: } elsif ($target eq 'tex') {
1.35 sakharuk 553: $currentstring .= '\large{\textbf{';
1.1 sakharuk 554: }
555: return $currentstring;
556: }
557: sub end_h5 {
558: my ($target,$token) = @_;
559: my $currentstring = '';
560: if ($target eq 'web') {
561: $currentstring .= $token->[2];
562: } elsif ($target eq 'tex') {
1.35 sakharuk 563: $currentstring .= '}}';
1.1 sakharuk 564: }
565: return $currentstring;
566: }
1.35 sakharuk 567: #-- <h6> tag
1.1 sakharuk 568: sub start_h6 {
569: my ($target,$token) = @_;
570: my $currentstring = '';
571: if ($target eq 'web') {
572: $currentstring .= $token->[4];
573: } elsif ($target eq 'tex') {
1.35 sakharuk 574: $currentstring .= '\large{\textbf{';
1.1 sakharuk 575: }
576: return $currentstring;
577: }
578: sub end_h6 {
579: my ($target,$token) = @_;
580: my $currentstring = '';
581: if ($target eq 'web') {
582: $currentstring .= $token->[2];
583: } elsif ($target eq 'tex') {
1.35 sakharuk 584: $currentstring .= '}}';
1.1 sakharuk 585: }
586: return $currentstring;
587: }
1.35 sakharuk 588: #--- <cite> tag
1.1 sakharuk 589: sub start_cite {
590: my ($target,$token) = @_;
591: my $currentstring = '';
592: if ($target eq 'web') {
593: $currentstring .= $token->[4];
594: } elsif ($target eq 'tex') {
1.18 sakharuk 595: $currentstring .= "\\textit{";
596: } elsif ($target eq 'latexsource') {
597: $currentstring .= "\\textit{";
1.1 sakharuk 598: }
599: return $currentstring;
600: }
601: sub end_cite {
602: my ($target,$token) = @_;
603: my $currentstring = '';
604: if ($target eq 'web') {
605: $currentstring .= $token->[2];
606: } elsif ($target eq 'tex') {
607: $currentstring .= "}";
1.18 sakharuk 608: } elsif ($target eq 'latexsource') {
609: $currentstring .= "}";
1.1 sakharuk 610: }
611: return $currentstring;
612: }
1.35 sakharuk 613: #-- <i> tag
1.1 sakharuk 614: sub start_i {
615: my ($target,$token) = @_;
616: my $currentstring = '';
617: if ($target eq 'web') {
618: $currentstring .= $token->[4];
619: } elsif ($target eq 'tex') {
1.35 sakharuk 620: $currentstring .= '\textit{';
1.18 sakharuk 621: } elsif ($target eq 'latexsource') {
1.35 sakharuk 622: $currentstring .= '\textit{';
1.1 sakharuk 623: }
624: return $currentstring;
625: }
626: sub end_i {
627: my ($target,$token) = @_;
628: my $currentstring = '';
629: if ($target eq 'web') {
630: $currentstring .= $token->[2];
631: } elsif ($target eq 'tex') {
1.35 sakharuk 632: $currentstring .= '}';
1.18 sakharuk 633: } elsif ($target eq 'latexsource') {
1.35 sakharuk 634: $currentstring .= '}';
1.1 sakharuk 635: }
636: return $currentstring;
637: }
1.35 sakharuk 638: #-- <address> tag
1.1 sakharuk 639: sub start_address {
640: my ($target,$token) = @_;
641: my $currentstring = '';
642: if ($target eq 'web') {
643: $currentstring .= $token->[4];
644: } elsif ($target eq 'tex') {
1.18 sakharuk 645: $currentstring .= "\\textit{";
646: } elsif ($target eq 'latexsource') {
647: $currentstring .= "\\textit{";
1.1 sakharuk 648: }
649: return $currentstring;
650: }
651: sub end_address {
652: my ($target,$token) = @_;
653: my $currentstring = '';
654: if ($target eq 'web') {
655: $currentstring .= $token->[2];
656: } elsif ($target eq 'tex') {
657: $currentstring .= "}";
1.18 sakharuk 658: } elsif ($target eq 'latexsource') {
659: $currentstring .= "}";
1.1 sakharuk 660: }
661: return $currentstring;
662: }
1.35 sakharuk 663: #-- <dfn> tag
1.1 sakharuk 664: sub start_dfn {
665: my ($target,$token) = @_;
666: my $currentstring = '';
667: if ($target eq 'web') {
668: $currentstring .= $token->[4];
669: } elsif ($target eq 'tex') {
1.18 sakharuk 670: $currentstring .= "\\textit{";
671: } elsif ($target eq 'latexsource') {
672: $currentstring .= "\\textit{";
1.1 sakharuk 673: }
674: return $currentstring;
675: }
676: sub end_dfn {
677: my ($target,$token) = @_;
678: my $currentstring = '';
679: if ($target eq 'web') {
680: $currentstring .= $token->[2];
681: } elsif ($target eq 'tex') {
682: $currentstring .= "}";
1.18 sakharuk 683: } elsif ($target eq 'latexsource') {
684: $currentstring .= "}";
1.1 sakharuk 685: }
686: return $currentstring;
687: }
1.35 sakharuk 688: #-- <tt> tag
1.1 sakharuk 689: sub start_tt {
690: my ($target,$token) = @_;
691: my $currentstring = '';
692: if ($target eq 'web') {
693: $currentstring .= $token->[4];
694: } elsif ($target eq 'tex') {
1.35 sakharuk 695: $currentstring .= '\texttt{';
1.18 sakharuk 696: } elsif ($target eq 'latexsource') {
1.35 sakharuk 697: $currentstring .= '\texttt{';
1.1 sakharuk 698: }
699: return $currentstring;
700: }
701: sub end_tt {
702: my ($target,$token) = @_;
703: my $currentstring = '';
704: if ($target eq 'web') {
705: $currentstring .= $token->[2];
706: } elsif ($target eq 'tex') {
1.35 sakharuk 707: $currentstring .= '}';
1.18 sakharuk 708: } elsif ($target eq 'latexsource') {
1.35 sakharuk 709: $currentstring .= '}';
1.18 sakharuk 710: }
1.1 sakharuk 711: return $currentstring;
712: }
1.35 sakharuk 713: #-- <kbd> tag
1.1 sakharuk 714: sub start_kbd {
715: my ($target,$token) = @_;
716: my $currentstring = '';
717: if ($target eq 'web') {
718: $currentstring .= $token->[4];
719: } elsif ($target eq 'tex') {
1.18 sakharuk 720: $currentstring .= "\\texttt";
721: } elsif ($target eq 'latexsource') {
722: $currentstring .= "\\texttt{";
1.1 sakharuk 723: }
724: return $currentstring;
725: }
726: sub end_kbd {
727: my ($target,$token) = @_;
728: my $currentstring = '';
729: if ($target eq 'web') {
730: $currentstring .= $token->[2];
731: } elsif ($target eq 'tex') {
732: $currentstring .= "}";
1.18 sakharuk 733: } elsif ($target eq 'latexsource') {
734: $currentstring .= "}";
1.1 sakharuk 735: }
736: return $currentstring;
737: }
1.35 sakharuk 738: #-- <code> tag
1.1 sakharuk 739: sub start_code {
740: my ($target,$token) = @_;
741: my $currentstring = '';
742: if ($target eq 'web') {
743: $currentstring .= $token->[4];
744: } elsif ($target eq 'tex') {
1.35 sakharuk 745: $currentstring .= '\texttt{';
1.1 sakharuk 746: }
747: return $currentstring;
748: }
749: sub end_code {
750: my ($target,$token) = @_;
751: my $currentstring = '';
752: if ($target eq 'web') {
753: $currentstring .= $token->[2];
754: } elsif ($target eq 'tex') {
1.35 sakharuk 755: $currentstring .= '}';
1.1 sakharuk 756: }
757: return $currentstring;
758: }
1.35 sakharuk 759: #-- <em> tag
1.1 sakharuk 760: sub start_em {
761: my ($target,$token) = @_;
762: my $currentstring = '';
763: if ($target eq 'web') {
764: $currentstring .= $token->[4];
765: } elsif ($target eq 'tex') {
1.35 sakharuk 766: $currentstring .= '\emph{';
1.18 sakharuk 767: } elsif ($target eq 'latexsource') {
1.35 sakharuk 768: $currentstring .= '\emph{';
1.1 sakharuk 769: }
770: return $currentstring;
771: }
772: sub end_em {
773: my ($target,$token) = @_;
774: my $currentstring = '';
775: if ($target eq 'web') {
776: $currentstring .= $token->[2];
777: } elsif ($target eq 'tex') {
1.35 sakharuk 778: $currentstring .= '}';
1.18 sakharuk 779: } elsif ($target eq 'latexsource') {
1.35 sakharuk 780: $currentstring .= '}';
1.18 sakharuk 781: }
1.1 sakharuk 782: return $currentstring;
783: }
1.35 sakharuk 784: #-- <q> tag
1.1 sakharuk 785: sub start_q {
786: my ($target,$token) = @_;
787: my $currentstring = '';
788: if ($target eq 'web') {
789: $currentstring .= $token->[4];
790: } elsif ($target eq 'tex') {
1.18 sakharuk 791: $currentstring .= "\\emph{";
792: } elsif ($target eq 'latexsource') {
793: $currentstring .= "\\emph{";
794: }
1.1 sakharuk 795: return $currentstring;
796: }
797: sub end_q {
798: my ($target,$token) = @_;
799: my $currentstring = '';
800: if ($target eq 'web') {
801: $currentstring .= $token->[2];
802: } elsif ($target eq 'tex') {
803: $currentstring .= "}";
1.18 sakharuk 804: } elsif ($target eq 'latexsource') {
805: $currentstring .= "}";
806: }
1.1 sakharuk 807: return $currentstring;
808: }
1.35 sakharuk 809: #-- <p> tag
1.1 sakharuk 810: sub start_p {
811: my ($target,$token) = @_;
812: my $currentstring = '';
813: if ($target eq 'web') {
814: $currentstring .= $token->[4];
815: } elsif ($target eq 'tex') {
1.35 sakharuk 816: $currentstring .= '{\par ';
1.18 sakharuk 817: } elsif ($target eq 'latexsource') {
1.35 sakharuk 818: $currentstring .= '{\par ';
1.1 sakharuk 819: }
820: return $currentstring;
821: }
822: sub end_p {
823: my ($target,$token) = @_;
824: my $currentstring = '';
825: if ($target eq 'web') {
826: $currentstring .= $token->[2];
827: } elsif ($target eq 'tex') {
1.35 sakharuk 828: $currentstring .= '}';
1.18 sakharuk 829: } elsif ($target eq 'latexsource') {
1.35 sakharuk 830: $currentstring .= '}';
1.1 sakharuk 831: }
832: return $currentstring;
833: }
1.35 sakharuk 834: #-- <br> tag
1.1 sakharuk 835: sub start_br {
836: my ($target,$token) = @_;
837: my $currentstring = '';
838: if ($target eq 'web') {
839: $currentstring .= $token->[4];
840: } elsif ($target eq 'tex') {
1.41 sakharuk 841: $currentstring .= '\\\\';
1.18 sakharuk 842: } elsif ($target eq 'latexsource') {
1.35 sakharuk 843: $currentstring .= '\\';
1.1 sakharuk 844: }
845: return $currentstring;
846: }
847: sub end_br {
848: my ($target,$token) = @_;
849: my $currentstring = '';
850: if ($target eq 'web') {
851: $currentstring .= $token->[2];
852: }
853: return $currentstring;
854: }
1.35 sakharuk 855: #-- <big> tag
1.1 sakharuk 856: sub start_big {
857: my ($target,$token) = @_;
858: my $currentstring = '';
859: if ($target eq 'web') {
860: $currentstring .= $token->[4];
861: } elsif ($target eq 'tex') {
1.36 albertel 862: $currentstring .= '\large{';
1.18 sakharuk 863: } elsif ($target eq 'latexsource') {
1.41 sakharuk 864: $currentstring .= '{\Large ';
1.18 sakharuk 865: }
1.1 sakharuk 866: return $currentstring;
867: }
868: sub end_big {
869: my ($target,$token) = @_;
870: my $currentstring = '';
871: if ($target eq 'web') {
872: $currentstring .= $token->[2];
873: } elsif ($target eq 'tex') {
1.35 sakharuk 874: $currentstring .= '}';
1.18 sakharuk 875: } elsif ($target eq 'latexsource') {
1.35 sakharuk 876: $currentstring .= '}';
1.1 sakharuk 877: }
878: return $currentstring;
879: }
1.35 sakharuk 880: #-- <small> tag
1.1 sakharuk 881: sub start_small {
882: my ($target,$token) = @_;
883: my $currentstring = '';
884: if ($target eq 'web') {
885: $currentstring .= $token->[4];
886: } elsif ($target eq 'tex') {
1.41 sakharuk 887: $currentstring .= '{\footnotesize ';
1.18 sakharuk 888: } elsif ($target eq 'latexsource') {
1.41 sakharuk 889: $currentstring .= '{\footnotesize ';
1.1 sakharuk 890: }
891: return $currentstring;
892: }
893: sub end_small {
894: my ($target,$token) = @_;
895: my $currentstring = '';
896: if ($target eq 'web') {
897: $currentstring .= $token->[2];
898: } elsif ($target eq 'tex') {
1.35 sakharuk 899: $currentstring .= '}';
1.18 sakharuk 900: } elsif ($target eq 'latexsource') {
1.35 sakharuk 901: $currentstring .= '}';
1.1 sakharuk 902: }
903: return $currentstring;
904: }
1.35 sakharuk 905: #-- <basefont> tag
1.1 sakharuk 906: sub start_basefont {
1.14 albertel 907: my ($target,$token) = @_;
908: my $currentstring = '';
909: if ($target eq 'web') {
910: $currentstring = $token->[4];
911: }
912: return $currentstring;
913: }
914: sub end_basefont {
915: my ($target,$token) = @_;
916: my $currentstring = '';
917: if ($target eq 'web') {
918: $currentstring = $token->[4];
919: }
920: return $currentstring;
921: }
1.35 sakharuk 922: #-- <font> tag
1.1 sakharuk 923: sub start_font {
924: my ($target,$token) = @_;
925: my $currentstring = '';
926: if ($target eq 'web') {
927: $currentstring = $token->[4];
928: }
929: return $currentstring;
930: }
931: sub end_font {
932: my ($target,$token) = @_;
933: my $currentstring = '';
934: if ($target eq 'web') {
935: $currentstring = $token->[2];
936: }
937: return $currentstring;
938: }
1.35 sakharuk 939: #-- <strike> tag
1.1 sakharuk 940: sub start_strike {
941: my ($target,$token) = @_;
942: my $currentstring = '';
943: if ($target eq 'web') {
944: $currentstring .= $token->[4];
945: } elsif ($target eq 'tex') {
946: $currentstring .= "{\\underline ";
947: }
948: return $currentstring;
949: }
950: sub end_strike {
951: my ($target,$token) = @_;
952: my $currentstring = '';
953: if ($target eq 'web') {
954: $currentstring .= $token->[2];
955: } elsif ($target eq 'tex') {
956: $currentstring .= " }";
957: }
958: return $currentstring;
959: }
1.35 sakharuk 960: #-- <s> tag
1.1 sakharuk 961: sub start_s {
962: my ($target,$token) = @_;
963: my $currentstring = '';
964: if ($target eq 'web') {
965: $currentstring .= $token->[4];
966: } elsif ($target eq 'tex') {
967: $currentstring .= "{\\underline ";
968: }
969: return $currentstring;
970: }
971: sub end_s {
972: my ($target,$token) = @_;
973: my $currentstring = '';
974: if ($target eq 'web') {
975: $currentstring .= $token->[2];
976: } elsif ($target eq 'tex') {
977: $currentstring .= " }";
978: }
979: return $currentstring;
980: }
1.35 sakharuk 981: #-- <sub> tag
1.1 sakharuk 982: sub start_sub {
983: my ($target,$token) = @_;
984: my $currentstring = '';
985: if ($target eq 'web') {
986: $currentstring .= $token->[4];
987: } elsif ($target eq 'tex') {
988: $currentstring .= "\$_{ ";
989: }
990: return $currentstring;
991: }
992: sub end_sub {
993: my ($target,$token) = @_;
994: my $currentstring = '';
995: if ($target eq 'web') {
996: $currentstring .= $token->[2];
997: } elsif ($target eq 'tex') {
998: $currentstring .= " }\$";
999: }
1000: return $currentstring;
1001: }
1.35 sakharuk 1002: #-- <sup> tag
1.1 sakharuk 1003: sub start_sup {
1004: my ($target,$token) = @_;
1005: my $currentstring = '';
1006: if ($target eq 'web') {
1007: $currentstring .= $token->[4];
1008: } elsif ($target eq 'tex') {
1009: $currentstring .= "\$^{ ";
1010: }
1011: return $currentstring;
1012: }
1013: sub end_sup {
1014: my ($target,$token) = @_;
1015: my $currentstring = '';
1016: if ($target eq 'web') {
1017: $currentstring .= $token->[2];
1018: } elsif ($target eq 'tex') {
1019: $currentstring .= " }\$";
1020: }
1021: return $currentstring;
1022: }
1.35 sakharuk 1023: #-- <hr> tag
1.1 sakharuk 1024: sub start_hr {
1025: my ($target,$token) = @_;
1026: my $currentstring = '';
1027: if ($target eq 'web') {
1028: $currentstring .= $token->[4];
1029: } elsif ($target eq 'tex') {
1030: $currentstring .= "\\hline ";
1.6 sakharuk 1031: }
1032: return $currentstring;
1033: }
1034: sub end_hr {
1035: my ($target,$token) = @_;
1036: my $currentstring = '';
1037: if ($target eq 'web') {
1038: $currentstring .= $token->[2];
1039: } elsif ($target eq 'tex') {
1.1 sakharuk 1040: }
1041: return $currentstring;
1042: }
1.35 sakharuk 1043: #-- <a> tag
1.1 sakharuk 1044: sub start_a {
1045: my ($target,$token) = @_;
1046: my $currentstring = '';
1047: if ($target eq 'web') {
1048: $currentstring .= $token->[4];
1049: } elsif ($target eq 'tex') {
1050: }
1051: return $currentstring;
1052: }
1053: sub end_a {
1.30 albertel 1054: my ($target,$token,$tagstack,$stackref) = @_;
1.1 sakharuk 1055: my $currentstring = '';
1056: if ($target eq 'web') {
1057: $currentstring .= $token->[2];
1058: } elsif ($target eq 'tex') {
1059: my $tempor_var = $stackref->[$#$stackref];
1060: if (index($tempor_var,'name') != -1 ) {
1061: $tempor_var =~ s/name=([^,]*),/$1/g;
1.15 sakharuk 1062: # $currentstring .= " \\label{$tempor_var}";
1.1 sakharuk 1063: } elsif (index($tempor_var,'href') != -1 ) {
1064: $tempor_var =~ s/href=([^,]*),/$1/g;
1065: $currentstring .= " \\ref{$tempor_var}";
1066: }
1067: }
1068: return $currentstring;
1069: }
1.35 sakharuk 1070: #-- <li> tag
1.1 sakharuk 1071: sub start_li {
1.30 albertel 1072: my ($target,$token,$tagstack,$stackref) = @_;
1.1 sakharuk 1073: my $currentstring = '';
1074: if ($target eq 'web') {
1075: $currentstring = $token->[4];
1076: } elsif ($target eq 'tex') {
1.15 sakharuk 1077: my $tempor_var = $stackref->[$#$stackref];
1.1 sakharuk 1078: if (index($tempor_var,'circle') != -1 ) {
1079: $currentstring .= " \\item[o] ";
1080: } elsif (index($tempor_var,'square') != -1 ) {
1081: $currentstring .= " \\item[$\Box$] ";
1.15 sakharuk 1082: } elsif ($tempor_var ne '') {
1083: $_ = $tempor_var;
1084: m/my\s*([^=]*)=/;
1085: $currentstring .= " \\item[$1] ";
1086: } else {
1.1 sakharuk 1087: $currentstring .= " \\item ";
1088: }
1089: }
1090: return $currentstring;
1091: }
1092: sub end_li {
1093: my ($target,$token) = @_;
1094: my $currentstring = '';
1095: if ($target eq 'web') {
1096: $currentstring = $token->[2];
1097: }
1098: return $currentstring;
1099: }
1.35 sakharuk 1100: #-- <u> tag
1.1 sakharuk 1101: sub start_u {
1102: my ($target,$token) = @_;
1103: my $currentstring = '';
1104: if ($target eq 'web') {
1105: $currentstring .= $token->[4];
1106: } elsif ($target eq 'tex') {
1107: $currentstring .= "{\\underline ";
1108: }
1109: return $currentstring;
1110: }
1111: sub end_u {
1112: my ($target,$token) = @_;
1113: my $currentstring = '';
1114: if ($target eq 'web') {
1115: $currentstring .= $token->[2];
1116: } elsif ($target eq 'tex') {
1117: $currentstring .= " }";
1118: }
1119: return $currentstring;
1120: }
1.35 sakharuk 1121: #-- <ul> tag
1.1 sakharuk 1122: sub start_ul {
1123: my ($target,$token) = @_;
1124: my $currentstring = '';
1125: if ($target eq 'web') {
1126: $currentstring = $token->[4];
1127: } elsif ($target eq 'tex') {
1.41 sakharuk 1128: $currentstring = '\begin{itemize}';
1.1 sakharuk 1129: }
1130: return $currentstring;
1131: }
1132: sub end_ul {
1133: my ($target,$token) = @_;
1134: my $currentstring = '';
1135: if ($target eq 'web') {
1136: $currentstring = $token->[2];
1137: } elsif ($target eq 'tex') {
1.41 sakharuk 1138: $currentstring = '\end{itemize}';
1.1 sakharuk 1139: }
1140: return $currentstring;
1141: }
1.35 sakharuk 1142: #-- <menu> tag
1.1 sakharuk 1143: sub start_menu {
1144: my ($target,$token) = @_;
1145: my $currentstring = '';
1146: if ($target eq 'web') {
1147: $currentstring = $token->[4];
1148: } elsif ($target eq 'tex') {
1149: $currentstring = " \\begin{itemize} ";
1150: }
1151: return $currentstring;
1152: }
1153: sub end_menu {
1154: my ($target,$token) = @_;
1155: my $currentstring = '';
1156: if ($target eq 'web') {
1157: $currentstring = $token->[2];
1158: } elsif ($target eq 'tex') {
1159: $currentstring = " \\end{itemize}";
1160: }
1161: return $currentstring;
1162: }
1.35 sakharuk 1163: #-- <dir> tag
1.1 sakharuk 1164: sub start_dir {
1165: my ($target,$token) = @_;
1166: my $currentstring = '';
1167: if ($target eq 'web') {
1168: $currentstring = $token->[4];
1169: } elsif ($target eq 'tex') {
1170: $currentstring = " \\begin{itemize} ";
1171: }
1172: return $currentstring;
1173: }
1174: sub end_dir {
1175: my ($target,$token) = @_;
1176: my $currentstring = '';
1177: if ($target eq 'web') {
1178: $currentstring = $token->[2];
1179: } elsif ($target eq 'tex') {
1180: $currentstring = " \\end{itemize}";
1181: }
1182: return $currentstring;
1183: }
1.35 sakharuk 1184: #-- <ol> tag
1.1 sakharuk 1185: sub start_ol {
1186: my ($target,$token) = @_;
1187: my $currentstring = '';
1188: if ($target eq 'web') {
1189: $currentstring = $token->[4];
1190: } elsif ($target eq 'tex') {
1.41 sakharuk 1191: $currentstring = '\begin{enumerate}';
1.1 sakharuk 1192: }
1193: return $currentstring;
1194: }
1195: sub end_ol {
1196: my ($target,$token) = @_;
1197: my $currentstring = '';
1198: if ($target eq 'web') {
1199: $currentstring = $token->[2];
1200: } elsif ($target eq 'tex') {
1.41 sakharuk 1201: $currentstring = '\end{enumerate}';
1.1 sakharuk 1202: }
1203: return $currentstring;
1204: }
1.35 sakharuk 1205: #-- <dl> tag
1.1 sakharuk 1206: sub start_dl {
1207: my ($target,$token) = @_;
1208: my $currentstring = '';
1209: if ($target eq 'web') {
1210: $currentstring = $token->[4];
1211: } elsif ($target eq 'tex') {
1.41 sakharuk 1212: $currentstring = '\begin{description}';
1.1 sakharuk 1213: }
1214: return $currentstring;
1215: }
1216: sub end_dl {
1217: my ($target,$token) = @_;
1218: my $currentstring = '';
1219: if ($target eq 'web') {
1220: $currentstring = $token->[2];
1221: } elsif ($target eq 'tex') {
1.41 sakharuk 1222: $currentstring = '\end{description}';
1.1 sakharuk 1223: }
1224: return $currentstring;
1225: }
1.35 sakharuk 1226: #-- <dt> tag
1.1 sakharuk 1227: sub start_dt {
1228: my ($target,$token) = @_;
1229: my $currentstring = '';
1230: if ($target eq 'web') {
1231: $currentstring = $token->[4];
1232: } elsif ($target eq 'tex') {
1.41 sakharuk 1233: $currentstring = '\item[';
1.1 sakharuk 1234: }
1235: return $currentstring;
1236: }
1237: sub end_dt {
1238: my ($target,$token) = @_;
1239: my $currentstring = '';
1240: if ($target eq 'web') {
1241: $currentstring = $token->[2];
1242: } elsif ($target eq 'tex') {
1.41 sakharuk 1243: $currentstring = ']';
1.1 sakharuk 1244: }
1245: return $currentstring;
1246: }
1.35 sakharuk 1247: #-- <dd> tag
1.1 sakharuk 1248: sub start_dd {
1249: my ($target,$token) = @_;
1250: my $currentstring = '';
1251: if ($target eq 'web') {
1252: $currentstring = $token->[4];
1253: }
1254: return $currentstring;
1255: }
1256: sub end_dd {
1257: my ($target,$token) = @_;
1258: my $currentstring = '';
1259: if ($target eq 'web') {
1260: $currentstring = $token->[2];
1261: }
1262: return $currentstring;
1263: }
1.35 sakharuk 1264: #-- <table> tag
1.1 sakharuk 1265: sub start_table {
1.50 sakharuk 1266: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1.1 sakharuk 1267: my $currentstring = '';
1268: if ($target eq 'web') {
1269: $currentstring = $token->[4];
1270: } elsif ($target eq 'tex') {
1.53 sakharuk 1271: my $aa = {};
1272: push @Apache::londefdef::table, $aa;
1273: $Apache::londefdef::table[-1]{'row_number'} = -1;
1274: $Apache::londefdef::table[-1]{'output'} = '\begin{tabular} ';
1.50 sakharuk 1275: my $border = &Apache::lonxml::get_param('border',$parstack,$safeeval);
1276: unless (defined $border) { $border = 0; }
1.51 sakharuk 1277: if ($border) {
1.53 sakharuk 1278: $Apache::londefdef::table[-1]{'hinc'} = '\hline ';
1279: $Apache::londefdef::table[-1]{'vinc'} = '&';
1280: $Apache::londefdef::table[-1]{'vvinc'} = '|';
1.52 sakharuk 1281: } else {
1.53 sakharuk 1282: $Apache::londefdef::table[-1]{'hinc'} = '';
1283: $Apache::londefdef::table[-1]{'vinc'} = '';
1284: $Apache::londefdef::table[-1]{'vvinc'} = '';
1.50 sakharuk 1285: }
1.51 sakharuk 1286: }
1287: return $currentstring;
1288: }
1289: sub end_table {
1290: my ($target,$token) = @_;
1291: my $currentstring = '';
1292: if ($target eq 'web') {
1293: $currentstring = $token->[2];
1294: } elsif ($target eq 'tex') {
1.53 sakharuk 1295: my $inmemory = '';
1.52 sakharuk 1296: my $output = '';
1.53 sakharuk 1297: my $header_of_table = '{'.$Apache::londefdef::table[-1]{'vvinc'};
1.50 sakharuk 1298: my $in;
1.53 sakharuk 1299: for ($in=0;$in<=$Apache::londefdef::table[-1]{'counter_columns'};$in++) {
1300: $header_of_table .= $Apache::londefdef::table[-1]{'columns'}[$in].$Apache::londefdef::table[-1]{'vvinc'};
1301: }
1302: $header_of_table .= '}';
1303: for ($in=0;$in<=$Apache::londefdef::table[-1]{'row_number'};$in++) {
1304: $output .= $Apache::londefdef::table[-1]{'rowdata'}[$in];
1.52 sakharuk 1305: chop $output;
1306: $output .= ' \\\\ ';
1.50 sakharuk 1307: }
1.53 sakharuk 1308: $Apache::londefdef::table[-1]{'output'} .= $header_of_table.$output.$Apache::londefdef::table[-1]{'hinc'}.'\end{tabular}';
1309: if ($#Apache::londefdef::table > 0) {
1310: $inmemory = $Apache::londefdef::table[-1]{'output'};
1311: pop @Apache::londefdef::table;
1312: $Apache::londefdef::table[-1]{'rowdata'}[$Apache::londefdef::table[-1]{'row_number'}] .= $inmemory;
1313: } else {
1314: $currentstring = $Apache::londefdef::table[-1]{'output'};
1315: $currentstring =~ s/\\\\\s+\\\\/\\\\/g;
1316: pop @Apache::londefdef::table;
1317: }
1.51 sakharuk 1318: }
1319: return $currentstring;
1320: }
1321: #-- <tr> tag
1322: sub start_tr {
1323: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1324: my $currentstring = '';
1325: if ($target eq 'web') {
1326: $currentstring = $token->[4];
1327: } elsif ($target eq 'tex') {
1.53 sakharuk 1328: $Apache::londefdef::table[-1]{'row_number'}++;
1329: my $alignchar = substr(&Apache::lonxml::get_param('align',$parstack,$safeeval),0,1);
1330: if ($alignchar ne '') {
1331: push @ {$Apache::londefdef::table[-1]{'rows'} }, $alignchar;
1.51 sakharuk 1332: } else {
1.53 sakharuk 1333: push @ {$Apache::londefdef::table[-1]{'rows'} }, 'c';
1.51 sakharuk 1334: }
1.53 sakharuk 1335: push ( @{ $Apache::londefdef::table[-1]{'rowdata'} }, $Apache::londefdef::table[-1]{'hinc'});
1336: $Apache::londefdef::table[-1]{'counter_columns'} = -1;
1.52 sakharuk 1337:
1.1 sakharuk 1338: }
1339: return $currentstring;
1.51 sakharuk 1340: }
1341: sub end_tr {
1342: my ($target,$token) = @_;
1343: my $currentstring = '';
1344: if ($target eq 'web') {
1345: $currentstring = $token->[2];
1346: } elsif ($target eq 'tex') {
1.53 sakharuk 1347: # $currentstring .= ' START ROW '. $Apache::londefdef::table[-1]{'rowdata'}[$Apache::londefdef::table[-1]{'row_number'}].' END ROW ';
1.51 sakharuk 1348: }
1349: return $currentstring;
1.1 sakharuk 1350: }
1.51 sakharuk 1351: #-- <td> tag
1352: sub start_td {
1353: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1354: my $currentstring = '';
1355: if ($target eq 'web') {
1356: $currentstring = $token->[4];
1357: } elsif ($target eq 'tex') {
1358: my $what_to_push = substr(&Apache::lonxml::get_param('align',$parstack,$safeeval),0,1);
1359: if ($what_to_push eq '') {
1.53 sakharuk 1360: $what_to_push = substr($Apache::londefdef::table[-1]{'rows'}[0],0,1);;
1.51 sakharuk 1361: }
1.53 sakharuk 1362: push @{ $Apache::londefdef::table[-1]{'columns'} }, $what_to_push;
1363: $Apache::londefdef::table[-1]{'counter_columns'}++;
1.52 sakharuk 1364: &Apache::lonxml::startredirection();
1365: ;
1.51 sakharuk 1366: }
1367: return $currentstring;
1368: }
1369: sub end_td {
1.59 ! sakharuk 1370: my ($target,$token) = @_;
! 1371: my $currentstring = '';
! 1372: if ($target eq 'web') {
! 1373: $currentstring = $token->[2];
! 1374: } elsif ($target eq 'tex') {
! 1375: my $current_row = $Apache::londefdef::table[-1]{'row_number'};
! 1376: my $data=&Apache::lonxml::endredirection();
! 1377: @{ $Apache::londefdef::table[-1]{'rowdata'} }[$current_row] .= $data.' '.$Apache::londefdef::table[-1]{'vinc'};
! 1378: }
! 1379: return $currentstring;
! 1380: }
! 1381: #-- <th> tag
! 1382: sub start_th {
! 1383: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
! 1384: my $currentstring = '';
! 1385: if ($target eq 'web') {
! 1386: $currentstring = $token->[4];
! 1387: } elsif ($target eq 'tex') {
! 1388: my $what_to_push = substr(&Apache::lonxml::get_param('align',$parstack,$safeeval),0,1);
! 1389: if ($what_to_push eq '') {
! 1390: $what_to_push = substr($Apache::londefdef::table[-1]{'rows'}[0],0,1);;
! 1391: }
! 1392: push @{ $Apache::londefdef::table[-1]{'columns'} }, $what_to_push;
! 1393: $Apache::londefdef::table[-1]{'counter_columns'}++;
! 1394: &Apache::lonxml::startredirection();
! 1395: ;
! 1396: }
! 1397: return $currentstring;
! 1398: }
! 1399: sub end_th {
1.1 sakharuk 1400: my ($target,$token) = @_;
1401: my $currentstring = '';
1402: if ($target eq 'web') {
1.51 sakharuk 1403: $currentstring = $token->[2];
1404: } elsif ($target eq 'tex') {
1.53 sakharuk 1405: my $current_row = $Apache::londefdef::table[-1]{'row_number'};
1.52 sakharuk 1406: my $data=&Apache::lonxml::endredirection();
1.53 sakharuk 1407: @{ $Apache::londefdef::table[-1]{'rowdata'} }[$current_row] .= $data.' '.$Apache::londefdef::table[-1]{'vinc'};
1.44 sakharuk 1408: }
1.1 sakharuk 1409: return $currentstring;
1410: }
1.35 sakharuk 1411: #-- <img> tag
1.10 www 1412: sub start_img {
1.41 sakharuk 1413: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1.44 sakharuk 1414: $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=
1.10 www 1415: $token->[2]->{'src'};
1416: my $currentstring = '';
1.58 sakharuk 1417: my $width_param = '';
1.44 sakharuk 1418:
1.42 albertel 1419: if ($target eq 'web') {
1.10 www 1420: $currentstring = $token->[4];
1421: } elsif ($target eq 'tex') {
1.58 sakharuk 1422: my $TeXwidth = &Apache::lonxml::get_param('TeXwidth',$parstack,$safeeval);
1423: my $TeXheight = &Apache::lonxml::get_param('TeXheight',$parstack,$safeeval);
1424: my $width = &Apache::lonxml::get_param('width',$parstack,$safeeval);
1425: if ($TeXwidth ne '') {
1426: $width_param = $TeXwidth;
1427: } elsif ($TeXheight ne '') {
1428: $width_param = $TeXheight;
1429: } else {
1430: if ($width ne '') {
1431: $width_param = $width*.3;
1432: if ($width_param <= 900) {
1433: $width_param = '[width='.$width_param.'mm]';
1434: } else {
1435: $width_param = '[width= 9.0 cm]';
1436: }
1437: }
1438: }
1.42 albertel 1439: my $src = &Apache::lonxml::get_param('src',$parstack,$safeeval);
1.54 sakharuk 1440: $src=&Apache::lonnet::filelocation($Apache::lonxml::pwd[-1],$src);
1.42 albertel 1441: my $file;
1.55 sakharuk 1442: my $path;
1443: if ($src =~ m!(.*)/([^/]*)$!) {
1444: $file = $2;
1.57 sakharuk 1445: $path = $1.'/';
1.55 sakharuk 1446: }
1.57 sakharuk 1447: my $newsrc = $src;
1448: $newsrc =~ s/(\.gif|\.jpg)$/\.eps/;
1449: $file=~s/(\.gif|\.jpg)$/\.eps/;
1450: if (-e $newsrc) {
1451: if ($path) {
1.58 sakharuk 1452: $currentstring .= '\graphicspath{{'.$path.'}}\fbox{\includegraphics'.$width_param.'{'.$file.'}}';
1.57 sakharuk 1453: }
1.42 albertel 1454: } else {
1.57 sakharuk 1455: my $temp_file;
1456: my $filename = "/home/httpd/prtspool/$ENV{'user.name'}$ENV{'user.domain'}temp$ENV{'user.login.time'}.dat";
1457: $temp_file = Apache::File->new('>>'.$filename);
1458: print $temp_file "$src\n";
1.58 sakharuk 1459: $currentstring .= '\graphicspath{{/home/httpd/prtspool/}}\fbox{\includegraphics'.$width_param.'{'.$file.'}}';
1.42 albertel 1460: }
1461: }
1462: return $currentstring;
1.10 www 1463: }
1464: sub end_img {
1465: my ($target,$token) = @_;
1466: my $currentstring = '';
1467: if ($target eq 'web') {
1.44 sakharuk 1468: $currentstring = $token->[2];
1.10 www 1469: } elsif ($target eq 'tex') {
1.44 sakharuk 1470: $currentstring = '';
1471: }
1.10 www 1472: return $currentstring;
1473: }
1.35 sakharuk 1474: #-- <applet> tag
1.10 www 1475:
1476: sub start_applet {
1477: my ($target,$token) = @_;
1478: $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=
1479: $token->[2]->{'code'};
1.44 sakharuk 1480: $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=
1.10 www 1481: $token->[2]->{'archive'};
1482: my $currentstring = '';
1483: if ($target eq 'web') {
1.44 sakharuk 1484: $currentstring = $token->[4];
1.10 www 1485: } elsif ($target eq 'tex') {
1.44 sakharuk 1486: $currentstring = " \\begin{figure} ";
1.10 www 1487: }
1488: return $currentstring;
1489: }
1.44 sakharuk 1490: sub end_applet {
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: }
1.10 www 1500:
1.35 sakharuk 1501: #-- <embed> tag
1.10 www 1502:
1.45 sakharuk 1503: sub start_embed {
1.44 sakharuk 1504: my ($target,$token) = @_;
1505: $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=
1506: $token->[2]->{'src'};
1507: my $currentstring = '';
1508: if ($target eq 'web') {
1509: $currentstring = $token->[4];
1510: } elsif ($target eq 'tex') {
1511: $currentstring = " \\begin{figure} ";
1512: }
1513: return $currentstring;
1514: }
1.10 www 1515: sub end_embed {
1516: my ($target,$token) = @_;
1517: my $currentstring = '';
1518: if ($target eq 'web') {
1519: $currentstring = $token->[2];
1520: } elsif ($target eq 'tex') {
1521: $currentstring = " \\end{figure}";
1522: }
1523: return $currentstring;
1524: }
1525:
1.35 sakharuk 1526: #-- <param> tag
1.10 www 1527:
1.11 www 1528: sub start_param {
1.10 www 1529: my ($target,$token) = @_;
1530: if ($token->[2]->{'name'} eq 'cabbase') {
1531: $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=
1532: $token->[2]->{'value'};
1533: }
1.20 www 1534: $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=
1.10 www 1535: $token->[2]->{'src'};
1536: my $currentstring = '';
1537: if ($target eq 'web') {
1538: $currentstring = $token->[4];
1539: } elsif ($target eq 'tex') {
1540: $currentstring = " \\begin{figure} ";
1541: }
1542: return $currentstring;
1543: }
1.11 www 1544: sub end_param {
1.10 www 1545: my ($target,$token) = @_;
1546: my $currentstring = '';
1547: if ($target eq 'web') {
1548: $currentstring = $token->[2];
1549: } elsif ($target eq 'tex') {
1550: $currentstring = " \\end{figure}";
1551: }
1552: return $currentstring;
1553: }
1554:
1.35 sakharuk 1555: #-- <allow> tag
1.10 www 1556:
1557: sub start_allow {
1558: my ($target,$token) = @_;
1559:
1.20 www 1560: $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=
1.10 www 1561: $token->[2]->{'src'};
1562:
1563: return '';
1564: }
1565: sub end_allow {
1566: return '';
1567: }
1.35 sakharuk 1568: #-- Frames
1.31 albertel 1569: sub start_frameset {
1570: my ($target,$token) = @_;
1571: my $currentstring = '';
1572: if ($target eq 'web') {
1573: if (!$Apache::lonxml::registered) {
1.47 matthew 1574: $currentstring.='<head>'.
1575: &Apache::lonxml::registerurl(undef,$target).'</head>';
1.31 albertel 1576: }
1577: $currentstring .= $token->[4];
1578: }
1579: return $currentstring;
1580: }
1581: sub end_frameset {
1582: my ($target,$token) = @_;
1583: my $currentstring = '';
1584: if ($target eq 'web') {
1585: $currentstring = $token->[2];
1586: }
1587: return $currentstring;
1.41 sakharuk 1588: }
1589: #-- <pre>
1590: sub start_pre {
1591: my ($target,$token) = @_;
1592: my $currentstring = '';
1593: if ($target eq 'web') {
1594: $currentstring .= $token->[4];
1595: } elsif ($target eq 'tex') {
1596: $currentstring .= '\begin{verbatim}';
1597: }
1598: return $currentstring;
1599: }
1600: sub end_pre {
1601: my ($target,$token) = @_;
1602: my $currentstring = '';
1603: if ($target eq 'web') {
1604: $currentstring .= $token->[2];
1605: } elsif ($target eq 'tex') {
1606: $currentstring .= '\end{verbatim}';
1.44 sakharuk 1607: }
1608: return $currentstring;
1609: }
1610: #-- <insert>
1611: sub start_insert {
1.46 sakharuk 1612: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1.44 sakharuk 1613: my $currentstring = '';
1614: if ($target eq 'web') {
1.46 sakharuk 1615: my $display = &Apache::lonxml::get_param('display',$parstack,$safeeval);
1616: $currentstring .= '<b>'.$display.'</b>';;
1.44 sakharuk 1617: }
1618: return $currentstring;
1619: }
1620: sub end_insert {
1.48 sakharuk 1621: my ($target,$token) = @_;
1622: my $currentstring = '';
1623: if ($target eq 'web') {
1624: $currentstring .= '';
1625: }
1626: return $currentstring;
1627: }
1628: #-- <externallink>
1629: sub start_externallink {
1630: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1631: my $currentstring = '';
1632: if ($target eq 'web') {
1633: my $display = &Apache::lonxml::get_param('display',$parstack,$safeeval);
1634: $currentstring .= '<b>'.$display.'</b>';;
1635: }
1636: return $currentstring;
1637: }
1638: sub end_externallink {
1.44 sakharuk 1639: my ($target,$token) = @_;
1640: my $currentstring = '';
1641: if ($target eq 'web') {
1642: $currentstring .= '';
1.41 sakharuk 1643: }
1644: return $currentstring;
1.31 albertel 1645: }
1.1 sakharuk 1646: 1;
1647: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>