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