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