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