Annotation of loncom/xml/londefdef.pm, revision 1.76
1.1 sakharuk 1: # The LearningOnline Network with CAPA
2: # Tags Default Definition Module
3: #
1.76 ! sakharuk 4: # $Id: londefdef.pm,v 1.75 2002/07/23 19:15:08 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);
1.76 ! sakharuk 94: if ($currentstring=~/\s*\\\\\s*/) {$currentstring = ' \vskip 0 mm ';}
1.73 albertel 95: } else {
96: my $inside = &Apache::lonxml::get_all_text_unbalanced("/m",$parser);
1.33 albertel 97: }
98: return $currentstring;
99: }
100: sub end_m {
101: my ($target,$token) = @_;
102: my $currentstring = '';
103: if ($target eq 'web') {
1.61 albertel 104: $Apache::lonxml::prevent_entity_encode--;
1.33 albertel 105: } elsif ($target eq 'tex') {
106: $currentstring = "";
107: } elsif ($target eq 'meta') {
108: }
109: return $currentstring;
110: }
1.35 sakharuk 111: #-- <html> tag
1.1 sakharuk 112: sub start_html {
113: my ($target,$token) = @_;
1.41 sakharuk 114: my $currentstring = '';
1.39 albertel 115: if ($ENV{'browser.mathml'}) {
116: &tth::ttminit();
117: } else {
118: &tth::tthinit();
119: }
1.1 sakharuk 120: if ($target eq 'web') {
1.29 www 121: $currentstring = &Apache::lonxml::xmlbegin().
122: &Apache::lonxml::fontsettings();
1.35 sakharuk 123: } elsif ($target eq 'tex') {
1.53 sakharuk 124: @Apache::londefdef::table = ();
1.35 sakharuk 125: $currentstring .= '\documentclass[letterpaper]{article}
1.41 sakharuk 126: \newcommand{\keephidden}[1]{}
1.44 sakharuk 127: \usepackage[dvips]{graphicx}
1.65 sakharuk 128: \usepackage{epsfig}\usepackage{calc}';
1.35 sakharuk 129: }
1.1 sakharuk 130: return $currentstring;
131: }
132: sub end_html {
133: my ($target,$token) = @_;
134: my $currentstring = '';
135: if ($target eq 'web') {
1.28 www 136: $currentstring = &Apache::lonxml::xmlend();
1.35 sakharuk 137: }
1.1 sakharuk 138: return $currentstring;
139: }
1.35 sakharuk 140: #-- <head> tag
1.1 sakharuk 141: sub start_head {
142: my ($target,$token) = @_;
143: my $currentstring = '';
144: if ($target eq 'web') {
145: $currentstring = $token->[4];
146: }
147: return $currentstring;
148: }
149: sub end_head {
150: my ($target,$token) = @_;
151: my $currentstring = '';
152: if ($target eq 'web') {
1.47 matthew 153: $currentstring = &Apache::lonxml::registerurl(undef,$target).
1.29 www 154: $token->[2];
1.1 sakharuk 155: }
156: return $currentstring;
157: }
1.35 sakharuk 158: #-- <map> tag
1.1 sakharuk 159: sub start_map {
160: my ($target,$token) = @_;
161: my $currentstring = '';
162: if ($target eq 'web') {
163: $currentstring = $token->[4];
164: }
165: return $currentstring;
166: }
167: sub end_map {
168: my ($target,$token) = @_;
169: my $currentstring = '';
170: if ($target eq 'web') {
171: $currentstring = $token->[2];
172: }
173: return $currentstring;
174: }
1.35 sakharuk 175: #-- <select> tag
1.1 sakharuk 176: sub start_select {
177: my ($target,$token) = @_;
178: my $currentstring = '';
179: if ($target eq 'web') {
180: $currentstring = $token->[4];
181: }
182: return $currentstring;
183: }
184: sub end_select {
185: my ($target,$token) = @_;
186: my $currentstring = '';
187: if ($target eq 'web') {
188: $currentstring = $token->[2];
189: }
190: return $currentstring;
191: }
1.35 sakharuk 192: #-- <option> tag
1.1 sakharuk 193: sub start_option {
194: my ($target,$token) = @_;
195: my $currentstring = '';
196: if ($target eq 'web') {
197: $currentstring = $token->[4];
198: }
199: return $currentstring;
200: }
201: sub end_option {
202: my ($target,$token) = @_;
203: my $currentstring = '';
204: if ($target eq 'web') {
205: $currentstring = $token->[2];
206: }
207: return $currentstring;
208: }
1.35 sakharuk 209: #-- <input> tag
1.1 sakharuk 210: sub start_input {
211: my ($target,$token) = @_;
212: my $currentstring = '';
213: if ($target eq 'web') {
214: $currentstring = $token->[4];
215: }
216: return $currentstring;
217: }
218: sub end_input {
219: my ($target,$token) = @_;
220: my $currentstring = '';
221: if ($target eq 'web') {
222: $currentstring = $token->[2];
223: }
224: return $currentstring;
225: }
1.35 sakharuk 226: #-- <textarea> tag
1.1 sakharuk 227: sub start_textarea {
228: my ($target,$token) = @_;
229: my $currentstring = '';
230: if ($target eq 'web') {
231: $currentstring = $token->[4];
232: }
233: return $currentstring;
234: }
235: sub end_textarea {
236: my ($target,$token) = @_;
237: my $currentstring = '';
238: if ($target eq 'web') {
239: $currentstring = $token->[2];
240: }
241: return $currentstring;
242: }
1.35 sakharuk 243: #-- <form> tag
1.1 sakharuk 244: sub start_form {
245: my ($target,$token) = @_;
246: my $currentstring = '';
247: if ($target eq 'web') {
248: $currentstring = $token->[4];
249: }
250: return $currentstring;
251: }
252: sub end_form {
253: my ($target,$token) = @_;
254: my $currentstring = '';
255: if ($target eq 'web') {
256: $currentstring = $token->[2];
257: }
258: return $currentstring;
259: }
1.35 sakharuk 260: #-- <title> tag
1.1 sakharuk 261: sub start_title {
262: my ($target,$token) = @_;
263: my $currentstring = '';
264: if ($target eq 'web') {
265: $currentstring = $token->[4];
1.35 sakharuk 266: } elsif ($target eq 'tex') {
267: $currentstring .= '\keephidden{'
1.1 sakharuk 268: }
1.13 www 269: if ($target eq 'meta') {
270: $currentstring='<title>';
271: &start_output();
272: }
1.1 sakharuk 273: return $currentstring;
274: }
275: sub end_title {
276: my ($target,$token) = @_;
277: my $currentstring = '';
278: if ($target eq 'web') {
279: $currentstring = $token->[2];
1.35 sakharuk 280: } elsif ($target eq 'tex') {
281: $currentstring .= '}';
282: }
1.13 www 283: if ($target eq 'meta') {
284: &end_output();
285: $currentstring='</title>';
1.1 sakharuk 286: }
287: return $currentstring;
288: }
1.35 sakharuk 289: #-- <meta> tag
1.1 sakharuk 290: sub start_meta {
1.30 albertel 291: my ($target,$token,$tagstack,$parstack,$parser) = @_;
1.1 sakharuk 292: my $currentstring = '';
293: if ($target eq 'web') {
1.25 albertel 294: my $args='';
295: if ( $#$parstack > -1 ) { $args=$$parstack[$#$parstack]; }
296: if ($args eq '') {
297: &Apache::lonxml::get_all_text("/meta",$$parser[$#$parser]);
298: } else {
299: $currentstring = $token->[4];
300: }
1.12 www 301: }
302: if ($target eq 'meta') {
303: unless ($token->[2]->{'http-equiv'}) {
304: my $name=$token->[2]->{'name'};
305: $name=~tr/A-Z/a-z/;
306: $name=~s/\s/\_/g;
307: if ($name) {
308: $currentstring='<'.$name.'>'.
309: $token->[2]->{'content'}.
310: '</'.$name.'>';
311: }
312: }
1.1 sakharuk 313: }
314: return $currentstring;
315: }
1.26 albertel 316: sub end_meta {
1.30 albertel 317: my ($target,$token,$tagstack,$parstack,$parser) = @_;
1.26 albertel 318: my $currentstring = '';
319: if ($target eq 'web') {
320: my $args='';
321: if ( $#$parstack > -1 ) { $args=$$parstack[$#$parstack]; }
322: if ($args ne '') {
323: $currentstring = $token->[4];
324: }
325: }
326: return $currentstring;
327: }
1.35 sakharuk 328: #-- <body> tag
1.1 sakharuk 329: sub start_body {
1.41 sakharuk 330: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
331: # my ($target,$token) = @_;
1.1 sakharuk 332: my $currentstring = '';
333: if ($target eq 'web') {
1.31 albertel 334: if (!$Apache::lonxml::registered) {
1.47 matthew 335: $currentstring.='<head>'.
336: &Apache::lonxml::registerurl(undef,$target).'</head>';
1.31 albertel 337: }
1.32 albertel 338: my $onLoad='';
339: foreach my $key (keys(%{$token->[2]})) {
340: if ($key =~ /^onload$/i) {
341: $onLoad.=$token->[2]->{$key}.';';
342: delete($token->[2]->{$key});
343: }
344: }
1.56 albertel 345: $token->[2]->{'onLoad'}=&Apache::lonxml::loadevents().
346: ';'.$onLoad;
1.32 albertel 347: my $onUnload='';
348: foreach my $key (keys(%{$token->[2]})) {
349: if ($key =~ /^onunload$/i) {
350: $onUnload.=$token->[2]->{$key}.';';
351: delete($token->[2]->{$key});
352: }
353: }
1.56 albertel 354: $token->[2]->{'onUnload'}=&Apache::lonxml::unloadevents().
355: ';'.$onUnload;
1.31 albertel 356:
357: $currentstring .= '<'.$token->[1];
1.37 albertel 358: foreach (keys %{$token->[2]}) {
359: $currentstring.=' '.$_.'="'.$token->[2]->{$_}.'"';
360: }
1.31 albertel 361: $currentstring.='>';
1.40 albertel 362: if ($ENV{'request.state'} ne 'published') {
363: $currentstring.=(<<EDITBUTTON);
364: <form method="post">
1.49 albertel 365: <input type="submit" name="editmode" value="Edit" />
1.40 albertel 366: </form>
367: EDITBUTTON
368: }
1.28 www 369: } elsif ($target eq 'tex') {
1.35 sakharuk 370: $currentstring = '\begin{document}';
1.1 sakharuk 371: }
372: return $currentstring;
373: }
374: sub end_body {
375: my ($target,$token) = @_;
376: my $currentstring = '';
377: if ($target eq 'web') {
378: $currentstring = $token->[2];
379: } elsif ($target eq 'tex') {
1.35 sakharuk 380: $currentstring = '\end{document}';
1.1 sakharuk 381: }
382: return $currentstring;
383: }
1.35 sakharuk 384: #-- <center> tag
1.1 sakharuk 385: sub start_center {
386: my ($target,$token) = @_;
387: my $currentstring = '';
388: if ($target eq 'web') {
389: $currentstring = $token->[4];
390: } elsif ($target eq 'tex') {
1.35 sakharuk 391: $currentstring = '\begin{center}';
1.18 sakharuk 392: } elsif ($target eq 'latexsource') {
1.35 sakharuk 393: $currentstring = '\begin{center}';
1.1 sakharuk 394: }
395: return $currentstring;
396: }
397: sub end_center {
398: my ($target,$token) = @_;
399: my $currentstring = '';
400: if ($target eq 'web') {
401: $currentstring = $token->[2];
402: } elsif ($target eq 'tex') {
1.35 sakharuk 403: $currentstring = '\end{center}';
1.18 sakharuk 404: } elsif ($target eq 'latexsource') {
1.35 sakharuk 405: $currentstring = '\end{center}';
1.1 sakharuk 406: }
407: return $currentstring;
408: }
1.35 sakharuk 409: #-- <b> tag
1.1 sakharuk 410: sub start_b {
411: my ($target,$token) = @_;
412: my $currentstring = '';
413: if ($target eq 'web') {
414: $currentstring = $token->[4];
415: } elsif ($target eq 'tex') {
1.35 sakharuk 416: $currentstring = '\textbf{';
1.18 sakharuk 417: } elsif ($target eq 'latexsource') {
1.35 sakharuk 418: $currentstring = '\textbf{';
1.1 sakharuk 419: }
420: return $currentstring;
421: }
422: sub end_b {
423: my ($target,$token) = @_;
424: my $currentstring = '';
425: if ($target eq 'web') {
426: $currentstring = $token->[2];
427: } elsif ($target eq 'tex') {
1.35 sakharuk 428: $currentstring = '}';
429:
1.18 sakharuk 430: } elsif ($target eq 'latexsource') {
1.35 sakharuk 431: $currentstring = '}';
1.1 sakharuk 432: }
433: return $currentstring;
434: }
1.35 sakharuk 435: #-- <strong> tag
1.1 sakharuk 436: sub start_strong {
437: my ($target,$token) = @_;
438: my $currentstring = '';
439: if ($target eq 'web') {
440: $currentstring = $token->[4];
441: } elsif ($target eq 'tex') {
1.35 sakharuk 442: $currentstring = '\textbf{';
1.18 sakharuk 443: } elsif ($target eq 'latexsource') {
1.35 sakharuk 444: $currentstring = '\textbf{';
1.1 sakharuk 445: }
446: return $currentstring;
447: }
448: sub end_strong {
449: my ($target,$token) = @_;
450: my $currentstring = '';
451: if ($target eq 'web') {
452:
453: $currentstring = $token->[2];
454: } elsif ($target eq 'tex') {
1.35 sakharuk 455: $currentstring = '}';
1.18 sakharuk 456: } elsif ($target eq 'latexsource') {
1.35 sakharuk 457: $currentstring = '}';
1.1 sakharuk 458: }
459: return $currentstring;
460: }
1.35 sakharuk 461: #-- <h1> tag
1.1 sakharuk 462: sub start_h1 {
463: my ($target,$token) = @_;
464: my $currentstring = '';
465: if ($target eq 'web') {
466: $currentstring .= $token->[4];
467: } elsif ($target eq 'tex') {
1.35 sakharuk 468: $currentstring .= '\large{\textbf{';
1.13 www 469: } elsif ($target eq 'meta') {
470: $currentstring='<subject>';
471: &start_output();
472: }
1.1 sakharuk 473: return $currentstring;
474: }
475: sub end_h1 {
476: my ($target,$token) = @_;
477: my $currentstring = '';
478: if ($target eq 'web') {
479: $currentstring .= $token->[2];
480: } elsif ($target eq 'tex') {
1.35 sakharuk 481: $currentstring .= '}}';
1.13 www 482: } elsif ($target eq 'meta') {
483: &end_output();
484: $currentstring='</subject>';
485: }
1.1 sakharuk 486: return $currentstring;
487: }
1.35 sakharuk 488: #-- <h2> tag
1.1 sakharuk 489: sub start_h2 {
490: my ($target,$token) = @_;
491: my $currentstring = '';
492: if ($target eq 'web') {
493: $currentstring .= $token->[4];
494: } elsif ($target eq 'tex') {
1.35 sakharuk 495: $currentstring .= '\large{\textbf{';
1.1 sakharuk 496: }
497: return $currentstring;
498: }
499: sub end_h2 {
500: my ($target,$token) = @_;
501: my $currentstring = '';
502: if ($target eq 'web') {
503: $currentstring .= $token->[2];
504: } elsif ($target eq 'tex') {
1.35 sakharuk 505: $currentstring .= '}}';
1.1 sakharuk 506: }
507: return $currentstring;
508: }
1.35 sakharuk 509: #-- <h3> tag
1.1 sakharuk 510: sub start_h3 {
511: my ($target,$token) = @_;
512: my $currentstring = '';
513: if ($target eq 'web') {
514: $currentstring .= $token->[4];
515: } elsif ($target eq 'tex') {
1.35 sakharuk 516: $currentstring .= '\large{\textbf{';
1.1 sakharuk 517: }
518: return $currentstring;
519: }
520: sub end_h3 {
521: my ($target,$token) = @_;
522: my $currentstring = '';
523: if ($target eq 'web') {
524: $currentstring .= $token->[2];
525: } elsif ($target eq 'tex') {
1.35 sakharuk 526: $currentstring .= '}}';
1.1 sakharuk 527: }
528: return $currentstring;
529: }
1.35 sakharuk 530: #-- <h4> tag
1.1 sakharuk 531: sub start_h4 {
532: my ($target,$token) = @_;
533: my $currentstring = '';
534: if ($target eq 'web') {
535: $currentstring .= $token->[4];
536: } elsif ($target eq 'tex') {
1.41 sakharuk 537: $currentstring .= '\large{\textbf{';
1.1 sakharuk 538: }
539: return $currentstring;
540: }
541: sub end_h4 {
542: my ($target,$token) = @_;
543: my $currentstring = '';
544: if ($target eq 'web') {
545: $currentstring .= $token->[2];
546: } elsif ($target eq 'tex') {
1.35 sakharuk 547: $currentstring .= '}}';
1.1 sakharuk 548: }
549: return $currentstring;
550: }
1.35 sakharuk 551: #-- <h5> tag
1.1 sakharuk 552: sub start_h5 {
553: my ($target,$token) = @_;
554: my $currentstring = '';
555: if ($target eq 'web') {
556: $currentstring .= $token->[4];
557: } elsif ($target eq 'tex') {
1.35 sakharuk 558: $currentstring .= '\large{\textbf{';
1.1 sakharuk 559: }
560: return $currentstring;
561: }
562: sub end_h5 {
563: my ($target,$token) = @_;
564: my $currentstring = '';
565: if ($target eq 'web') {
566: $currentstring .= $token->[2];
567: } elsif ($target eq 'tex') {
1.35 sakharuk 568: $currentstring .= '}}';
1.1 sakharuk 569: }
570: return $currentstring;
571: }
1.35 sakharuk 572: #-- <h6> tag
1.1 sakharuk 573: sub start_h6 {
574: my ($target,$token) = @_;
575: my $currentstring = '';
576: if ($target eq 'web') {
577: $currentstring .= $token->[4];
578: } elsif ($target eq 'tex') {
1.35 sakharuk 579: $currentstring .= '\large{\textbf{';
1.1 sakharuk 580: }
581: return $currentstring;
582: }
583: sub end_h6 {
584: my ($target,$token) = @_;
585: my $currentstring = '';
586: if ($target eq 'web') {
587: $currentstring .= $token->[2];
588: } elsif ($target eq 'tex') {
1.35 sakharuk 589: $currentstring .= '}}';
1.1 sakharuk 590: }
591: return $currentstring;
592: }
1.35 sakharuk 593: #--- <cite> tag
1.1 sakharuk 594: sub start_cite {
595: my ($target,$token) = @_;
596: my $currentstring = '';
597: if ($target eq 'web') {
598: $currentstring .= $token->[4];
599: } elsif ($target eq 'tex') {
1.18 sakharuk 600: $currentstring .= "\\textit{";
601: } elsif ($target eq 'latexsource') {
602: $currentstring .= "\\textit{";
1.1 sakharuk 603: }
604: return $currentstring;
605: }
606: sub end_cite {
607: my ($target,$token) = @_;
608: my $currentstring = '';
609: if ($target eq 'web') {
610: $currentstring .= $token->[2];
611: } elsif ($target eq 'tex') {
612: $currentstring .= "}";
1.18 sakharuk 613: } elsif ($target eq 'latexsource') {
614: $currentstring .= "}";
1.1 sakharuk 615: }
616: return $currentstring;
617: }
1.35 sakharuk 618: #-- <i> tag
1.1 sakharuk 619: sub start_i {
620: my ($target,$token) = @_;
621: my $currentstring = '';
622: if ($target eq 'web') {
623: $currentstring .= $token->[4];
624: } elsif ($target eq 'tex') {
1.35 sakharuk 625: $currentstring .= '\textit{';
1.18 sakharuk 626: } elsif ($target eq 'latexsource') {
1.35 sakharuk 627: $currentstring .= '\textit{';
1.1 sakharuk 628: }
629: return $currentstring;
630: }
631: sub end_i {
632: my ($target,$token) = @_;
633: my $currentstring = '';
634: if ($target eq 'web') {
635: $currentstring .= $token->[2];
636: } elsif ($target eq 'tex') {
1.35 sakharuk 637: $currentstring .= '}';
1.18 sakharuk 638: } elsif ($target eq 'latexsource') {
1.35 sakharuk 639: $currentstring .= '}';
1.1 sakharuk 640: }
641: return $currentstring;
642: }
1.35 sakharuk 643: #-- <address> tag
1.1 sakharuk 644: sub start_address {
645: my ($target,$token) = @_;
646: my $currentstring = '';
647: if ($target eq 'web') {
648: $currentstring .= $token->[4];
649: } elsif ($target eq 'tex') {
1.18 sakharuk 650: $currentstring .= "\\textit{";
651: } elsif ($target eq 'latexsource') {
652: $currentstring .= "\\textit{";
1.1 sakharuk 653: }
654: return $currentstring;
655: }
656: sub end_address {
657: my ($target,$token) = @_;
658: my $currentstring = '';
659: if ($target eq 'web') {
660: $currentstring .= $token->[2];
661: } elsif ($target eq 'tex') {
662: $currentstring .= "}";
1.18 sakharuk 663: } elsif ($target eq 'latexsource') {
664: $currentstring .= "}";
1.1 sakharuk 665: }
666: return $currentstring;
667: }
1.35 sakharuk 668: #-- <dfn> tag
1.1 sakharuk 669: sub start_dfn {
670: my ($target,$token) = @_;
671: my $currentstring = '';
672: if ($target eq 'web') {
673: $currentstring .= $token->[4];
674: } elsif ($target eq 'tex') {
1.18 sakharuk 675: $currentstring .= "\\textit{";
676: } elsif ($target eq 'latexsource') {
677: $currentstring .= "\\textit{";
1.1 sakharuk 678: }
679: return $currentstring;
680: }
681: sub end_dfn {
682: my ($target,$token) = @_;
683: my $currentstring = '';
684: if ($target eq 'web') {
685: $currentstring .= $token->[2];
686: } elsif ($target eq 'tex') {
687: $currentstring .= "}";
1.18 sakharuk 688: } elsif ($target eq 'latexsource') {
689: $currentstring .= "}";
1.1 sakharuk 690: }
691: return $currentstring;
692: }
1.35 sakharuk 693: #-- <tt> tag
1.1 sakharuk 694: sub start_tt {
695: my ($target,$token) = @_;
696: my $currentstring = '';
697: if ($target eq 'web') {
698: $currentstring .= $token->[4];
699: } elsif ($target eq 'tex') {
1.35 sakharuk 700: $currentstring .= '\texttt{';
1.18 sakharuk 701: } elsif ($target eq 'latexsource') {
1.35 sakharuk 702: $currentstring .= '\texttt{';
1.1 sakharuk 703: }
704: return $currentstring;
705: }
706: sub end_tt {
707: my ($target,$token) = @_;
708: my $currentstring = '';
709: if ($target eq 'web') {
710: $currentstring .= $token->[2];
711: } elsif ($target eq 'tex') {
1.35 sakharuk 712: $currentstring .= '}';
1.18 sakharuk 713: } elsif ($target eq 'latexsource') {
1.35 sakharuk 714: $currentstring .= '}';
1.18 sakharuk 715: }
1.1 sakharuk 716: return $currentstring;
717: }
1.35 sakharuk 718: #-- <kbd> tag
1.1 sakharuk 719: sub start_kbd {
720: my ($target,$token) = @_;
721: my $currentstring = '';
722: if ($target eq 'web') {
723: $currentstring .= $token->[4];
724: } elsif ($target eq 'tex') {
1.18 sakharuk 725: $currentstring .= "\\texttt";
726: } elsif ($target eq 'latexsource') {
727: $currentstring .= "\\texttt{";
1.1 sakharuk 728: }
729: return $currentstring;
730: }
731: sub end_kbd {
732: my ($target,$token) = @_;
733: my $currentstring = '';
734: if ($target eq 'web') {
735: $currentstring .= $token->[2];
736: } elsif ($target eq 'tex') {
737: $currentstring .= "}";
1.18 sakharuk 738: } elsif ($target eq 'latexsource') {
739: $currentstring .= "}";
1.1 sakharuk 740: }
741: return $currentstring;
742: }
1.35 sakharuk 743: #-- <code> tag
1.1 sakharuk 744: sub start_code {
745: my ($target,$token) = @_;
746: my $currentstring = '';
747: if ($target eq 'web') {
748: $currentstring .= $token->[4];
749: } elsif ($target eq 'tex') {
1.35 sakharuk 750: $currentstring .= '\texttt{';
1.1 sakharuk 751: }
752: return $currentstring;
753: }
754: sub end_code {
755: my ($target,$token) = @_;
756: my $currentstring = '';
757: if ($target eq 'web') {
758: $currentstring .= $token->[2];
759: } elsif ($target eq 'tex') {
1.35 sakharuk 760: $currentstring .= '}';
1.1 sakharuk 761: }
762: return $currentstring;
763: }
1.35 sakharuk 764: #-- <em> tag
1.1 sakharuk 765: sub start_em {
766: my ($target,$token) = @_;
767: my $currentstring = '';
768: if ($target eq 'web') {
769: $currentstring .= $token->[4];
770: } elsif ($target eq 'tex') {
1.35 sakharuk 771: $currentstring .= '\emph{';
1.18 sakharuk 772: } elsif ($target eq 'latexsource') {
1.35 sakharuk 773: $currentstring .= '\emph{';
1.1 sakharuk 774: }
775: return $currentstring;
776: }
777: sub end_em {
778: my ($target,$token) = @_;
779: my $currentstring = '';
780: if ($target eq 'web') {
781: $currentstring .= $token->[2];
782: } elsif ($target eq 'tex') {
1.35 sakharuk 783: $currentstring .= '}';
1.18 sakharuk 784: } elsif ($target eq 'latexsource') {
1.35 sakharuk 785: $currentstring .= '}';
1.18 sakharuk 786: }
1.1 sakharuk 787: return $currentstring;
788: }
1.35 sakharuk 789: #-- <q> tag
1.1 sakharuk 790: sub start_q {
791: my ($target,$token) = @_;
792: my $currentstring = '';
793: if ($target eq 'web') {
794: $currentstring .= $token->[4];
795: } elsif ($target eq 'tex') {
1.18 sakharuk 796: $currentstring .= "\\emph{";
797: } elsif ($target eq 'latexsource') {
798: $currentstring .= "\\emph{";
799: }
1.1 sakharuk 800: return $currentstring;
801: }
802: sub end_q {
803: my ($target,$token) = @_;
804: my $currentstring = '';
805: if ($target eq 'web') {
806: $currentstring .= $token->[2];
807: } elsif ($target eq 'tex') {
808: $currentstring .= "}";
1.18 sakharuk 809: } elsif ($target eq 'latexsource') {
810: $currentstring .= "}";
811: }
1.1 sakharuk 812: return $currentstring;
813: }
1.35 sakharuk 814: #-- <p> tag
1.1 sakharuk 815: sub start_p {
816: my ($target,$token) = @_;
817: my $currentstring = '';
818: if ($target eq 'web') {
819: $currentstring .= $token->[4];
820: } elsif ($target eq 'tex') {
1.35 sakharuk 821: $currentstring .= '{\par ';
1.18 sakharuk 822: } elsif ($target eq 'latexsource') {
1.35 sakharuk 823: $currentstring .= '{\par ';
1.1 sakharuk 824: }
825: return $currentstring;
826: }
827: sub end_p {
828: my ($target,$token) = @_;
829: my $currentstring = '';
830: if ($target eq 'web') {
831: $currentstring .= $token->[2];
832: } elsif ($target eq 'tex') {
1.35 sakharuk 833: $currentstring .= '}';
1.18 sakharuk 834: } elsif ($target eq 'latexsource') {
1.35 sakharuk 835: $currentstring .= '}';
1.1 sakharuk 836: }
837: return $currentstring;
838: }
1.35 sakharuk 839: #-- <br> tag
1.1 sakharuk 840: sub start_br {
1.75 sakharuk 841: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1.1 sakharuk 842: my $currentstring = '';
843: if ($target eq 'web') {
844: $currentstring .= $token->[4];
845: } elsif ($target eq 'tex') {
1.76 ! sakharuk 846: if ($$tagstack[-2] ne 'sub' && $$tagstack[-2] ne 'sup') {
1.75 sakharuk 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') {
1.76 ! sakharuk 957: $currentstring .= '\underline{';
1.1 sakharuk 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') {
1.76 ! sakharuk 967: $currentstring .= '}';
1.1 sakharuk 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') {
1.76 ! sakharuk 978: $currentstring .= '\underline{';
1.1 sakharuk 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') {
1.76 ! sakharuk 988: $currentstring .= '}';
1.1 sakharuk 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') {
1.76 ! sakharuk 1118: $currentstring .= '\underline{';
1.1 sakharuk 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') {
1.76 ! sakharuk 1128: $currentstring .= '}';
1.1 sakharuk 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>