Annotation of loncom/xml/londefdef.pm, revision 1.99
1.1 sakharuk 1: # The LearningOnline Network with CAPA
2: # Tags Default Definition Module
3: #
1.99 ! albertel 4: # $Id: londefdef.pm,v 1.96 2002/10/28 19:20:15 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.88 sakharuk 55: &Apache::lonxml::register('Apache::londefdef',('a','abbr','acronym','address','allow','applet','area','b','base','basefont','bgo','bgsound','big','blink','blockquote','blankspace','body','br','button','caption','center','cite','code','col','colgroup','dd','del','dfn','dir','div','dl','dt','em','embed','externallink','fieldset','font','form','frame','frameset','h1','h2','h3','h4','h5','h6','head','hr','html','i','iframe','img','input','ins','insert','isindex','kbd','keygen','label','layer','legend','li','link','m','map','marquee','menu','meta','multicol','nobr','noembed','noframes','nolayer','noscript','object','ol','optgroup','option','output','p','param','pre','q','s','samp','select','server','small','spacer','span','strike','strong','sub','sup','table','tbody','td','textarea','tfoot','th','thead','title','tr','tt','u','ul','var','wbr'));
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.83 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.77 sakharuk 126: \newcommand{\keephidden}[1]{}
127: \renewcommand{\deg}{$^{\circ}$}
1.44 sakharuk 128: \usepackage[dvips]{graphicx}
1.86 sakharuk 129: \usepackage{epsfig}\usepackage{calc}
130: \newenvironment{choicelist}{\begin{enumerate}}{\end{enumerate}}';
1.35 sakharuk 131: }
1.1 sakharuk 132: return $currentstring;
133: }
134: sub end_html {
135: my ($target,$token) = @_;
136: my $currentstring = '';
137: if ($target eq 'web') {
1.28 www 138: $currentstring = &Apache::lonxml::xmlend();
1.35 sakharuk 139: }
1.1 sakharuk 140: return $currentstring;
141: }
1.35 sakharuk 142: #-- <head> tag
1.1 sakharuk 143: sub start_head {
144: my ($target,$token) = @_;
145: my $currentstring = '';
146: if ($target eq 'web') {
147: $currentstring = $token->[4];
148: }
149: return $currentstring;
150: }
151: sub end_head {
152: my ($target,$token) = @_;
153: my $currentstring = '';
154: if ($target eq 'web') {
1.47 matthew 155: $currentstring = &Apache::lonxml::registerurl(undef,$target).
1.29 www 156: $token->[2];
1.1 sakharuk 157: }
158: return $currentstring;
159: }
1.35 sakharuk 160: #-- <map> tag
1.1 sakharuk 161: sub start_map {
162: my ($target,$token) = @_;
163: my $currentstring = '';
164: if ($target eq 'web') {
165: $currentstring = $token->[4];
166: }
167: return $currentstring;
168: }
169: sub end_map {
170: my ($target,$token) = @_;
171: my $currentstring = '';
172: if ($target eq 'web') {
173: $currentstring = $token->[2];
174: }
175: return $currentstring;
176: }
1.35 sakharuk 177: #-- <select> tag
1.1 sakharuk 178: sub start_select {
179: my ($target,$token) = @_;
180: my $currentstring = '';
181: if ($target eq 'web') {
182: $currentstring = $token->[4];
183: }
184: return $currentstring;
185: }
186: sub end_select {
187: my ($target,$token) = @_;
188: my $currentstring = '';
189: if ($target eq 'web') {
190: $currentstring = $token->[2];
191: }
192: return $currentstring;
193: }
1.35 sakharuk 194: #-- <option> tag
1.1 sakharuk 195: sub start_option {
196: my ($target,$token) = @_;
197: my $currentstring = '';
198: if ($target eq 'web') {
199: $currentstring = $token->[4];
200: }
201: return $currentstring;
202: }
203: sub end_option {
204: my ($target,$token) = @_;
205: my $currentstring = '';
206: if ($target eq 'web') {
207: $currentstring = $token->[2];
208: }
209: return $currentstring;
210: }
1.35 sakharuk 211: #-- <input> tag
1.1 sakharuk 212: sub start_input {
213: my ($target,$token) = @_;
214: my $currentstring = '';
215: if ($target eq 'web') {
216: $currentstring = $token->[4];
217: }
218: return $currentstring;
219: }
220: sub end_input {
221: my ($target,$token) = @_;
222: my $currentstring = '';
223: if ($target eq 'web') {
224: $currentstring = $token->[2];
225: }
226: return $currentstring;
227: }
1.35 sakharuk 228: #-- <textarea> tag
1.1 sakharuk 229: sub start_textarea {
230: my ($target,$token) = @_;
231: my $currentstring = '';
232: if ($target eq 'web') {
233: $currentstring = $token->[4];
234: }
235: return $currentstring;
236: }
237: sub end_textarea {
238: my ($target,$token) = @_;
239: my $currentstring = '';
240: if ($target eq 'web') {
241: $currentstring = $token->[2];
242: }
243: return $currentstring;
244: }
1.35 sakharuk 245: #-- <form> tag
1.1 sakharuk 246: sub start_form {
247: my ($target,$token) = @_;
248: my $currentstring = '';
249: if ($target eq 'web') {
250: $currentstring = $token->[4];
251: }
252: return $currentstring;
253: }
254: sub end_form {
255: my ($target,$token) = @_;
256: my $currentstring = '';
257: if ($target eq 'web') {
258: $currentstring = $token->[2];
259: }
260: return $currentstring;
261: }
1.35 sakharuk 262: #-- <title> tag
1.1 sakharuk 263: sub start_title {
264: my ($target,$token) = @_;
265: my $currentstring = '';
266: if ($target eq 'web') {
267: $currentstring = $token->[4];
1.35 sakharuk 268: } elsif ($target eq 'tex') {
269: $currentstring .= '\keephidden{'
1.1 sakharuk 270: }
1.13 www 271: if ($target eq 'meta') {
272: $currentstring='<title>';
273: &start_output();
274: }
1.1 sakharuk 275: return $currentstring;
276: }
277: sub end_title {
278: my ($target,$token) = @_;
279: my $currentstring = '';
280: if ($target eq 'web') {
281: $currentstring = $token->[2];
1.35 sakharuk 282: } elsif ($target eq 'tex') {
283: $currentstring .= '}';
284: }
1.13 www 285: if ($target eq 'meta') {
286: &end_output();
287: $currentstring='</title>';
1.1 sakharuk 288: }
289: return $currentstring;
290: }
1.35 sakharuk 291: #-- <meta> tag
1.1 sakharuk 292: sub start_meta {
1.30 albertel 293: my ($target,$token,$tagstack,$parstack,$parser) = @_;
1.1 sakharuk 294: my $currentstring = '';
295: if ($target eq 'web') {
1.25 albertel 296: my $args='';
297: if ( $#$parstack > -1 ) { $args=$$parstack[$#$parstack]; }
298: if ($args eq '') {
299: &Apache::lonxml::get_all_text("/meta",$$parser[$#$parser]);
300: } else {
301: $currentstring = $token->[4];
302: }
1.12 www 303: }
304: if ($target eq 'meta') {
305: unless ($token->[2]->{'http-equiv'}) {
306: my $name=$token->[2]->{'name'};
307: $name=~tr/A-Z/a-z/;
308: $name=~s/\s/\_/g;
309: if ($name) {
310: $currentstring='<'.$name.'>'.
311: $token->[2]->{'content'}.
312: '</'.$name.'>';
313: }
314: }
1.1 sakharuk 315: }
316: return $currentstring;
317: }
1.26 albertel 318: sub end_meta {
1.30 albertel 319: my ($target,$token,$tagstack,$parstack,$parser) = @_;
1.26 albertel 320: my $currentstring = '';
321: if ($target eq 'web') {
322: my $args='';
323: if ( $#$parstack > -1 ) { $args=$$parstack[$#$parstack]; }
324: if ($args ne '') {
325: $currentstring = $token->[4];
326: }
327: }
328: return $currentstring;
329: }
1.35 sakharuk 330: #-- <body> tag
1.1 sakharuk 331: sub start_body {
1.41 sakharuk 332: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1.1 sakharuk 333: my $currentstring = '';
334: if ($target eq 'web') {
1.31 albertel 335: if (!$Apache::lonxml::registered) {
1.47 matthew 336: $currentstring.='<head>'.
337: &Apache::lonxml::registerurl(undef,$target).'</head>';
1.31 albertel 338: }
1.32 albertel 339: my $onLoad='';
340: foreach my $key (keys(%{$token->[2]})) {
341: if ($key =~ /^onload$/i) {
342: $onLoad.=$token->[2]->{$key}.';';
343: delete($token->[2]->{$key});
344: }
345: }
1.56 albertel 346: $token->[2]->{'onLoad'}=&Apache::lonxml::loadevents().
347: ';'.$onLoad;
1.32 albertel 348: my $onUnload='';
349: foreach my $key (keys(%{$token->[2]})) {
350: if ($key =~ /^onunload$/i) {
351: $onUnload.=$token->[2]->{$key}.';';
352: delete($token->[2]->{$key});
353: }
354: }
1.56 albertel 355: $token->[2]->{'onUnload'}=&Apache::lonxml::unloadevents().
356: ';'.$onUnload;
1.31 albertel 357:
358: $currentstring .= '<'.$token->[1];
1.37 albertel 359: foreach (keys %{$token->[2]}) {
360: $currentstring.=' '.$_.'="'.$token->[2]->{$_}.'"';
361: }
1.31 albertel 362: $currentstring.='>';
1.40 albertel 363: if ($ENV{'request.state'} ne 'published') {
364: $currentstring.=(<<EDITBUTTON);
365: <form method="post">
1.49 albertel 366: <input type="submit" name="editmode" value="Edit" />
1.40 albertel 367: </form>
368: EDITBUTTON
369: }
1.28 www 370: } elsif ($target eq 'tex') {
1.35 sakharuk 371: $currentstring = '\begin{document}';
1.1 sakharuk 372: }
373: return $currentstring;
374: }
375: sub end_body {
376: my ($target,$token) = @_;
377: my $currentstring = '';
378: if ($target eq 'web') {
379: $currentstring = $token->[2];
380: } elsif ($target eq 'tex') {
1.35 sakharuk 381: $currentstring = '\end{document}';
1.1 sakharuk 382: }
383: return $currentstring;
384: }
1.35 sakharuk 385: #-- <center> tag
1.1 sakharuk 386: sub start_center {
387: my ($target,$token) = @_;
388: my $currentstring = '';
389: if ($target eq 'web') {
390: $currentstring = $token->[4];
391: } elsif ($target eq 'tex') {
1.35 sakharuk 392: $currentstring = '\begin{center}';
1.18 sakharuk 393: } elsif ($target eq 'latexsource') {
1.35 sakharuk 394: $currentstring = '\begin{center}';
1.1 sakharuk 395: }
396: return $currentstring;
397: }
398: sub end_center {
399: my ($target,$token) = @_;
400: my $currentstring = '';
401: if ($target eq 'web') {
402: $currentstring = $token->[2];
403: } elsif ($target eq 'tex') {
1.35 sakharuk 404: $currentstring = '\end{center}';
1.18 sakharuk 405: } elsif ($target eq 'latexsource') {
1.35 sakharuk 406: $currentstring = '\end{center}';
1.1 sakharuk 407: }
408: return $currentstring;
409: }
1.35 sakharuk 410: #-- <b> tag
1.1 sakharuk 411: sub start_b {
412: my ($target,$token) = @_;
413: my $currentstring = '';
414: if ($target eq 'web') {
415: $currentstring = $token->[4];
416: } elsif ($target eq 'tex') {
1.35 sakharuk 417: $currentstring = '\textbf{';
1.18 sakharuk 418: } elsif ($target eq 'latexsource') {
1.35 sakharuk 419: $currentstring = '\textbf{';
1.1 sakharuk 420: }
421: return $currentstring;
422: }
423: sub end_b {
424: my ($target,$token) = @_;
425: my $currentstring = '';
426: if ($target eq 'web') {
427: $currentstring = $token->[2];
428: } elsif ($target eq 'tex') {
1.35 sakharuk 429: $currentstring = '}';
430:
1.18 sakharuk 431: } elsif ($target eq 'latexsource') {
1.35 sakharuk 432: $currentstring = '}';
1.1 sakharuk 433: }
434: return $currentstring;
435: }
1.35 sakharuk 436: #-- <strong> tag
1.1 sakharuk 437: sub start_strong {
438: my ($target,$token) = @_;
439: my $currentstring = '';
440: if ($target eq 'web') {
441: $currentstring = $token->[4];
442: } elsif ($target eq 'tex') {
1.35 sakharuk 443: $currentstring = '\textbf{';
1.18 sakharuk 444: } elsif ($target eq 'latexsource') {
1.35 sakharuk 445: $currentstring = '\textbf{';
1.1 sakharuk 446: }
447: return $currentstring;
448: }
449: sub end_strong {
450: my ($target,$token) = @_;
451: my $currentstring = '';
452: if ($target eq 'web') {
453:
454: $currentstring = $token->[2];
455: } elsif ($target eq 'tex') {
1.35 sakharuk 456: $currentstring = '}';
1.18 sakharuk 457: } elsif ($target eq 'latexsource') {
1.35 sakharuk 458: $currentstring = '}';
1.1 sakharuk 459: }
460: return $currentstring;
461: }
1.35 sakharuk 462: #-- <h1> tag
1.1 sakharuk 463: sub start_h1 {
464: my ($target,$token) = @_;
465: my $currentstring = '';
466: if ($target eq 'web') {
467: $currentstring .= $token->[4];
468: } elsif ($target eq 'tex') {
1.87 sakharuk 469: $currentstring .= '{\large \textbf{';
1.13 www 470: } elsif ($target eq 'meta') {
471: $currentstring='<subject>';
472: &start_output();
473: }
1.1 sakharuk 474: return $currentstring;
475: }
476: sub end_h1 {
477: my ($target,$token) = @_;
478: my $currentstring = '';
479: if ($target eq 'web') {
480: $currentstring .= $token->[2];
481: } elsif ($target eq 'tex') {
1.35 sakharuk 482: $currentstring .= '}}';
1.13 www 483: } elsif ($target eq 'meta') {
484: &end_output();
485: $currentstring='</subject>';
486: }
1.1 sakharuk 487: return $currentstring;
488: }
1.35 sakharuk 489: #-- <h2> tag
1.1 sakharuk 490: sub start_h2 {
491: my ($target,$token) = @_;
492: my $currentstring = '';
493: if ($target eq 'web') {
494: $currentstring .= $token->[4];
495: } elsif ($target eq 'tex') {
1.87 sakharuk 496: $currentstring .= '{\large \textbf{';
1.1 sakharuk 497: }
498: return $currentstring;
499: }
500: sub end_h2 {
501: my ($target,$token) = @_;
502: my $currentstring = '';
503: if ($target eq 'web') {
504: $currentstring .= $token->[2];
505: } elsif ($target eq 'tex') {
1.35 sakharuk 506: $currentstring .= '}}';
1.1 sakharuk 507: }
508: return $currentstring;
509: }
1.35 sakharuk 510: #-- <h3> tag
1.1 sakharuk 511: sub start_h3 {
512: my ($target,$token) = @_;
513: my $currentstring = '';
514: if ($target eq 'web') {
515: $currentstring .= $token->[4];
516: } elsif ($target eq 'tex') {
1.87 sakharuk 517: $currentstring .= '{\large \textbf{';
1.1 sakharuk 518: }
519: return $currentstring;
520: }
521: sub end_h3 {
522: my ($target,$token) = @_;
523: my $currentstring = '';
524: if ($target eq 'web') {
525: $currentstring .= $token->[2];
526: } elsif ($target eq 'tex') {
1.35 sakharuk 527: $currentstring .= '}}';
1.1 sakharuk 528: }
529: return $currentstring;
530: }
1.35 sakharuk 531: #-- <h4> tag
1.1 sakharuk 532: sub start_h4 {
533: my ($target,$token) = @_;
534: my $currentstring = '';
535: if ($target eq 'web') {
536: $currentstring .= $token->[4];
537: } elsif ($target eq 'tex') {
1.87 sakharuk 538: $currentstring .= '{\large \textbf{';
1.1 sakharuk 539: }
540: return $currentstring;
541: }
542: sub end_h4 {
543: my ($target,$token) = @_;
544: my $currentstring = '';
545: if ($target eq 'web') {
546: $currentstring .= $token->[2];
547: } elsif ($target eq 'tex') {
1.35 sakharuk 548: $currentstring .= '}}';
1.1 sakharuk 549: }
550: return $currentstring;
551: }
1.35 sakharuk 552: #-- <h5> tag
1.1 sakharuk 553: sub start_h5 {
554: my ($target,$token) = @_;
555: my $currentstring = '';
556: if ($target eq 'web') {
557: $currentstring .= $token->[4];
558: } elsif ($target eq 'tex') {
1.87 sakharuk 559: $currentstring .= '{\large \textbf{';
1.1 sakharuk 560: }
561: return $currentstring;
562: }
563: sub end_h5 {
564: my ($target,$token) = @_;
565: my $currentstring = '';
566: if ($target eq 'web') {
567: $currentstring .= $token->[2];
568: } elsif ($target eq 'tex') {
1.35 sakharuk 569: $currentstring .= '}}';
1.1 sakharuk 570: }
571: return $currentstring;
572: }
1.35 sakharuk 573: #-- <h6> tag
1.1 sakharuk 574: sub start_h6 {
575: my ($target,$token) = @_;
576: my $currentstring = '';
577: if ($target eq 'web') {
578: $currentstring .= $token->[4];
579: } elsif ($target eq 'tex') {
1.87 sakharuk 580: $currentstring .= '{\large \textbf{';
1.1 sakharuk 581: }
582: return $currentstring;
583: }
584: sub end_h6 {
585: my ($target,$token) = @_;
586: my $currentstring = '';
587: if ($target eq 'web') {
588: $currentstring .= $token->[2];
589: } elsif ($target eq 'tex') {
1.35 sakharuk 590: $currentstring .= '}}';
1.1 sakharuk 591: }
592: return $currentstring;
593: }
1.35 sakharuk 594: #--- <cite> tag
1.1 sakharuk 595: sub start_cite {
596: my ($target,$token) = @_;
597: my $currentstring = '';
598: if ($target eq 'web') {
599: $currentstring .= $token->[4];
600: } elsif ($target eq 'tex') {
1.18 sakharuk 601: $currentstring .= "\\textit{";
602: } elsif ($target eq 'latexsource') {
603: $currentstring .= "\\textit{";
1.1 sakharuk 604: }
605: return $currentstring;
606: }
607: sub end_cite {
608: my ($target,$token) = @_;
609: my $currentstring = '';
610: if ($target eq 'web') {
611: $currentstring .= $token->[2];
612: } elsif ($target eq 'tex') {
613: $currentstring .= "}";
1.18 sakharuk 614: } elsif ($target eq 'latexsource') {
615: $currentstring .= "}";
1.1 sakharuk 616: }
617: return $currentstring;
618: }
1.35 sakharuk 619: #-- <i> tag
1.1 sakharuk 620: sub start_i {
621: my ($target,$token) = @_;
622: my $currentstring = '';
623: if ($target eq 'web') {
624: $currentstring .= $token->[4];
625: } elsif ($target eq 'tex') {
1.35 sakharuk 626: $currentstring .= '\textit{';
1.18 sakharuk 627: } elsif ($target eq 'latexsource') {
1.35 sakharuk 628: $currentstring .= '\textit{';
1.1 sakharuk 629: }
630: return $currentstring;
631: }
632: sub end_i {
633: my ($target,$token) = @_;
634: my $currentstring = '';
635: if ($target eq 'web') {
636: $currentstring .= $token->[2];
637: } elsif ($target eq 'tex') {
1.35 sakharuk 638: $currentstring .= '}';
1.18 sakharuk 639: } elsif ($target eq 'latexsource') {
1.35 sakharuk 640: $currentstring .= '}';
1.1 sakharuk 641: }
642: return $currentstring;
643: }
1.35 sakharuk 644: #-- <address> tag
1.1 sakharuk 645: sub start_address {
646: my ($target,$token) = @_;
647: my $currentstring = '';
648: if ($target eq 'web') {
649: $currentstring .= $token->[4];
650: } elsif ($target eq 'tex') {
1.18 sakharuk 651: $currentstring .= "\\textit{";
652: } elsif ($target eq 'latexsource') {
653: $currentstring .= "\\textit{";
1.1 sakharuk 654: }
655: return $currentstring;
656: }
657: sub end_address {
658: my ($target,$token) = @_;
659: my $currentstring = '';
660: if ($target eq 'web') {
661: $currentstring .= $token->[2];
662: } elsif ($target eq 'tex') {
663: $currentstring .= "}";
1.18 sakharuk 664: } elsif ($target eq 'latexsource') {
665: $currentstring .= "}";
1.1 sakharuk 666: }
667: return $currentstring;
668: }
1.35 sakharuk 669: #-- <dfn> tag
1.1 sakharuk 670: sub start_dfn {
671: my ($target,$token) = @_;
672: my $currentstring = '';
673: if ($target eq 'web') {
674: $currentstring .= $token->[4];
675: } elsif ($target eq 'tex') {
1.18 sakharuk 676: $currentstring .= "\\textit{";
677: } elsif ($target eq 'latexsource') {
678: $currentstring .= "\\textit{";
1.1 sakharuk 679: }
680: return $currentstring;
681: }
682: sub end_dfn {
683: my ($target,$token) = @_;
684: my $currentstring = '';
685: if ($target eq 'web') {
686: $currentstring .= $token->[2];
687: } elsif ($target eq 'tex') {
688: $currentstring .= "}";
1.18 sakharuk 689: } elsif ($target eq 'latexsource') {
690: $currentstring .= "}";
1.1 sakharuk 691: }
692: return $currentstring;
693: }
1.35 sakharuk 694: #-- <tt> tag
1.1 sakharuk 695: sub start_tt {
696: my ($target,$token) = @_;
697: my $currentstring = '';
698: if ($target eq 'web') {
699: $currentstring .= $token->[4];
700: } elsif ($target eq 'tex') {
1.35 sakharuk 701: $currentstring .= '\texttt{';
1.18 sakharuk 702: } elsif ($target eq 'latexsource') {
1.35 sakharuk 703: $currentstring .= '\texttt{';
1.1 sakharuk 704: }
705: return $currentstring;
706: }
707: sub end_tt {
708: my ($target,$token) = @_;
709: my $currentstring = '';
710: if ($target eq 'web') {
711: $currentstring .= $token->[2];
712: } elsif ($target eq 'tex') {
1.35 sakharuk 713: $currentstring .= '}';
1.18 sakharuk 714: } elsif ($target eq 'latexsource') {
1.35 sakharuk 715: $currentstring .= '}';
1.18 sakharuk 716: }
1.1 sakharuk 717: return $currentstring;
718: }
1.35 sakharuk 719: #-- <kbd> tag
1.1 sakharuk 720: sub start_kbd {
721: my ($target,$token) = @_;
722: my $currentstring = '';
723: if ($target eq 'web') {
724: $currentstring .= $token->[4];
725: } elsif ($target eq 'tex') {
1.18 sakharuk 726: $currentstring .= "\\texttt";
727: } elsif ($target eq 'latexsource') {
728: $currentstring .= "\\texttt{";
1.1 sakharuk 729: }
730: return $currentstring;
731: }
732: sub end_kbd {
733: my ($target,$token) = @_;
734: my $currentstring = '';
735: if ($target eq 'web') {
736: $currentstring .= $token->[2];
737: } elsif ($target eq 'tex') {
738: $currentstring .= "}";
1.18 sakharuk 739: } elsif ($target eq 'latexsource') {
740: $currentstring .= "}";
1.1 sakharuk 741: }
742: return $currentstring;
743: }
1.35 sakharuk 744: #-- <code> tag
1.1 sakharuk 745: sub start_code {
746: my ($target,$token) = @_;
747: my $currentstring = '';
748: if ($target eq 'web') {
749: $currentstring .= $token->[4];
750: } elsif ($target eq 'tex') {
1.35 sakharuk 751: $currentstring .= '\texttt{';
1.1 sakharuk 752: }
753: return $currentstring;
754: }
755: sub end_code {
756: my ($target,$token) = @_;
757: my $currentstring = '';
758: if ($target eq 'web') {
759: $currentstring .= $token->[2];
760: } elsif ($target eq 'tex') {
1.35 sakharuk 761: $currentstring .= '}';
1.1 sakharuk 762: }
763: return $currentstring;
764: }
1.35 sakharuk 765: #-- <em> tag
1.1 sakharuk 766: sub start_em {
767: my ($target,$token) = @_;
768: my $currentstring = '';
769: if ($target eq 'web') {
770: $currentstring .= $token->[4];
771: } elsif ($target eq 'tex') {
1.35 sakharuk 772: $currentstring .= '\emph{';
1.18 sakharuk 773: } elsif ($target eq 'latexsource') {
1.35 sakharuk 774: $currentstring .= '\emph{';
1.1 sakharuk 775: }
776: return $currentstring;
777: }
778: sub end_em {
779: my ($target,$token) = @_;
780: my $currentstring = '';
781: if ($target eq 'web') {
782: $currentstring .= $token->[2];
783: } elsif ($target eq 'tex') {
1.35 sakharuk 784: $currentstring .= '}';
1.18 sakharuk 785: } elsif ($target eq 'latexsource') {
1.35 sakharuk 786: $currentstring .= '}';
1.18 sakharuk 787: }
1.1 sakharuk 788: return $currentstring;
789: }
1.35 sakharuk 790: #-- <q> tag
1.1 sakharuk 791: sub start_q {
792: my ($target,$token) = @_;
793: my $currentstring = '';
794: if ($target eq 'web') {
795: $currentstring .= $token->[4];
796: } elsif ($target eq 'tex') {
1.18 sakharuk 797: $currentstring .= "\\emph{";
798: } elsif ($target eq 'latexsource') {
799: $currentstring .= "\\emph{";
800: }
1.1 sakharuk 801: return $currentstring;
802: }
803: sub end_q {
804: my ($target,$token) = @_;
805: my $currentstring = '';
806: if ($target eq 'web') {
807: $currentstring .= $token->[2];
808: } elsif ($target eq 'tex') {
809: $currentstring .= "}";
1.18 sakharuk 810: } elsif ($target eq 'latexsource') {
811: $currentstring .= "}";
812: }
1.1 sakharuk 813: return $currentstring;
814: }
1.35 sakharuk 815: #-- <p> tag
1.1 sakharuk 816: sub start_p {
817: my ($target,$token) = @_;
818: my $currentstring = '';
819: if ($target eq 'web') {
820: $currentstring .= $token->[4];
821: } elsif ($target eq 'tex') {
1.35 sakharuk 822: $currentstring .= '{\par ';
1.18 sakharuk 823: } elsif ($target eq 'latexsource') {
1.35 sakharuk 824: $currentstring .= '{\par ';
1.1 sakharuk 825: }
826: return $currentstring;
827: }
828: sub end_p {
829: my ($target,$token) = @_;
830: my $currentstring = '';
831: if ($target eq 'web') {
832: $currentstring .= $token->[2];
833: } elsif ($target eq 'tex') {
1.35 sakharuk 834: $currentstring .= '}';
1.18 sakharuk 835: } elsif ($target eq 'latexsource') {
1.35 sakharuk 836: $currentstring .= '}';
1.1 sakharuk 837: }
838: return $currentstring;
839: }
1.35 sakharuk 840: #-- <br> tag
1.1 sakharuk 841: sub start_br {
1.75 sakharuk 842: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1.1 sakharuk 843: my $currentstring = '';
844: if ($target eq 'web') {
845: $currentstring .= $token->[4];
846: } elsif ($target eq 'tex') {
1.76 sakharuk 847: if ($$tagstack[-2] ne 'sub' && $$tagstack[-2] ne 'sup') {
1.96 sakharuk 848: $currentstring .= '\vskip 0.2 mm';
1.75 sakharuk 849: }
1.18 sakharuk 850: } elsif ($target eq 'latexsource') {
1.35 sakharuk 851: $currentstring .= '\\';
1.1 sakharuk 852: }
853: return $currentstring;
854: }
855: sub end_br {
856: my ($target,$token) = @_;
857: my $currentstring = '';
858: if ($target eq 'web') {
859: $currentstring .= $token->[2];
860: }
861: return $currentstring;
862: }
1.35 sakharuk 863: #-- <big> tag
1.1 sakharuk 864: sub start_big {
865: my ($target,$token) = @_;
866: my $currentstring = '';
867: if ($target eq 'web') {
868: $currentstring .= $token->[4];
869: } elsif ($target eq 'tex') {
1.36 albertel 870: $currentstring .= '\large{';
1.18 sakharuk 871: } elsif ($target eq 'latexsource') {
1.41 sakharuk 872: $currentstring .= '{\Large ';
1.18 sakharuk 873: }
1.1 sakharuk 874: return $currentstring;
875: }
876: sub end_big {
877: my ($target,$token) = @_;
878: my $currentstring = '';
879: if ($target eq 'web') {
880: $currentstring .= $token->[2];
881: } elsif ($target eq 'tex') {
1.35 sakharuk 882: $currentstring .= '}';
1.18 sakharuk 883: } elsif ($target eq 'latexsource') {
1.35 sakharuk 884: $currentstring .= '}';
1.1 sakharuk 885: }
886: return $currentstring;
887: }
1.35 sakharuk 888: #-- <small> tag
1.1 sakharuk 889: sub start_small {
890: my ($target,$token) = @_;
891: my $currentstring = '';
892: if ($target eq 'web') {
893: $currentstring .= $token->[4];
894: } elsif ($target eq 'tex') {
1.41 sakharuk 895: $currentstring .= '{\footnotesize ';
1.18 sakharuk 896: } elsif ($target eq 'latexsource') {
1.41 sakharuk 897: $currentstring .= '{\footnotesize ';
1.1 sakharuk 898: }
899: return $currentstring;
900: }
901: sub end_small {
902: my ($target,$token) = @_;
903: my $currentstring = '';
904: if ($target eq 'web') {
905: $currentstring .= $token->[2];
906: } elsif ($target eq 'tex') {
1.35 sakharuk 907: $currentstring .= '}';
1.18 sakharuk 908: } elsif ($target eq 'latexsource') {
1.35 sakharuk 909: $currentstring .= '}';
1.1 sakharuk 910: }
911: return $currentstring;
912: }
1.35 sakharuk 913: #-- <basefont> tag
1.1 sakharuk 914: sub start_basefont {
1.14 albertel 915: my ($target,$token) = @_;
916: my $currentstring = '';
917: if ($target eq 'web') {
918: $currentstring = $token->[4];
919: }
920: return $currentstring;
921: }
922: sub end_basefont {
923: my ($target,$token) = @_;
924: my $currentstring = '';
925: if ($target eq 'web') {
926: $currentstring = $token->[4];
927: }
928: return $currentstring;
929: }
1.35 sakharuk 930: #-- <font> tag
1.1 sakharuk 931: sub start_font {
1.61 albertel 932: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1.1 sakharuk 933: my $currentstring = '';
934: if ($target eq 'web') {
1.61 albertel 935: my $face=&Apache::lonxml::get_param('face',$parstack,$safeeval);
936: if ($face=~/symbol/i) {$Apache::lonxml::prevent_entity_encode++;}
1.1 sakharuk 937: $currentstring = $token->[4];
938: }
939: return $currentstring;
940: }
941: sub end_font {
1.61 albertel 942: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1.1 sakharuk 943: my $currentstring = '';
944: if ($target eq 'web') {
1.61 albertel 945: my $face=&Apache::lonxml::get_param('face',$parstack,$safeeval);
946: if ($face=~/symbol/i) {$Apache::lonxml::prevent_entity_encode--;}
1.1 sakharuk 947: $currentstring = $token->[2];
948: }
949: return $currentstring;
950: }
1.35 sakharuk 951: #-- <strike> tag
1.1 sakharuk 952: sub start_strike {
953: my ($target,$token) = @_;
954: my $currentstring = '';
955: if ($target eq 'web') {
956: $currentstring .= $token->[4];
957: } elsif ($target eq 'tex') {
1.76 sakharuk 958: $currentstring .= '\underline{';
1.1 sakharuk 959: }
960: return $currentstring;
961: }
962: sub end_strike {
963: my ($target,$token) = @_;
964: my $currentstring = '';
965: if ($target eq 'web') {
966: $currentstring .= $token->[2];
967: } elsif ($target eq 'tex') {
1.76 sakharuk 968: $currentstring .= '}';
1.1 sakharuk 969: }
970: return $currentstring;
971: }
1.35 sakharuk 972: #-- <s> tag
1.1 sakharuk 973: sub start_s {
974: my ($target,$token) = @_;
975: my $currentstring = '';
976: if ($target eq 'web') {
977: $currentstring .= $token->[4];
978: } elsif ($target eq 'tex') {
1.76 sakharuk 979: $currentstring .= '\underline{';
1.1 sakharuk 980: }
981: return $currentstring;
982: }
983: sub end_s {
984: my ($target,$token) = @_;
985: my $currentstring = '';
986: if ($target eq 'web') {
987: $currentstring .= $token->[2];
988: } elsif ($target eq 'tex') {
1.76 sakharuk 989: $currentstring .= '}';
1.1 sakharuk 990: }
991: return $currentstring;
992: }
1.35 sakharuk 993: #-- <sub> tag
1.1 sakharuk 994: sub start_sub {
995: my ($target,$token) = @_;
996: my $currentstring = '';
997: if ($target eq 'web') {
998: $currentstring .= $token->[4];
999: } elsif ($target eq 'tex') {
1000: $currentstring .= "\$_{ ";
1001: }
1002: return $currentstring;
1003: }
1004: sub end_sub {
1005: my ($target,$token) = @_;
1006: my $currentstring = '';
1007: if ($target eq 'web') {
1008: $currentstring .= $token->[2];
1009: } elsif ($target eq 'tex') {
1010: $currentstring .= " }\$";
1011: }
1012: return $currentstring;
1013: }
1.35 sakharuk 1014: #-- <sup> tag
1.1 sakharuk 1015: sub start_sup {
1016: my ($target,$token) = @_;
1017: my $currentstring = '';
1018: if ($target eq 'web') {
1019: $currentstring .= $token->[4];
1020: } elsif ($target eq 'tex') {
1021: $currentstring .= "\$^{ ";
1022: }
1023: return $currentstring;
1024: }
1025: sub end_sup {
1026: my ($target,$token) = @_;
1027: my $currentstring = '';
1028: if ($target eq 'web') {
1029: $currentstring .= $token->[2];
1030: } elsif ($target eq 'tex') {
1031: $currentstring .= " }\$";
1032: }
1033: return $currentstring;
1034: }
1.35 sakharuk 1035: #-- <hr> tag
1.1 sakharuk 1036: sub start_hr {
1037: my ($target,$token) = @_;
1038: my $currentstring = '';
1039: if ($target eq 'web') {
1040: $currentstring .= $token->[4];
1041: } elsif ($target eq 'tex') {
1.85 sakharuk 1042: $currentstring .= '\vskip 0 mm \noindent\makebox[\textwidth/2 ][b]{\hrulefill}\vskip 0 mm ';
1.6 sakharuk 1043: }
1044: return $currentstring;
1045: }
1046: sub end_hr {
1047: my ($target,$token) = @_;
1048: my $currentstring = '';
1049: if ($target eq 'web') {
1050: $currentstring .= $token->[2];
1051: } elsif ($target eq 'tex') {
1.85 sakharuk 1052: }
1053: return $currentstring;
1054: }
1055: #-- <div> tag
1056: sub start_div {
1057: my ($target,$token) = @_;
1058: my $currentstring = '';
1059: if ($target eq 'web') {
1060: $currentstring .= $token->[4];
1061: }
1062: return $currentstring;
1063: }
1064: sub end_div {
1065: my ($target,$token) = @_;
1066: my $currentstring = '';
1067: if ($target eq 'web') {
1068: $currentstring .= $token->[2];
1.1 sakharuk 1069: }
1070: return $currentstring;
1071: }
1.35 sakharuk 1072: #-- <a> tag
1.1 sakharuk 1073: sub start_a {
1074: my ($target,$token) = @_;
1075: my $currentstring = '';
1076: if ($target eq 'web') {
1077: $currentstring .= $token->[4];
1078: } elsif ($target eq 'tex') {
1079: }
1080: return $currentstring;
1081: }
1082: sub end_a {
1.30 albertel 1083: my ($target,$token,$tagstack,$stackref) = @_;
1.1 sakharuk 1084: my $currentstring = '';
1085: if ($target eq 'web') {
1086: $currentstring .= $token->[2];
1087: } elsif ($target eq 'tex') {
1088: my $tempor_var = $stackref->[$#$stackref];
1089: if (index($tempor_var,'name') != -1 ) {
1090: $tempor_var =~ s/name=([^,]*),/$1/g;
1091: } elsif (index($tempor_var,'href') != -1 ) {
1092: $tempor_var =~ s/href=([^,]*),/$1/g;
1093: $currentstring .= " \\ref{$tempor_var}";
1094: }
1095: }
1096: return $currentstring;
1097: }
1.35 sakharuk 1098: #-- <li> tag
1.1 sakharuk 1099: sub start_li {
1.30 albertel 1100: my ($target,$token,$tagstack,$stackref) = @_;
1.1 sakharuk 1101: my $currentstring = '';
1102: if ($target eq 'web') {
1103: $currentstring = $token->[4];
1104: } elsif ($target eq 'tex') {
1.15 sakharuk 1105: my $tempor_var = $stackref->[$#$stackref];
1.1 sakharuk 1106: if (index($tempor_var,'circle') != -1 ) {
1107: $currentstring .= " \\item[o] ";
1108: } elsif (index($tempor_var,'square') != -1 ) {
1109: $currentstring .= " \\item[$\Box$] ";
1.15 sakharuk 1110: } elsif ($tempor_var ne '') {
1111: $_ = $tempor_var;
1112: m/my\s*([^=]*)=/;
1113: $currentstring .= " \\item[$1] ";
1114: } else {
1.1 sakharuk 1115: $currentstring .= " \\item ";
1116: }
1117: }
1118: return $currentstring;
1119: }
1120: sub end_li {
1121: my ($target,$token) = @_;
1122: my $currentstring = '';
1123: if ($target eq 'web') {
1124: $currentstring = $token->[2];
1125: }
1126: return $currentstring;
1127: }
1.35 sakharuk 1128: #-- <u> tag
1.1 sakharuk 1129: sub start_u {
1130: my ($target,$token) = @_;
1131: my $currentstring = '';
1132: if ($target eq 'web') {
1133: $currentstring .= $token->[4];
1134: } elsif ($target eq 'tex') {
1.76 sakharuk 1135: $currentstring .= '\underline{';
1.1 sakharuk 1136: }
1137: return $currentstring;
1138: }
1139: sub end_u {
1140: my ($target,$token) = @_;
1141: my $currentstring = '';
1142: if ($target eq 'web') {
1143: $currentstring .= $token->[2];
1144: } elsif ($target eq 'tex') {
1.76 sakharuk 1145: $currentstring .= '}';
1.1 sakharuk 1146: }
1147: return $currentstring;
1148: }
1.35 sakharuk 1149: #-- <ul> tag
1.1 sakharuk 1150: sub start_ul {
1151: my ($target,$token) = @_;
1152: my $currentstring = '';
1153: if ($target eq 'web') {
1154: $currentstring = $token->[4];
1155: } elsif ($target eq 'tex') {
1.41 sakharuk 1156: $currentstring = '\begin{itemize}';
1.1 sakharuk 1157: }
1158: return $currentstring;
1159: }
1160: sub end_ul {
1161: my ($target,$token) = @_;
1162: my $currentstring = '';
1163: if ($target eq 'web') {
1164: $currentstring = $token->[2];
1165: } elsif ($target eq 'tex') {
1.41 sakharuk 1166: $currentstring = '\end{itemize}';
1.1 sakharuk 1167: }
1168: return $currentstring;
1169: }
1.35 sakharuk 1170: #-- <menu> tag
1.1 sakharuk 1171: sub start_menu {
1172: my ($target,$token) = @_;
1173: my $currentstring = '';
1174: if ($target eq 'web') {
1175: $currentstring = $token->[4];
1176: } elsif ($target eq 'tex') {
1177: $currentstring = " \\begin{itemize} ";
1178: }
1179: return $currentstring;
1180: }
1181: sub end_menu {
1182: my ($target,$token) = @_;
1183: my $currentstring = '';
1184: if ($target eq 'web') {
1185: $currentstring = $token->[2];
1186: } elsif ($target eq 'tex') {
1187: $currentstring = " \\end{itemize}";
1188: }
1189: return $currentstring;
1190: }
1.35 sakharuk 1191: #-- <dir> tag
1.1 sakharuk 1192: sub start_dir {
1193: my ($target,$token) = @_;
1194: my $currentstring = '';
1195: if ($target eq 'web') {
1196: $currentstring = $token->[4];
1197: } elsif ($target eq 'tex') {
1198: $currentstring = " \\begin{itemize} ";
1199: }
1200: return $currentstring;
1201: }
1202: sub end_dir {
1203: my ($target,$token) = @_;
1204: my $currentstring = '';
1205: if ($target eq 'web') {
1206: $currentstring = $token->[2];
1207: } elsif ($target eq 'tex') {
1208: $currentstring = " \\end{itemize}";
1209: }
1210: return $currentstring;
1211: }
1.35 sakharuk 1212: #-- <ol> tag
1.1 sakharuk 1213: sub start_ol {
1214: my ($target,$token) = @_;
1215: my $currentstring = '';
1216: if ($target eq 'web') {
1217: $currentstring = $token->[4];
1218: } elsif ($target eq 'tex') {
1.41 sakharuk 1219: $currentstring = '\begin{enumerate}';
1.1 sakharuk 1220: }
1221: return $currentstring;
1222: }
1223: sub end_ol {
1224: my ($target,$token) = @_;
1225: my $currentstring = '';
1226: if ($target eq 'web') {
1227: $currentstring = $token->[2];
1228: } elsif ($target eq 'tex') {
1.41 sakharuk 1229: $currentstring = '\end{enumerate}';
1.1 sakharuk 1230: }
1231: return $currentstring;
1232: }
1.35 sakharuk 1233: #-- <dl> tag
1.1 sakharuk 1234: sub start_dl {
1235: my ($target,$token) = @_;
1236: my $currentstring = '';
1237: if ($target eq 'web') {
1238: $currentstring = $token->[4];
1239: } elsif ($target eq 'tex') {
1.41 sakharuk 1240: $currentstring = '\begin{description}';
1.1 sakharuk 1241: }
1242: return $currentstring;
1243: }
1244: sub end_dl {
1245: my ($target,$token) = @_;
1246: my $currentstring = '';
1247: if ($target eq 'web') {
1248: $currentstring = $token->[2];
1249: } elsif ($target eq 'tex') {
1.41 sakharuk 1250: $currentstring = '\end{description}';
1.1 sakharuk 1251: }
1252: return $currentstring;
1253: }
1.35 sakharuk 1254: #-- <dt> tag
1.1 sakharuk 1255: sub start_dt {
1256: my ($target,$token) = @_;
1257: my $currentstring = '';
1258: if ($target eq 'web') {
1259: $currentstring = $token->[4];
1260: } elsif ($target eq 'tex') {
1.41 sakharuk 1261: $currentstring = '\item[';
1.1 sakharuk 1262: }
1263: return $currentstring;
1264: }
1265: sub end_dt {
1266: my ($target,$token) = @_;
1267: my $currentstring = '';
1268: if ($target eq 'web') {
1269: $currentstring = $token->[2];
1270: } elsif ($target eq 'tex') {
1.41 sakharuk 1271: $currentstring = ']';
1.1 sakharuk 1272: }
1273: return $currentstring;
1274: }
1.35 sakharuk 1275: #-- <dd> tag
1.1 sakharuk 1276: sub start_dd {
1277: my ($target,$token) = @_;
1278: my $currentstring = '';
1279: if ($target eq 'web') {
1280: $currentstring = $token->[4];
1281: }
1282: return $currentstring;
1283: }
1284: sub end_dd {
1285: my ($target,$token) = @_;
1286: my $currentstring = '';
1287: if ($target eq 'web') {
1288: $currentstring = $token->[2];
1289: }
1290: return $currentstring;
1291: }
1.35 sakharuk 1292: #-- <table> tag
1.91 sakharuk 1293: sub start_table {
1294: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1295: my $currentstring = '';
1296: if ($target eq 'web') {
1297: $currentstring = $token->[4];
1298: } elsif ($target eq 'tex') {
1299: my $aa = {};
1300: push @Apache::londefdef::table, $aa;
1301: $Apache::londefdef::table[-1]{'row_number'} = -1;
1302: $Apache::londefdef::table[-1]{'output'} = ' \noindent \begin{tabular} ';
1303: my $border = &Apache::lonxml::get_param('border',$parstack,$safeeval);
1304: unless (defined $border) { $border = 0; }
1305: if ($border) {
1306: $Apache::londefdef::table[-1]{'hinc'} = '\hline ';
1307: $Apache::londefdef::table[-1]{'vinc'} = '&';
1308: $Apache::londefdef::table[-1]{'vvinc'} = '|';
1309: } else {
1310: $Apache::londefdef::table[-1]{'hinc'} = '';
1311: $Apache::londefdef::table[-1]{'vinc'} = '&';
1312: $Apache::londefdef::table[-1]{'vvinc'} = '';
1313: }
1314: my $width;
1315: foreach my $key (keys(%{$token->[2]})) {
1316: if ($key =~ /^width$/i) {
1317: $width = &Apache::lonxml::get_param($key,$parstack,$safeeval);
1318: }
1.51 sakharuk 1319: }
1.91 sakharuk 1320: if (defined($width)) { $Apache::londefdef::table[-1]{'width'}=$width; }
1321: }
1322: return $currentstring;
1323: }
1.51 sakharuk 1324: sub end_table {
1.79 sakharuk 1325: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1.51 sakharuk 1326: my $currentstring = '';
1327: if ($target eq 'web') {
1328: $currentstring = $token->[2];
1329: } elsif ($target eq 'tex') {
1.53 sakharuk 1330: my $inmemory = '';
1.52 sakharuk 1331: my $output = '';
1.79 sakharuk 1332: #construct header of the table
1.53 sakharuk 1333: my $header_of_table = '{'.$Apache::londefdef::table[-1]{'vvinc'};
1.50 sakharuk 1334: my $in;
1.53 sakharuk 1335: for ($in=0;$in<=$Apache::londefdef::table[-1]{'counter_columns'};$in++) {
1336: $header_of_table .= $Apache::londefdef::table[-1]{'columns'}[$in].$Apache::londefdef::table[-1]{'vvinc'};
1337: }
1338: $header_of_table .= '}';
1.79 sakharuk 1339: #fill the table
1.53 sakharuk 1340: for ($in=0;$in<=$Apache::londefdef::table[-1]{'row_number'};$in++) {
1341: $output .= $Apache::londefdef::table[-1]{'rowdata'}[$in];
1.52 sakharuk 1342: chop $output;
1343: $output .= ' \\\\ ';
1.50 sakharuk 1344: }
1.79 sakharuk 1345: #define the length of the table cells
1346: my @lengthforoutput = split(/,/,$Apache::londefdef::table[-1]{'lengthrow'}[0]);
1.91 sakharuk 1347: my $how_many_columns = $#lengthforoutput + 1; #total number of columns in the table
1348: my $filled_columns = 0; #number of columns with information about width
1349: my $available_space = ' ';
1.79 sakharuk 1350: foreach my $tempo_length (@{ $Apache::londefdef::table[-1]{'lengthrow'} }) {
1351: my @length = split(/,/,$tempo_length);
1352: for (my $ico=0;$ico<=$#lengthforoutput;$ico++) {
1353: $lengthforoutput[$ico] =~ m/(\d*\.?\d*)\s*(\w+)/;
1354: my $old_value = $1;
1355: my $old_unit = $2;
1356: if ($old_unit eq 'cm') {
1357: $old_value = $old_value * 10;
1358: } elsif ($old_unit eq 'in') {
1359: $old_value = $old_value * 25.4;
1360: } elsif ($old_unit eq 'pt') {
1361: $old_value = $old_value * 25.4/72.27;
1362: } elsif ($old_unit eq 'pc') {
1363: $old_value = $old_value * 25.4/6.022;
1364: }
1365: $old_unit = 'mm';
1366: $length[$ico] =~ m/(\d*\.?\d*)\s*(\w+)/;
1367: my $new_value = $1;
1368: my $new_unit = $2;
1369: if ($new_unit eq 'cm') {
1370: $new_value = $new_value * 10;
1371: } elsif ($old_unit eq 'in') {
1372: $new_value = $new_value * 25.4;
1373: } elsif ($old_unit eq 'pt') {
1374: $new_value = $new_value * 25.4/72.27;
1375: } elsif ($old_unit eq 'pc') {
1376: $new_value = $new_value * 25.4/6.022;
1377: }
1378: $new_unit = 'mm';
1379: if ($old_value < $new_value) {
1380: $lengthforoutput[$ico] = $new_value.' mm';
1381: } else {
1382: $lengthforoutput[$ico] = $old_value.' mm';
1383: }
1384: }
1385: }
1.91 sakharuk 1386: for (my $ico=0;$ico<=$#lengthforoutput;$ico++) {
1387: if (not $lengthforoutput[$ico]=~m/^\s*0\s*\w*\s*$/) {
1388: $filled_columns++;
1389: $available_space = $available_space.' - '.$lengthforoutput[$ico];
1390: }
1.71 sakharuk 1391: }
1.91 sakharuk 1392: my $temp_file;
1393: my $filename = "/home/httpd/prtspool/$ENV{'user.name'}_$ENV{'user.domain'}_printout.tbl";
1394: if (-e $filename) {
1395: $temp_file = Apache::File->new($filename);
1396: my @tbl_file_content = <$temp_file>;
1397: my ($one,$two,$three) = split(/,/,$tbl_file_content[0]);
1398: $how_many_columns+=$one-1;
1399: $filled_columns+=$two;
1400: if($three=~/\S/) {$available_space = $available_space.' - '.$three;}
1401: } else {
1402: $temp_file = Apache::File->new('>>'.$filename);
1403: }
1404: print $temp_file "$how_many_columns,$filled_columns,$available_space\n";
1405: $output =~ s/\\parbox{TOBECHANGEDONNUMBER}{}/\\parbox{1 mm}{}/g;
1406: $output =~ s/\\parbox{TOBECHANGEDONNUMBER}/\\parbox{\$SpacePerColumn}/g;
1.79 sakharuk 1407: my @tagar = @$tagstack;
1408: my $signature = 1;
1409: for (my $ico=0;$ico<$#tagar;$ico++) {
1410: if ($tagar[$ico] eq 'table') { $signature = 0; }
1411: }
1412: if ($signature) {
1.91 sakharuk 1413: my $NumberEmptyLength = $how_many_columns - $filled_columns;
1414: my $SpacePerColumn = '(\textwidth '.$available_space.')/'.$NumberEmptyLength;
1.97 sakharuk 1415: my $shorthand = ($NumberEmptyLength+1)*4;
1416: $output =~ s/\$SpacePerColumn/$SpacePerColumn - $shorthand mm/g;
1.91 sakharuk 1417: }
1.70 sakharuk 1418: $Apache::londefdef::table[-1]{'output'} .= $header_of_table.$output.$Apache::londefdef::table[-1]{'hinc'}.'\end{tabular}\vskip 0 mm ';
1.53 sakharuk 1419: if ($#Apache::londefdef::table > 0) {
1420: $inmemory = $Apache::londefdef::table[-1]{'output'};
1421: pop @Apache::londefdef::table;
1.91 sakharuk 1422: $Apache::londefdef::table[-1]{'rowdata'}[$Apache::londefdef::table[-1]{'row_number'}] .= $inmemory
1.53 sakharuk 1423: } else {
1424: $currentstring = $Apache::londefdef::table[-1]{'output'};
1425: $currentstring =~ s/\\\\\s+\\\\/\\\\/g;
1426: pop @Apache::londefdef::table;
1.81 sakharuk 1427: if (-e $filename) {
1428: unlink $filename;
1429: }
1.53 sakharuk 1430: }
1.51 sakharuk 1431: }
1432: return $currentstring;
1433: }
1434: #-- <tr> tag
1435: sub start_tr {
1436: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1437: my $currentstring = '';
1438: if ($target eq 'web') {
1439: $currentstring = $token->[4];
1440: } elsif ($target eq 'tex') {
1.53 sakharuk 1441: $Apache::londefdef::table[-1]{'row_number'}++;
1442: my $alignchar = substr(&Apache::lonxml::get_param('align',$parstack,$safeeval),0,1);
1443: if ($alignchar ne '') {
1444: push @ {$Apache::londefdef::table[-1]{'rows'} }, $alignchar;
1.51 sakharuk 1445: } else {
1.69 sakharuk 1446: push @ {$Apache::londefdef::table[-1]{'rows'} }, 'l';
1.51 sakharuk 1447: }
1.53 sakharuk 1448: push ( @{ $Apache::londefdef::table[-1]{'rowdata'} }, $Apache::londefdef::table[-1]{'hinc'});
1449: $Apache::londefdef::table[-1]{'counter_columns'} = -1;
1.78 sakharuk 1450: $Apache::londefdef::table[-1]{'length'} = '';
1.1 sakharuk 1451: }
1452: return $currentstring;
1.51 sakharuk 1453: }
1454: sub end_tr {
1455: my ($target,$token) = @_;
1456: my $currentstring = '';
1457: if ($target eq 'web') {
1458: $currentstring = $token->[2];
1459: } elsif ($target eq 'tex') {
1.79 sakharuk 1460: push @{ $Apache::londefdef::table[-1]{'lengthrow'} },$Apache::londefdef::table[-1]{'length'};
1461:
1.51 sakharuk 1462: }
1463: return $currentstring;
1.1 sakharuk 1464: }
1.51 sakharuk 1465: #-- <td> tag
1466: sub start_td {
1467: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1468: my $currentstring = '';
1469: if ($target eq 'web') {
1470: $currentstring = $token->[4];
1.91 sakharuk 1471: } elsif ($target eq 'tex') {
1.51 sakharuk 1472: my $what_to_push = substr(&Apache::lonxml::get_param('align',$parstack,$safeeval),0,1);
1473: if ($what_to_push eq '') {
1.53 sakharuk 1474: $what_to_push = substr($Apache::londefdef::table[-1]{'rows'}[0],0,1);;
1.51 sakharuk 1475: }
1.53 sakharuk 1476: push @{ $Apache::londefdef::table[-1]{'columns'} }, $what_to_push;
1477: $Apache::londefdef::table[-1]{'counter_columns'}++;
1.52 sakharuk 1478: &Apache::lonxml::startredirection();
1479: ;
1.51 sakharuk 1480: }
1481: return $currentstring;
1482: }
1483: sub end_td {
1.59 sakharuk 1484: my ($target,$token) = @_;
1485: my $currentstring = '';
1.82 sakharuk 1486: my $tempolen = '';
1.59 sakharuk 1487: if ($target eq 'web') {
1488: $currentstring = $token->[2];
1489: } elsif ($target eq 'tex') {
1490: my $current_row = $Apache::londefdef::table[-1]{'row_number'};
1491: my $data=&Apache::lonxml::endredirection();
1.91 sakharuk 1492: if ($data=~m/width\s*=\s*(\d+\.?\d*\s*(mm|cm|in|pc|pt))/) {
1.82 sakharuk 1493: $Apache::londefdef::table[-1]{'length'} .= $1.',';
1494: $tempolen = $1;
1.78 sakharuk 1495: } else {
1.82 sakharuk 1496: if (length($data)<5) {
1.91 sakharuk 1497: $Apache::londefdef::table[-1]{'length'} .= '0 mm,';
1.82 sakharuk 1498: $tempolen = '5 mm';
1499: } else {
1500: $Apache::londefdef::table[-1]{'length'} .= '0 mm,';
1.91 sakharuk 1501: $tempolen = 'TOBECHANGEDONNUMBER';
1.82 sakharuk 1502: }
1.79 sakharuk 1503: }
1.82 sakharuk 1504: @{ $Apache::londefdef::table[-1]{'rowdata'} }[$current_row] .= '\parbox{'.$tempolen.'}{'.$data.'} '.$Apache::londefdef::table[-1]{'vinc'};
1.59 sakharuk 1505: }
1506: return $currentstring;
1507: }
1508: #-- <th> tag
1509: sub start_th {
1510: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1511: my $currentstring = '';
1512: if ($target eq 'web') {
1513: $currentstring = $token->[4];
1514: } elsif ($target eq 'tex') {
1515: my $what_to_push = substr(&Apache::lonxml::get_param('align',$parstack,$safeeval),0,1);
1516: if ($what_to_push eq '') {
1517: $what_to_push = substr($Apache::londefdef::table[-1]{'rows'}[0],0,1);;
1518: }
1519: push @{ $Apache::londefdef::table[-1]{'columns'} }, $what_to_push;
1520: $Apache::londefdef::table[-1]{'counter_columns'}++;
1521: &Apache::lonxml::startredirection();
1522: ;
1523: }
1524: return $currentstring;
1525: }
1526: sub end_th {
1.1 sakharuk 1527: my ($target,$token) = @_;
1528: my $currentstring = '';
1529: if ($target eq 'web') {
1.51 sakharuk 1530: $currentstring = $token->[2];
1531: } elsif ($target eq 'tex') {
1.53 sakharuk 1532: my $current_row = $Apache::londefdef::table[-1]{'row_number'};
1.52 sakharuk 1533: my $data=&Apache::lonxml::endredirection();
1.78 sakharuk 1534: if ($data=~m/width\s*=\s*(\d+\.*\d*\s*(mm|cm))/) {
1535: $Apache::londefdef::table[-1]{'length'} .= $1.',';
1536: } else {
1537: $Apache::londefdef::table[-1]{'length'} .= '0 mm,';
1538: }
1.72 sakharuk 1539: @{ $Apache::londefdef::table[-1]{'rowdata'} }[$current_row] .= '\parbox{'.$1.'}{\textbf{'.$data.'}} '.$Apache::londefdef::table[-1]{'vinc'};
1.44 sakharuk 1540: }
1.1 sakharuk 1541: return $currentstring;
1542: }
1.35 sakharuk 1543: #-- <img> tag
1.10 www 1544: sub start_img {
1.41 sakharuk 1545: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1.99 ! albertel 1546: my $src = &Apache::lonxml::get_param('src',$parstack,$safeeval,
! 1547: undef,1);
! 1548: $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=$src;
1.10 www 1549: my $currentstring = '';
1.58 sakharuk 1550: my $width_param = '';
1.69 sakharuk 1551: my $height_param = '';
1.90 sakharuk 1552: my $scaling = .3;
1.44 sakharuk 1553:
1.42 albertel 1554: if ($target eq 'web') {
1.99 ! albertel 1555: $currentstring = $token->[4];
1.10 www 1556: } elsif ($target eq 'tex') {
1.99 ! albertel 1557: &image_replication($src);
1.54 sakharuk 1558: $src=&Apache::lonnet::filelocation($Apache::lonxml::pwd[-1],$src);
1.84 sakharuk 1559: #if original gif/jpg file exist do following:
1560: if (-e $src) {
1561: #defines the default size of image
1.80 sakharuk 1562: my $image = Image::Magick->new;
1563: my $current_figure = $image->Read($src);
1564: $width_param = $image->Get('width') * $scaling;;
1565: $height_param = $image->Get('height') * $scaling;;
1566: undef $image;
1567: #do we have any specified size of the picture?
1568: my $TeXwidth = &Apache::lonxml::get_param('TeXwidth',$parstack,$safeeval);
1569: my $TeXheight = &Apache::lonxml::get_param('TeXheight',$parstack,$safeeval);
1570: my $width = &Apache::lonxml::get_param('width',$parstack,$safeeval);
1.90 sakharuk 1571: if ($TeXwidth ne '') {
1572: if ($TeXwidth=~/(\d+)\s*\%/) {
1573: $width_param = $1*$ENV{'form.textwidth'}/100;
1574: } else {
1575: $width_param = $TeXwidth;
1576: }
1577: } elsif ($TeXheight ne '') {
1578: $width_param = $TeXheight/$height_param*$width_param;
1.80 sakharuk 1579: } elsif ($width ne '') {
1580: $width_param = $width*$scaling;
1581: }
1.84 sakharuk 1582: my $file;
1583: my $path;
1584: if ($src =~ m!(.*)/([^/]*)$!) {
1585: $file = $2;
1586: $path = $1.'/';
1587: }
1588: my $newsrc = $src;
1589: $newsrc =~ s/(\.gif|\.jpg)$/\.eps/i;
1590: $file=~s/(\.gif|\.jpg)$/\.eps/i;
1.80 sakharuk 1591: #where can we find the picture?
1592: if (-e $newsrc) {
1.84 sakharuk 1593: #eps counterpart for image exist
1.80 sakharuk 1594: if ($path) {
1.96 sakharuk 1595: $currentstring .= '\vskip 1 mm \noindent\graphicspath{{'.$path.'}}\fbox{\includegraphics[width='.$width_param.' mm]{'.$file.'}} ';
1.62 sakharuk 1596: }
1.80 sakharuk 1597: } else {
1.84 sakharuk 1598: #there is no eps counterpart for image - check for ps one
1599: $newsrc =~ s/\.eps$/\.ps/;
1600: if (-e $newsrc) {
1601: #ps counterpart for image exist
1602: $file =~ s/\.eps$/\.ps/;
1603: if ($path) {
1.96 sakharuk 1604: $currentstring .= '\vskip 1 mm \noindent\graphicspath{{'.$path.'}}\fbox{\includegraphics[width='.$width_param.' mm]{'.$file.'}} ';
1.84 sakharuk 1605: }
1606: } else {
1607: #there aren't eps or ps - so create eps
1608: my $temp_file;
1609: my $filename = "/home/httpd/prtspool/$ENV{'user.name'}_$ENV{'user.domain'}_printout.dat";
1610: $temp_file = Apache::File->new('>>'.$filename);
1611: print $temp_file "$src\n";
1.96 sakharuk 1612: $currentstring .= '\vskip 1 mm \graphicspath{{/home/httpd/prtspool/}}\fbox{\includegraphics[width='.$width_param.' mm]{'.$file.'}} ';
1.84 sakharuk 1613: }
1.62 sakharuk 1614: }
1.80 sakharuk 1615: } else {
1.84 sakharuk 1616: #original image file doesn't exist so check the alt attribute
1.80 sakharuk 1617: my $alt = &Apache::lonxml::get_param('alt',$parstack,$safeeval);
1618: if ($alt) {
1619: $currentstring .= ' '.$alt.' ';
1.62 sakharuk 1620: } else {
1.92 sakharuk 1621: #<allow> tag will care about replication
1.57 sakharuk 1622: }
1.42 albertel 1623: }
1624: }
1625: return $currentstring;
1.10 www 1626: }
1627: sub end_img {
1628: my ($target,$token) = @_;
1629: my $currentstring = '';
1630: if ($target eq 'web') {
1.44 sakharuk 1631: $currentstring = $token->[2];
1.10 www 1632: } elsif ($target eq 'tex') {
1.44 sakharuk 1633: $currentstring = '';
1634: }
1.10 www 1635: return $currentstring;
1636: }
1.35 sakharuk 1637: #-- <applet> tag
1.10 www 1638:
1639: sub start_applet {
1640: my ($target,$token) = @_;
1641: $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=
1642: $token->[2]->{'code'};
1.44 sakharuk 1643: $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=
1.10 www 1644: $token->[2]->{'archive'};
1645: my $currentstring = '';
1646: if ($target eq 'web') {
1.44 sakharuk 1647: $currentstring = $token->[4];
1.10 www 1648: } elsif ($target eq 'tex') {
1.44 sakharuk 1649: $currentstring = " \\begin{figure} ";
1.10 www 1650: }
1651: return $currentstring;
1652: }
1.44 sakharuk 1653: sub end_applet {
1654: my ($target,$token) = @_;
1655: my $currentstring = '';
1656: if ($target eq 'web') {
1657: $currentstring = $token->[2];
1658: } elsif ($target eq 'tex') {
1659: $currentstring = " \\end{figure}";
1660: }
1661: return $currentstring;
1662: }
1.10 www 1663:
1.35 sakharuk 1664: #-- <embed> tag
1.10 www 1665:
1.45 sakharuk 1666: sub start_embed {
1.44 sakharuk 1667: my ($target,$token) = @_;
1668: $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=
1669: $token->[2]->{'src'};
1670: my $currentstring = '';
1671: if ($target eq 'web') {
1672: $currentstring = $token->[4];
1673: } elsif ($target eq 'tex') {
1674: $currentstring = " \\begin{figure} ";
1675: }
1676: return $currentstring;
1677: }
1.10 www 1678: sub end_embed {
1679: my ($target,$token) = @_;
1680: my $currentstring = '';
1681: if ($target eq 'web') {
1682: $currentstring = $token->[2];
1683: } elsif ($target eq 'tex') {
1684: $currentstring = " \\end{figure}";
1685: }
1686: return $currentstring;
1687: }
1688:
1.35 sakharuk 1689: #-- <param> tag
1.10 www 1690:
1.11 www 1691: sub start_param {
1.10 www 1692: my ($target,$token) = @_;
1693: if ($token->[2]->{'name'} eq 'cabbase') {
1694: $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=
1695: $token->[2]->{'value'};
1696: }
1.20 www 1697: $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=
1.10 www 1698: $token->[2]->{'src'};
1699: my $currentstring = '';
1700: if ($target eq 'web') {
1701: $currentstring = $token->[4];
1702: } elsif ($target eq 'tex') {
1703: $currentstring = " \\begin{figure} ";
1704: }
1705: return $currentstring;
1706: }
1.11 www 1707: sub end_param {
1.10 www 1708: my ($target,$token) = @_;
1709: my $currentstring = '';
1710: if ($target eq 'web') {
1711: $currentstring = $token->[2];
1712: } elsif ($target eq 'tex') {
1713: $currentstring = " \\end{figure}";
1714: }
1715: return $currentstring;
1716: }
1.35 sakharuk 1717: #-- <allow> tag
1.98 albertel 1718: sub start_allow {
1719: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1720: $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=
1721: $token->[2]->{'src'};
1722: my $src = &Apache::lonxml::get_param('src',$parstack,$safeeval);
1723: &image_replication($src);
1724: my $result;
1725: if ($target eq 'edit') {
1726: $result .=&Apache::edit::tag_start($target,$token);
1727: $result .=&Apache::edit::text_arg('File Spec:','src',$token,70);
1728: $result .=&Apache::edit::end_row();#.&Apache::edit::start_spanning_row();
1729: } elsif ($target eq 'modified') {
1730: my $constructtag=&Apache::edit::get_new_args($token,$parstack,
1731: $safeeval,'src');
1732: if ($constructtag) { $result = &Apache::edit::rebuild_tag($token); }
1733: }
1734: return $result;
1735: }
1736:
1737: sub end_allow {
1738: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1739: if ( $target eq 'edit') { return (&Apache::edit::end_table()); }
1740: return '';
1741: }
1.35 sakharuk 1742: #-- Frames
1.31 albertel 1743: sub start_frameset {
1744: my ($target,$token) = @_;
1745: my $currentstring = '';
1746: if ($target eq 'web') {
1747: if (!$Apache::lonxml::registered) {
1.47 matthew 1748: $currentstring.='<head>'.
1749: &Apache::lonxml::registerurl(undef,$target).'</head>';
1.31 albertel 1750: }
1751: $currentstring .= $token->[4];
1752: }
1753: return $currentstring;
1754: }
1755: sub end_frameset {
1756: my ($target,$token) = @_;
1757: my $currentstring = '';
1758: if ($target eq 'web') {
1759: $currentstring = $token->[2];
1760: }
1761: return $currentstring;
1.41 sakharuk 1762: }
1763: #-- <pre>
1764: sub start_pre {
1765: my ($target,$token) = @_;
1766: my $currentstring = '';
1767: if ($target eq 'web') {
1768: $currentstring .= $token->[4];
1769: } elsif ($target eq 'tex') {
1770: $currentstring .= '\begin{verbatim}';
1771: }
1772: return $currentstring;
1773: }
1774: sub end_pre {
1775: my ($target,$token) = @_;
1776: my $currentstring = '';
1777: if ($target eq 'web') {
1778: $currentstring .= $token->[2];
1779: } elsif ($target eq 'tex') {
1780: $currentstring .= '\end{verbatim}';
1.44 sakharuk 1781: }
1782: return $currentstring;
1783: }
1784: #-- <insert>
1785: sub start_insert {
1.46 sakharuk 1786: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1.44 sakharuk 1787: my $currentstring = '';
1788: if ($target eq 'web') {
1.46 sakharuk 1789: my $display = &Apache::lonxml::get_param('display',$parstack,$safeeval);
1790: $currentstring .= '<b>'.$display.'</b>';;
1.44 sakharuk 1791: }
1792: return $currentstring;
1793: }
1794: sub end_insert {
1.48 sakharuk 1795: my ($target,$token) = @_;
1796: my $currentstring = '';
1797: if ($target eq 'web') {
1798: $currentstring .= '';
1799: }
1800: return $currentstring;
1801: }
1802: #-- <externallink>
1803: sub start_externallink {
1804: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1805: my $currentstring = '';
1806: if ($target eq 'web') {
1807: my $display = &Apache::lonxml::get_param('display',$parstack,$safeeval);
1808: $currentstring .= '<b>'.$display.'</b>';;
1809: }
1810: return $currentstring;
1811: }
1812: sub end_externallink {
1.44 sakharuk 1813: my ($target,$token) = @_;
1814: my $currentstring = '';
1815: if ($target eq 'web') {
1816: $currentstring .= '';
1.65 sakharuk 1817: }
1818: return $currentstring;
1819: }
1820: #-- <blankspace heigth="">
1821: sub start_blankspace {
1822: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1823: my $currentstring = '';
1824: if ($target eq 'tex') {
1825: my $howmuch = &Apache::lonxml::get_param('heigth',$parstack,$safeeval);
1826: $currentstring .= '\vskip '.$howmuch.' ';
1827: }
1828: return $currentstring;
1829: }
1830: sub end_blankspace {
1831: my ($target,$token) = @_;
1832: my $currentstring = '';
1833: if ($target eq 'tex') {
1834: $currentstring .= '';
1835: }
1836: return $currentstring;
1837: }
1.88 sakharuk 1838: #-- <abbr> tag
1839: sub start_abbr {
1840: my ($target,$token) = @_;
1841: my $currentstring = '';
1842: if ($target eq 'web') {
1843: $currentstring = $token->[4];
1844: }
1845: return $currentstring;
1846: }
1847: sub end_abbr {
1848: my ($target,$token) = @_;
1849: my $currentstring = '';
1850: if ($target eq 'web') {
1851: $currentstring = $token->[2];
1852: }
1853: return $currentstring;
1854: }
1855: #-- <acronym> tag
1856: sub start_acronym {
1857: my ($target,$token) = @_;
1858: my $currentstring = '';
1859: if ($target eq 'web') {
1860: $currentstring = $token->[4];
1861: }
1862: return $currentstring;
1863: }
1864: sub end_acronym {
1865: my ($target,$token) = @_;
1866: my $currentstring = '';
1867: if ($target eq 'web') {
1868: $currentstring = $token->[2];
1869: }
1870: return $currentstring;
1871: }
1872: #-- <area> tag
1873: sub start_area {
1874: my ($target,$token) = @_;
1875: my $currentstring = '';
1876: if ($target eq 'web') {
1877: $currentstring = $token->[4];
1878: }
1879: return $currentstring;
1880: }
1881: sub end_area {
1882: my ($target,$token) = @_;
1883: my $currentstring = '';
1884: if ($target eq 'web') {
1885: $currentstring = $token->[2];
1886: }
1887: return $currentstring;
1888: }
1889: #-- <base> tag
1890: sub start_base {
1891: my ($target,$token) = @_;
1892: my $currentstring = '';
1893: if ($target eq 'web') {
1894: $currentstring = $token->[4];
1895: }
1896: return $currentstring;
1897: }
1898: sub end_base {
1899: my ($target,$token) = @_;
1900: my $currentstring = '';
1901: if ($target eq 'web') {
1902: $currentstring = $token->[2];
1903: }
1904: return $currentstring;
1905: }
1906: #-- <bdo> tag
1907: sub start_bdo {
1908: my ($target,$token) = @_;
1909: my $currentstring = '';
1910: if ($target eq 'web') {
1911: $currentstring = $token->[4];
1912: }
1913: return $currentstring;
1914: }
1915: sub end_bdo {
1916: my ($target,$token) = @_;
1917: my $currentstring = '';
1918: if ($target eq 'web') {
1919: $currentstring = $token->[2];
1920: }
1921: return $currentstring;
1922: }
1923: #-- <bgsound> tag
1924: sub start_bgsound {
1925: my ($target,$token) = @_;
1926: my $currentstring = '';
1927: if ($target eq 'web') {
1928: $currentstring = $token->[4];
1929: }
1930: return $currentstring;
1931: }
1932: sub end_bgsound {
1933: my ($target,$token) = @_;
1934: my $currentstring = '';
1935: if ($target eq 'web') {
1936: $currentstring = $token->[2];
1937: }
1938: return $currentstring;
1939: }
1940: #-- <blink> tag
1941: sub start_blink {
1942: my ($target,$token) = @_;
1943: my $currentstring = '';
1944: if ($target eq 'web') {
1945: $currentstring = $token->[4];
1946: }
1947: return $currentstring;
1948: }
1949: sub end_blink {
1950: my ($target,$token) = @_;
1951: my $currentstring = '';
1952: if ($target eq 'web') {
1953: $currentstring = $token->[2];
1954: }
1955: return $currentstring;
1956: }
1957: #-- <blockquote> tag
1958: sub start_blockquote {
1959: my ($target,$token) = @_;
1960: my $currentstring = '';
1961: if ($target eq 'web') {
1962: $currentstring = $token->[4];
1963: }
1964: return $currentstring;
1965: }
1966: sub end_blockquote {
1967: my ($target,$token) = @_;
1968: my $currentstring = '';
1969: if ($target eq 'web') {
1970: $currentstring = $token->[2];
1971: }
1972: return $currentstring;
1973: }
1974: #-- <button> tag
1975: sub start_button {
1976: my ($target,$token) = @_;
1977: my $currentstring = '';
1978: if ($target eq 'web') {
1979: $currentstring = $token->[4];
1980: }
1981: return $currentstring;
1982: }
1983: sub end_button {
1984: my ($target,$token) = @_;
1985: my $currentstring = '';
1986: if ($target eq 'web') {
1987: $currentstring = $token->[2];
1988: }
1989: return $currentstring;
1990: }
1991: #-- <caption> tag
1992: sub start_caption {
1993: my ($target,$token) = @_;
1994: my $currentstring = '';
1995: if ($target eq 'web') {
1996: $currentstring = $token->[4];
1997: }
1998: return $currentstring;
1999: }
2000: sub end_caption {
2001: my ($target,$token) = @_;
2002: my $currentstring = '';
2003: if ($target eq 'web') {
2004: $currentstring = $token->[2];
2005: }
2006: return $currentstring;
2007: }
2008: #-- <col> tag
2009: sub start_col {
2010: my ($target,$token) = @_;
2011: my $currentstring = '';
2012: if ($target eq 'web') {
2013: $currentstring = $token->[4];
2014: }
2015: return $currentstring;
2016: }
2017: sub end_col {
2018: my ($target,$token) = @_;
2019: my $currentstring = '';
2020: if ($target eq 'web') {
2021: $currentstring = $token->[2];
2022: }
2023: return $currentstring;
2024: }
2025: #-- <colgroup> tag
2026: sub start_colgroup {
2027: my ($target,$token) = @_;
2028: my $currentstring = '';
2029: if ($target eq 'web') {
2030: $currentstring = $token->[4];
2031: }
2032: return $currentstring;
2033: }
2034: sub end_colgroup {
2035: my ($target,$token) = @_;
2036: my $currentstring = '';
2037: if ($target eq 'web') {
2038: $currentstring = $token->[2];
2039: }
2040: return $currentstring;
2041: }
2042: #-- <del> tag
2043: sub start_del {
2044: my ($target,$token) = @_;
2045: my $currentstring = '';
2046: if ($target eq 'web') {
2047: $currentstring = $token->[4];
2048: }
2049: return $currentstring;
2050: }
2051: sub end_del {
2052: my ($target,$token) = @_;
2053: my $currentstring = '';
2054: if ($target eq 'web') {
2055: $currentstring = $token->[2];
2056: }
2057: return $currentstring;
2058: }
2059: #-- <fieldset> tag
2060: sub start_fieldset {
2061: my ($target,$token) = @_;
2062: my $currentstring = '';
2063: if ($target eq 'web') {
2064: $currentstring = $token->[4];
2065: }
2066: return $currentstring;
2067: }
2068: sub end_fieldset {
2069: my ($target,$token) = @_;
2070: my $currentstring = '';
2071: if ($target eq 'web') {
2072: $currentstring = $token->[2];
2073: }
2074: return $currentstring;
2075: }
2076: #-- <frame> tag
2077: sub start_frame {
2078: my ($target,$token) = @_;
2079: my $currentstring = '';
2080: if ($target eq 'web') {
2081: $currentstring = $token->[4];
2082: }
2083: return $currentstring;
2084: }
2085: sub end_frame {
2086: my ($target,$token) = @_;
2087: my $currentstring = '';
2088: if ($target eq 'web') {
2089: $currentstring = $token->[2];
2090: }
2091: return $currentstring;
2092: }
2093: #-- <iframe> tag
2094: sub start_iframe {
2095: my ($target,$token) = @_;
2096: my $currentstring = '';
2097: if ($target eq 'web') {
2098: $currentstring = $token->[4];
2099: }
2100: return $currentstring;
2101: }
2102: sub end_iframe {
2103: my ($target,$token) = @_;
2104: my $currentstring = '';
2105: if ($target eq 'web') {
2106: $currentstring = $token->[2];
2107: }
2108: return $currentstring;
2109: }
2110: #-- <ins> tag
2111: sub start_ins {
2112: my ($target,$token) = @_;
2113: my $currentstring = '';
2114: if ($target eq 'web') {
2115: $currentstring = $token->[4];
2116: }
2117: return $currentstring;
2118: }
2119: sub end_ins {
2120: my ($target,$token) = @_;
2121: my $currentstring = '';
2122: if ($target eq 'web') {
2123: $currentstring = $token->[2];
2124: }
2125: return $currentstring;
2126: }
2127: #-- <isindex> tag
2128: sub start_isindex {
2129: my ($target,$token) = @_;
2130: my $currentstring = '';
2131: if ($target eq 'web') {
2132: $currentstring = $token->[4];
2133: }
2134: return $currentstring;
2135: }
2136: sub end_isindex {
2137: my ($target,$token) = @_;
2138: my $currentstring = '';
2139: if ($target eq 'web') {
2140: $currentstring = $token->[2];
2141: }
2142: return $currentstring;
2143: }
2144: #-- <keygen> tag
2145: sub start_keygen {
2146: my ($target,$token) = @_;
2147: my $currentstring = '';
2148: if ($target eq 'web') {
2149: $currentstring = $token->[4];
2150: }
2151: return $currentstring;
2152: }
2153: sub end_keygen {
2154: my ($target,$token) = @_;
2155: my $currentstring = '';
2156: if ($target eq 'web') {
2157: $currentstring = $token->[2];
2158: }
2159: return $currentstring;
2160: }
2161: #-- <label> tag
2162: sub start_label {
2163: my ($target,$token) = @_;
2164: my $currentstring = '';
2165: if ($target eq 'web') {
2166: $currentstring = $token->[4];
2167: }
2168: return $currentstring;
2169: }
2170: sub end_label {
2171: my ($target,$token) = @_;
2172: my $currentstring = '';
2173: if ($target eq 'web') {
2174: $currentstring = $token->[2];
2175: }
2176: return $currentstring;
2177: }
2178: #-- <layer> tag
2179: sub start_layer {
2180: my ($target,$token) = @_;
2181: my $currentstring = '';
2182: if ($target eq 'web') {
2183: $currentstring = $token->[4];
2184: }
2185: return $currentstring;
2186: }
2187: sub end_layer {
2188: my ($target,$token) = @_;
2189: my $currentstring = '';
2190: if ($target eq 'web') {
2191: $currentstring = $token->[2];
2192: }
2193: return $currentstring;
2194: }
2195: #-- <legend> tag
2196: sub start_legend {
2197: my ($target,$token) = @_;
2198: my $currentstring = '';
2199: if ($target eq 'web') {
2200: $currentstring = $token->[4];
2201: }
2202: return $currentstring;
2203: }
2204: sub end_legend {
2205: my ($target,$token) = @_;
2206: my $currentstring = '';
2207: if ($target eq 'web') {
2208: $currentstring = $token->[2];
2209: }
2210: return $currentstring;
2211: }
2212: #-- <link> tag
2213: sub start_link {
2214: my ($target,$token) = @_;
2215: my $currentstring = '';
2216: if ($target eq 'web') {
2217: $currentstring = $token->[4];
2218: }
2219: return $currentstring;
2220: }
2221: sub end_link {
2222: my ($target,$token) = @_;
2223: my $currentstring = '';
2224: if ($target eq 'web') {
2225: $currentstring = $token->[2];
2226: }
2227: return $currentstring;
2228: }
2229: #-- <marquee> tag
2230: sub start_marquee {
2231: my ($target,$token) = @_;
2232: my $currentstring = '';
2233: if ($target eq 'web') {
2234: $currentstring = $token->[4];
2235: }
2236: return $currentstring;
2237: }
2238: sub end_marquee {
2239: my ($target,$token) = @_;
2240: my $currentstring = '';
2241: if ($target eq 'web') {
2242: $currentstring = $token->[2];
2243: }
2244: return $currentstring;
2245: }
2246: #-- <malticol> tag
2247: sub start_malticol {
2248: my ($target,$token) = @_;
2249: my $currentstring = '';
2250: if ($target eq 'web') {
2251: $currentstring = $token->[4];
2252: }
2253: return $currentstring;
2254: }
2255: sub end_malticol {
2256: my ($target,$token) = @_;
2257: my $currentstring = '';
2258: if ($target eq 'web') {
2259: $currentstring = $token->[2];
2260: }
2261: return $currentstring;
2262: }
2263: #-- <nobr> tag
2264: sub start_nobr {
2265: my ($target,$token) = @_;
2266: my $currentstring = '';
2267: if ($target eq 'web') {
2268: $currentstring = $token->[4];
2269: }
2270: return $currentstring;
2271: }
2272: sub end_nobr {
2273: my ($target,$token) = @_;
2274: my $currentstring = '';
2275: if ($target eq 'web') {
2276: $currentstring = $token->[2];
2277: }
2278: return $currentstring;
2279: }
2280: #-- <noembed> tag
2281: sub start_noembed {
2282: my ($target,$token) = @_;
2283: my $currentstring = '';
2284: if ($target eq 'web') {
2285: $currentstring = $token->[4];
2286: }
2287: return $currentstring;
2288: }
2289: sub end_noembed {
2290: my ($target,$token) = @_;
2291: my $currentstring = '';
2292: if ($target eq 'web') {
2293: $currentstring = $token->[2];
2294: }
2295: return $currentstring;
2296: }
2297: #-- <noframes> tag
2298: sub start_noframes {
2299: my ($target,$token) = @_;
2300: my $currentstring = '';
2301: if ($target eq 'web') {
2302: $currentstring = $token->[4];
2303: }
2304: return $currentstring;
2305: }
2306: sub end_noframes {
2307: my ($target,$token) = @_;
2308: my $currentstring = '';
2309: if ($target eq 'web') {
2310: $currentstring = $token->[2];
2311: }
2312: return $currentstring;
2313: }
2314: #-- <nolayer> tag
2315: sub start_nolayer {
2316: my ($target,$token) = @_;
2317: my $currentstring = '';
2318: if ($target eq 'web') {
2319: $currentstring = $token->[4];
2320: }
2321: return $currentstring;
2322: }
2323: sub end_nolayer {
2324: my ($target,$token) = @_;
2325: my $currentstring = '';
2326: if ($target eq 'web') {
2327: $currentstring = $token->[2];
2328: }
2329: return $currentstring;
2330: }
2331: #-- <noscript> tag
2332: sub start_noscript {
2333: my ($target,$token) = @_;
2334: my $currentstring = '';
2335: if ($target eq 'web') {
2336: $currentstring = $token->[4];
2337: }
2338: return $currentstring;
2339: }
2340: sub end_noscript {
2341: my ($target,$token) = @_;
2342: my $currentstring = '';
2343: if ($target eq 'web') {
2344: $currentstring = $token->[2];
2345: }
2346: return $currentstring;
2347: }
2348: #-- <object> tag
2349: sub start_object {
2350: my ($target,$token) = @_;
2351: my $currentstring = '';
2352: if ($target eq 'web') {
2353: $currentstring = $token->[4];
2354: }
2355: return $currentstring;
2356: }
2357: sub end_object {
2358: my ($target,$token) = @_;
2359: my $currentstring = '';
2360: if ($target eq 'web') {
2361: $currentstring = $token->[2];
2362: }
2363: return $currentstring;
2364: }
2365: #-- <optgroup> tag
2366: sub start_optgroup {
2367: my ($target,$token) = @_;
2368: my $currentstring = '';
2369: if ($target eq 'web') {
2370: $currentstring = $token->[4];
2371: }
2372: return $currentstring;
2373: }
2374: sub end_optgroup {
2375: my ($target,$token) = @_;
2376: my $currentstring = '';
2377: if ($target eq 'web') {
2378: $currentstring = $token->[2];
2379: }
2380: return $currentstring;
2381: }
2382: #-- <samp> tag
2383: sub start_samp {
2384: my ($target,$token) = @_;
2385: my $currentstring = '';
2386: if ($target eq 'web') {
2387: $currentstring = $token->[4];
2388: }
2389: return $currentstring;
2390: }
2391: sub end_samp {
2392: my ($target,$token) = @_;
2393: my $currentstring = '';
2394: if ($target eq 'web') {
2395: $currentstring = $token->[2];
2396: }
2397: return $currentstring;
2398: }
2399: #-- <server> tag
2400: sub start_server {
2401: my ($target,$token) = @_;
2402: my $currentstring = '';
2403: if ($target eq 'web') {
2404: $currentstring = $token->[4];
2405: }
2406: return $currentstring;
2407: }
2408: sub end_server {
2409: my ($target,$token) = @_;
2410: my $currentstring = '';
2411: if ($target eq 'web') {
2412: $currentstring = $token->[2];
2413: }
2414: return $currentstring;
2415: }
2416: #-- <spacer> tag
2417: sub start_spacer {
2418: my ($target,$token) = @_;
2419: my $currentstring = '';
2420: if ($target eq 'web') {
2421: $currentstring = $token->[4];
2422: }
2423: return $currentstring;
2424: }
2425: sub end_spacer {
2426: my ($target,$token) = @_;
2427: my $currentstring = '';
2428: if ($target eq 'web') {
2429: $currentstring = $token->[2];
2430: }
2431: return $currentstring;
2432: }
2433: #-- <span> tag
2434: sub start_span {
2435: my ($target,$token) = @_;
2436: my $currentstring = '';
2437: if ($target eq 'web') {
2438: $currentstring = $token->[4];
2439: }
2440: return $currentstring;
2441: }
2442: sub end_span {
2443: my ($target,$token) = @_;
2444: my $currentstring = '';
2445: if ($target eq 'web') {
2446: $currentstring = $token->[2];
2447: }
2448: return $currentstring;
2449: }
2450: #-- <tbody> tag
2451: sub start_tbody {
2452: my ($target,$token) = @_;
2453: my $currentstring = '';
2454: if ($target eq 'web') {
2455: $currentstring = $token->[4];
2456: }
2457: return $currentstring;
2458: }
2459: sub end_tbody {
2460: my ($target,$token) = @_;
2461: my $currentstring = '';
2462: if ($target eq 'web') {
2463: $currentstring = $token->[2];
2464: }
2465: return $currentstring;
2466: }
2467: #-- <tfoot> tag
2468: sub start_tfoot {
2469: my ($target,$token) = @_;
2470: my $currentstring = '';
2471: if ($target eq 'web') {
2472: $currentstring = $token->[4];
2473: }
2474: return $currentstring;
2475: }
2476: sub end_tfoot {
2477: my ($target,$token) = @_;
2478: my $currentstring = '';
2479: if ($target eq 'web') {
2480: $currentstring = $token->[2];
2481: }
2482: return $currentstring;
2483: }
2484: #-- <thead> tag
2485: sub start_thead {
2486: my ($target,$token) = @_;
2487: my $currentstring = '';
2488: if ($target eq 'web') {
2489: $currentstring = $token->[4];
2490: }
2491: return $currentstring;
2492: }
2493: sub end_thead {
2494: my ($target,$token) = @_;
2495: my $currentstring = '';
2496: if ($target eq 'web') {
2497: $currentstring = $token->[2];
2498: }
2499: return $currentstring;
2500: }
2501: #-- <var> tag
2502: sub start_var {
2503: my ($target,$token) = @_;
2504: my $currentstring = '';
2505: if ($target eq 'web') {
2506: $currentstring = $token->[4];
2507: }
2508: return $currentstring;
2509: }
2510: sub end_var {
2511: my ($target,$token) = @_;
2512: my $currentstring = '';
2513: if ($target eq 'web') {
2514: $currentstring = $token->[2];
2515: }
2516: return $currentstring;
2517: }
2518: #-- <wbr> tag
2519: sub start_wbr {
2520: my ($target,$token) = @_;
2521: my $currentstring = '';
2522: if ($target eq 'web') {
2523: $currentstring = $token->[4];
2524: }
2525: return $currentstring;
2526: }
2527: sub end_wbr {
2528: my ($target,$token) = @_;
2529: my $currentstring = '';
2530: if ($target eq 'web') {
2531: $currentstring = $token->[2];
2532: }
2533: return $currentstring;
2534: }
1.94 sakharuk 2535:
2536: sub image_replication {
2537: my $src = shift;
2538: if (not -e '/home/httpd/html'.$src) {
2539: #replicates image itself
2540: &Apache::lonnet::repcopy('/home/httpd/html'.$src);
2541: #replicates eps or ps
2542: my $newsrc = $src;
2543: $newsrc =~ s/(.gif|.jpg)$/.eps/;
2544: if (not-e $newsrc && &Apache::lonnet::repcopy('/home/httpd/html'.$newsrc) ne 'OK') {
2545: $newsrc =~ s/\.ps$/\.eps/;
2546: &Apache::lonnet::repcopy('/home/httpd/html'.$newsrc);
2547: }
2548: }
2549: return '';
2550: }
2551:
1.1 sakharuk 2552: 1;
2553: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>