Annotation of loncom/xml/londefdef.pm, revision 1.125
1.1 sakharuk 1: # The LearningOnline Network with CAPA
2: # Tags Default Definition Module
3: #
1.125 ! sakharuk 4: # $Id: londefdef.pm,v 1.124 2003/04/10 14:31:09 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.118 www 47: use Apache::lonnet();
1.1 sakharuk 48: use strict;
1.124 sakharuk 49: use Apache::lonxml;
1.57 sakharuk 50: use Apache::File();
1.70 sakharuk 51: use Image::Magick;
1.118 www 52: use Apache::lonmenu();
53: use Apache::lonmeta();
1.54 sakharuk 54:
1.38 harris41 55: BEGIN {
1.15 sakharuk 56:
1.121 www 57: &Apache::lonxml::register('Apache::londefdef',('a','abbr','acronym','accessrule','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','tthoption','u','ul','var','wbr'));
1.15 sakharuk 58:
1.3 sakharuk 59: }
1.1 sakharuk 60:
1.35 sakharuk 61: #======================= TAG SUBROUTINES =====================
1.8 sakharuk 62: #-- <output>
1.21 albertel 63: sub start_output {
1.122 albertel 64: my ($target) = @_;
65: if ($target eq 'meta') { $Apache::lonxml::metamode--; }
66: return '';
1.21 albertel 67: }
68: sub end_output {
1.122 albertel 69: my ($target) = @_;
70: if ($target eq 'meta') { $Apache::lonxml::metamode++; }
71: return '';
1.21 albertel 72: }
1.4 sakharuk 73: #-- <m> tag
1.33 albertel 74: sub start_m {
1.122 albertel 75: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
76: my $currentstring = '';
77: if ($target eq 'web') {
78: $Apache::lonxml::prevent_entity_encode++;
79: my $inside = &Apache::lonxml::get_all_text_unbalanced("/m",$parser);
80: $inside ='\\documentstyle{article}'.$inside;
81: &Apache::lonxml::debug("M is starting with:$inside:");
82: my $eval=&Apache::lonxml::get_param('eval',$parstack,$safeeval);
83: if ($eval eq 'on') {
84: $inside=&Apache::run::evaluate($inside,$safeeval,$$parstack[-1]);
85: #&Apache::lonxml::debug("M is evaulated to:$inside:");
86: }
87: $currentstring = &Apache::lontexconvert::converted(\$inside);
88: if ($Apache::lontexconvert::errorstring) {
89: &Apache::lonxml::warning("tth error: ".
90: $Apache::lontexconvert::errorstring);
91: $Apache::lontexconvert::errorstring='';
92: }
93: #&Apache::lonxml::debug("M is ends with:$currentstring:");
94: } elsif ($target eq 'tex') {
95: $currentstring = &Apache::lonxml::get_all_text_unbalanced("/m",$parser);
96: if ($currentstring=~/^(\s*\\\\\s*)*$/) {$currentstring = ' \vskip 0 mm ';}
97: } else {
98: my $inside = &Apache::lonxml::get_all_text_unbalanced("/m",$parser);
99: }
100: return $currentstring;
1.33 albertel 101: }
1.122 albertel 102:
1.33 albertel 103: sub end_m {
1.122 albertel 104: my ($target,$token) = @_;
105: my $currentstring = '';
106: if ($target eq 'web') {
107: $Apache::lonxml::prevent_entity_encode--;
108: } elsif ($target eq 'tex') {
109: $currentstring = "";
110: } elsif ($target eq 'meta') {
111: }
112: return $currentstring;
1.33 albertel 113: }
1.110 albertel 114:
115: sub start_tthoption {
1.122 albertel 116: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
117: my $result;
118: if ($target eq 'web') {
119: my $inside = &Apache::lonxml::get_all_text("/tthoption",$parser);
120: $inside=~s/^\s*//;
121: if ($ENV{'browser.mathml'}) {
122: &tth::ttmoptions($inside);
123: } else {
124: &tth::tthoptions($inside);
125: }
126: }
127: return $result;
1.110 albertel 128: }
129:
130: sub end_tthoption {
1.122 albertel 131: my ($target,$token) = @_;
132: my $result;
133: return $result;
1.110 albertel 134: }
135:
1.35 sakharuk 136: #-- <html> tag
1.100 albertel 137: sub start_html {
138: my ($target,$token) = @_;
139: my $currentstring = '';
140: if ($ENV{'browser.mathml'}) {
141: &tth::ttminit();
142: if ($ENV{'browser.unicode'}) {
143: &tth::ttmoptions('-L -u1');
144: } else {
145: &tth::ttmoptions('-L -u0');
146: }
147: } else {
148: &tth::tthinit();
149: if ($ENV{'browser.unicode'}) {
150: &tth::tthoptions('-L -u1');
151: } else {
152: &tth::tthoptions('-L -u0');
153: }
154: }
155: if ($target eq 'web') {
156: $currentstring = &Apache::lonxml::xmlbegin().
157: &Apache::lonxml::fontsettings();
158: } elsif ($target eq 'tex') {
159: @Apache::londefdef::table = ();
160: $currentstring .= '\documentclass[letterpaper]{article}
1.114 sakharuk 161: \newcommand{\keephidden}[1]{}
162: \renewcommand{\deg}{$^{\circ}$}
163: \usepackage{textcomp}
164: \usepackage[dvips]{graphicx}
165: \usepackage{epsfig}\usepackage{calc}
166: \newenvironment{choicelist}{\begin{list}{}{\setlength{\rightmargin}{0in}\setlength{\leftmargin}{0.13in}\setlength{\topsep}{0.05in}\setlength{\itemsep}{0.022in}\setlength{\parsep}{0in}\setlength{\belowdisplayskip}{0.04in}\setlength{\abovedisplayskip}{0.05in}\setlength{\abovedisplayshortskip}{-0.04in}\setlength{\belowdisplayshortskip}{0.04in}}}{\end{list}}';
1.100 albertel 167: }
168: return $currentstring;
169: }
1.122 albertel 170:
171: sub end_html {
172: my ($target,$token) = @_;
173: my $currentstring = '';
174: if ($target eq 'web') {
175: $currentstring = &Apache::lonxml::xmlend();
176: }
177: return $currentstring;
178: }
179:
1.35 sakharuk 180: #-- <head> tag
1.122 albertel 181: sub start_head {
182: my ($target,$token) = @_;
183: my $currentstring = '';
184: if ($target eq 'web') {
185: $currentstring = $token->[4];
186: }
187: return $currentstring;
188: }
189:
190: sub end_head {
191: my ($target,$token) = @_;
192: my $currentstring = '';
193: if ($target eq 'web') {
194: $currentstring = &Apache::lonmenu::registerurl(undef,$target).
195: $token->[2];
196: }
197: return $currentstring;
198: }
199:
1.35 sakharuk 200: #-- <map> tag
1.122 albertel 201: sub start_map {
202: my ($target,$token) = @_;
203: my $currentstring = '';
204: if ($target eq 'web') {
205: $currentstring = $token->[4];
206: }
207: return $currentstring;
208: }
209:
210: sub end_map {
211: my ($target,$token) = @_;
212: my $currentstring = '';
213: if ($target eq 'web') {
214: $currentstring = $token->[2];
215: }
216: return $currentstring;
217: }
218:
1.35 sakharuk 219: #-- <select> tag
1.122 albertel 220: sub start_select {
221: my ($target,$token) = @_;
222: my $currentstring = '';
223: if ($target eq 'web') {
224: $currentstring = $token->[4];
225: }
226: return $currentstring;
227: }
228:
229: sub end_select {
230: my ($target,$token) = @_;
231: my $currentstring = '';
232: if ($target eq 'web') {
233: $currentstring = $token->[2];
234: }
235: return $currentstring;
236: }
237:
1.35 sakharuk 238: #-- <option> tag
1.122 albertel 239: sub start_option {
240: my ($target,$token) = @_;
241: my $currentstring = '';
242: if ($target eq 'web') {
243: $currentstring = $token->[4];
244: }
245: return $currentstring;
246: }
247:
248: sub end_option {
249: my ($target,$token) = @_;
250: my $currentstring = '';
251: if ($target eq 'web') {
252: $currentstring = $token->[2];
253: }
254: return $currentstring;
255: }
256:
1.35 sakharuk 257: #-- <input> tag
1.122 albertel 258: sub start_input {
259: my ($target,$token) = @_;
260: my $currentstring = '';
261: if ($target eq 'web') {
262: $currentstring = $token->[4];
263: }
264: return $currentstring;
265: }
266:
267: sub end_input {
268: my ($target,$token) = @_;
269: my $currentstring = '';
270: if ($target eq 'web') {
271: $currentstring = $token->[2];
272: }
273: return $currentstring;
274: }
275:
1.35 sakharuk 276: #-- <textarea> tag
1.122 albertel 277: sub start_textarea {
278: my ($target,$token) = @_;
279: my $currentstring = '';
280: if ($target eq 'web') {
281: $currentstring = $token->[4];
282: }
283: return $currentstring;
284: }
285:
286: sub end_textarea {
287: my ($target,$token) = @_;
288: my $currentstring = '';
289: if ($target eq 'web') {
290: $currentstring = $token->[2];
291: }
292: return $currentstring;
293: }
294:
1.35 sakharuk 295: #-- <form> tag
1.122 albertel 296: sub start_form {
297: my ($target,$token) = @_;
298: my $currentstring = '';
299: if ($target eq 'web') {
300: $currentstring = $token->[4];
301: }
302: return $currentstring;
303: }
304:
305: sub end_form {
306: my ($target,$token) = @_;
307: my $currentstring = '';
308: if ($target eq 'web') {
309: $currentstring = $token->[2];
310: }
311: return $currentstring;
312: }
313:
1.35 sakharuk 314: #-- <title> tag
1.122 albertel 315: sub start_title {
316: my ($target,$token) = @_;
317: my $currentstring = '';
318: if ($target eq 'web') {
319: $currentstring = $token->[4];
320: } elsif ($target eq 'tex') {
321: $currentstring .= '\keephidden{'
322: }
323: if ($target eq 'meta') {
324: $currentstring='<title>';
325: &start_output();
326: }
327: return $currentstring;
328: }
329:
330: sub end_title {
331: my ($target,$token) = @_;
332: my $currentstring = '';
333: if ($target eq 'web') {
334: $currentstring = $token->[2];
335: } elsif ($target eq 'tex') {
336: $currentstring .= '}';
337: }
338: if ($target eq 'meta') {
339: &end_output();
340: $currentstring='</title>';
341: }
342: return $currentstring;
343: }
344:
345: #-- <meta> tag
346: sub start_meta {
347: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
348: my $currentstring = '';
349: if ($target eq 'web') {
350: my $args='';
351: if ( $#$parstack > -1 ) { $args=$$parstack[$#$parstack]; }
352: if ($args eq '') {
353: &Apache::lonxml::get_all_text("/meta",$parser);
354: } else {
355: $currentstring = $token->[4];
1.1 sakharuk 356: }
1.122 albertel 357: }
358: if ($target eq 'meta') {
359: unless (&Apache::lonxml::get_param
360: ('http-equiv',$parstack,$safeeval,undef,1)) {
361: my $name=$token->[2]->{'name'};
362: $name=~tr/A-Z/a-z/;
363: $name=~s/\s/\_/gs;
364: $name=~s/\W//gs;
365: if ($name) {
366: $currentstring='<'.$name.'>'.
367: &Apache::lonxml::get_param
368: ('content',$parstack,$safeeval,undef,1).
369: '</'.$name.'>';
1.1 sakharuk 370: }
371: }
1.122 albertel 372: }
373: return $currentstring;
374: }
375:
376: sub end_meta {
377: my ($target,$token,$tagstack,$parstack,$parser) = @_;
378: my $currentstring = '';
379: if ($target eq 'web') {
380: my $args='';
381: if ( $#$parstack > -1 ) { $args=$$parstack[$#$parstack]; }
382: if ($args ne '') {
1.121 www 383: $currentstring = $token->[4];
1.122 albertel 384: }
385: }
386: return $currentstring;
387: }
388:
1.121 www 389: # accessrule
1.122 albertel 390: sub start_accessrule {
391: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
392: my $currentstring = '';
393: my $eff=&Apache::lonxml::get_param
394: ('effect',$parstack,$safeeval,undef,1);
395: my $realm=&Apache::lonxml::get_param
396: ('realm',$parstack,$safeeval,undef,1);
1.123 www 397: my $role=&Apache::lonxml::get_param
398: ('role',$parstack,$safeeval,undef,1);
399: $realm=~s/\s+//g;
400: $realm=~s/\//\_/g;
401: $realm=~s/^\_//;
402: $realm=~s/\W/\;/g;
403: $role=~s/\s+//g;
404: $role=~s/\//\_/g;
405: $role=~s/\W/\;/g;
1.122 albertel 406: if ($target eq 'web') {
407: my $args='';
408: if ( $#$parstack > -1 ) { $args=$$parstack[$#$parstack]; }
409: if ($args eq '') {
410: &Apache::lonxml::get_all_text("/accessrule",$parser);
411: } else {
412: $currentstring = $token->[4];
413: }
414: }
415: if ($target eq 'meta') {
1.123 www 416: $currentstring='<rule>'.$eff.':'.$realm.':'.$role.'</rule>';
1.122 albertel 417: }
418: return $currentstring;
419: }
420:
421: sub end_accessrule {
422: my ($target,$token,$tagstack,$parstack,$parser) = @_;
423: my $currentstring = '';
424: if ($target eq 'web') {
425: my $args='';
426: if ( $#$parstack > -1 ) { $args=$$parstack[$#$parstack]; }
427: if ($args ne '') {
428: $currentstring = $token->[4];
429: }
430: }
431: return $currentstring;
432: }
433:
434: #-- <body> tag
435: sub start_body {
436: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
437: my $currentstring = '';
438: if ($target eq 'web') {
439: if (!$Apache::lonxml::registered) {
440: $currentstring.='<head>'.
441: &Apache::lonmenu::registerurl(undef,$target).'</head>';
442: }
443: my $onLoad='';
444: foreach my $key (keys(%{$token->[2]})) {
445: if ($key =~ /^onload$/i) {
446: $onLoad.=$token->[2]->{$key}.';';
447: delete($token->[2]->{$key});
1.121 www 448: }
1.122 albertel 449: }
450: $token->[2]->{'onload'}=&Apache::lonmenu::loadevents().';'.$onLoad;
451: my $onUnload='';
452: foreach my $key (keys(%{$token->[2]})) {
453: if ($key =~ /^onunload$/i) {
454: $onUnload.=$token->[2]->{$key}.';';
455: delete($token->[2]->{$key});
1.121 www 456: }
457: }
1.122 albertel 458: $token->[2]->{'onunload'}=&Apache::lonmenu::unloadevents().
459: ';'.$onUnload;
460:
461: $currentstring .= '<'.$token->[1];
462: foreach (keys %{$token->[2]}) {
463: $currentstring.=' '.$_.'="'.$token->[2]->{$_}.'"';
464: }
465: $currentstring.='>';
466: if ($ENV{'request.state'} ne 'published') {
467: $currentstring.=(<<EDITBUTTON);
1.40 albertel 468: <form method="post">
1.49 albertel 469: <input type="submit" name="editmode" value="Edit" />
1.40 albertel 470: </form>
471: EDITBUTTON
1.122 albertel 472: } else {
473: $currentstring.=&Apache::lonmenu::menubuttons(undef,$target,1);
1.1 sakharuk 474: }
1.122 albertel 475: } elsif ($target eq 'tex') {
476: $currentstring = '\begin{document}';
477: }
478: return $currentstring;
479: }
480:
481: sub end_body {
482: my ($target,$token) = @_;
483: my $currentstring = '';
484: if ($target eq 'web') {
485: $currentstring = $token->[2];
486: } elsif ($target eq 'tex') {
487: $currentstring = '\end{document}';
488: }
489: return $currentstring;
490: }
491:
1.35 sakharuk 492: #-- <center> tag
1.122 albertel 493: sub start_center {
494: my ($target,$token) = @_;
495: my $currentstring = '';
496: if ($target eq 'web') {
497: $currentstring = $token->[4];
498: } elsif ($target eq 'tex') {
499: $currentstring = '\begin{center}';
500: } elsif ($target eq 'latexsource') {
501: $currentstring = '\begin{center}';
502: }
503: return $currentstring;
504: }
505:
506: sub end_center {
507: my ($target,$token) = @_;
508: my $currentstring = '';
509: if ($target eq 'web') {
510: $currentstring = $token->[2];
511: } elsif ($target eq 'tex') {
512: $currentstring = '\end{center}';
513: } elsif ($target eq 'latexsource') {
514: $currentstring = '\end{center}';
515: }
516: return $currentstring;
517: }
518:
1.35 sakharuk 519: #-- <b> tag
1.122 albertel 520: sub start_b {
521: my ($target,$token) = @_;
522: my $currentstring = '';
523: if ($target eq 'web') {
524: $currentstring = $token->[4];
525: } elsif ($target eq 'tex') {
526: $currentstring = '\textbf{';
527: } elsif ($target eq 'latexsource') {
528: $currentstring = '\textbf{';
529: }
530: return $currentstring;
531: }
532:
533: sub end_b {
534: my ($target,$token) = @_;
535: my $currentstring = '';
536: if ($target eq 'web') {
537: $currentstring = $token->[2];
538: } elsif ($target eq 'tex') {
539: $currentstring = '}';
540: } elsif ($target eq 'latexsource') {
541: $currentstring = '}';
542: }
543: return $currentstring;
544: }
1.35 sakharuk 545:
546: #-- <strong> tag
1.122 albertel 547: sub start_strong {
548: my ($target,$token) = @_;
549: my $currentstring = '';
550: if ($target eq 'web') {
551: $currentstring = $token->[4];
552: } elsif ($target eq 'tex') {
553: $currentstring = '\textbf{';
554: } elsif ($target eq 'latexsource') {
555: $currentstring = '\textbf{';
556: }
557: return $currentstring;
558: }
559:
560: sub end_strong {
561: my ($target,$token) = @_;
562: my $currentstring = '';
563: if ($target eq 'web') {
564:
565: $currentstring = $token->[2];
566: } elsif ($target eq 'tex') {
567: $currentstring = '}';
568: } elsif ($target eq 'latexsource') {
569: $currentstring = '}';
570: }
571: return $currentstring;
572: }
573:
1.35 sakharuk 574: #-- <h1> tag
1.122 albertel 575: sub start_h1 {
1.125 ! sakharuk 576: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1.122 albertel 577: my $currentstring = '';
578: if ($target eq 'web') {
579: $currentstring .= $token->[4];
580: } elsif ($target eq 'tex') {
1.125 ! sakharuk 581: my $pre;
! 582: my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1);
! 583: if (($align eq 'center') || (not defined $align)) {
! 584: $pre='\begin{center}';
! 585: } elsif ($align eq 'left') {
! 586: $pre='\rlap{';
! 587: } elsif ($align eq 'right') {
! 588: $pre=' \hfill \llap{';
! 589: }
! 590: my $TeXsize=&Apache::lonxml::get_param('TeXsize',$parstack,$safeeval,undef,0);
! 591: if (not defined $TeXsize) {$TeXsize="large";}
! 592: $currentstring .= $pre.'{\\'.$TeXsize.' \textbf{';
1.122 albertel 593: } elsif ($target eq 'meta') {
594: $currentstring='<subject>';
595: &start_output();
596: }
597: return $currentstring;
598: }
599:
600: sub end_h1 {
1.125 ! sakharuk 601: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1.122 albertel 602: my $currentstring = '';
603: if ($target eq 'web') {
604: $currentstring .= $token->[2];
605: } elsif ($target eq 'tex') {
1.125 ! sakharuk 606: my $post;
! 607: my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1);
! 608: if (($align eq 'center') || (not defined $align)) {
! 609: $post='\end{center}';
! 610: } elsif ($align eq 'left') {
! 611: $post='} \hfill'.'\vskip 0 mm ';
! 612: } elsif ($align eq 'right') {
! 613: $post='}'.'\vskip 0 mm ';
! 614: }
! 615: $currentstring .= '}}'.$post;
1.122 albertel 616: } elsif ($target eq 'meta') {
617: &end_output();
618: $currentstring='</subject>';
619: }
620: return $currentstring;
621: }
622:
1.35 sakharuk 623: #-- <h2> tag
1.122 albertel 624: sub start_h2 {
1.125 ! sakharuk 625: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1.122 albertel 626: my $currentstring = '';
627: if ($target eq 'web') {
628: $currentstring .= $token->[4];
629: } elsif ($target eq 'tex') {
1.125 ! sakharuk 630: my $pre;
! 631: my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1);
! 632: if (($align eq 'center') || (not defined $align)) {
! 633: $pre='\begin{center}';
! 634: } elsif ($align eq 'left') {
! 635: $pre='\rlap{';
! 636: } elsif ($align eq 'right') {
! 637: $pre=' \hfill \llap{';
! 638: }
! 639: my $TeXsize=&Apache::lonxml::get_param('TeXsize',$parstack,$safeeval,undef,0);
! 640: if (not defined $TeXsize) {$TeXsize="large";}
! 641: $currentstring .= $pre.'{\\'.$TeXsize.' \textbf{';
1.122 albertel 642: }
643: return $currentstring;
644: }
645:
646: sub end_h2 {
1.125 ! sakharuk 647: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1.122 albertel 648: my $currentstring = '';
649: if ($target eq 'web') {
650: $currentstring .= $token->[2];
651: } elsif ($target eq 'tex') {
1.125 ! sakharuk 652: my $post;
! 653: my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1);
! 654: if (($align eq 'center') || (not defined $align)) {
! 655: $post='\end{center}';
! 656: } elsif ($align eq 'left') {
! 657: $post='} \hfill'.'\vskip 0 mm ';
! 658: } elsif ($align eq 'right') {
! 659: $post='}'.'\vskip 0 mm ';
! 660: }
! 661: $currentstring .= '}}'.$post;
1.122 albertel 662: }
663: return $currentstring;
664: }
665:
1.35 sakharuk 666: #-- <h3> tag
1.122 albertel 667: sub start_h3 {
1.125 ! sakharuk 668: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1.122 albertel 669: my $currentstring = '';
670: if ($target eq 'web') {
671: $currentstring .= $token->[4];
672: } elsif ($target eq 'tex') {
1.125 ! sakharuk 673: my $pre;
! 674: my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1);
! 675: if (($align eq 'center') || (not defined $align)) {
! 676: $pre='\begin{center}';
! 677: } elsif ($align eq 'left') {
! 678: $pre='\rlap{';
! 679: } elsif ($align eq 'right') {
! 680: $pre=' \hfill \llap{';
! 681: }
! 682: my $TeXsize=&Apache::lonxml::get_param('TeXsize',$parstack,$safeeval,undef,0);
! 683: if (not defined $TeXsize) {$TeXsize="large";}
! 684: $currentstring .= $pre.'{\\'.$TeXsize.' \textbf{';
1.122 albertel 685: }
686: return $currentstring;
687: }
688:
689: sub end_h3 {
1.125 ! sakharuk 690: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1.122 albertel 691: my $currentstring = '';
692: if ($target eq 'web') {
693: $currentstring .= $token->[2];
694: } elsif ($target eq 'tex') {
1.125 ! sakharuk 695: my $post;
! 696: my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1);
! 697: if (($align eq 'center') || (not defined $align)) {
! 698: $post='\end{center}';
! 699: } elsif ($align eq 'left') {
! 700: $post='} \hfill'.'\vskip 0 mm ';
! 701: } elsif ($align eq 'right') {
! 702: $post='}'.'\vskip 0 mm ';
! 703: }
! 704: $currentstring .= '}}'.$post;
1.122 albertel 705: }
706: return $currentstring;
707: }
708:
1.35 sakharuk 709: #-- <h4> tag
1.122 albertel 710: sub start_h4 {
1.125 ! sakharuk 711: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1.122 albertel 712: my $currentstring = '';
713: if ($target eq 'web') {
714: $currentstring .= $token->[4];
715: } elsif ($target eq 'tex') {
1.125 ! sakharuk 716: my $pre;
! 717: my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1);
! 718: if (($align eq 'center') || (not defined $align)) {
! 719: $pre='\begin{center}';
! 720: } elsif ($align eq 'left') {
! 721: $pre='\rlap{';
! 722: } elsif ($align eq 'right') {
! 723: $pre=' \hfill \llap{';
! 724: }
! 725: my $TeXsize=&Apache::lonxml::get_param('TeXsize',$parstack,$safeeval,undef,0);
! 726: if (not defined $TeXsize) {$TeXsize="large";}
! 727: $currentstring .= $pre.'{\\'.$TeXsize.' \textbf{';
1.122 albertel 728: }
729: return $currentstring;
730: }
731:
732: sub end_h4 {
1.125 ! sakharuk 733: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1.122 albertel 734: my $currentstring = '';
735: if ($target eq 'web') {
736: $currentstring .= $token->[2];
737: } elsif ($target eq 'tex') {
1.125 ! sakharuk 738: my $post;
! 739: my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1);
! 740: if (($align eq 'center') || (not defined $align)) {
! 741: $post='\end{center}';
! 742: } elsif ($align eq 'left') {
! 743: $post='} \hfill'.'\vskip 0 mm ';
! 744: } elsif ($align eq 'right') {
! 745: $post='}'.'\vskip 0 mm ';
! 746: }
! 747: $currentstring .= '}}'.$post;
1.122 albertel 748: }
749: return $currentstring;
750: }
751:
1.35 sakharuk 752: #-- <h5> tag
1.122 albertel 753: sub start_h5 {
1.125 ! sakharuk 754: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1.122 albertel 755: my $currentstring = '';
756: if ($target eq 'web') {
757: $currentstring .= $token->[4];
758: } elsif ($target eq 'tex') {
1.125 ! sakharuk 759: my $pre;
! 760: my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1);
! 761: if (($align eq 'center') || (not defined $align)) {
! 762: $pre='\begin{center}';
! 763: } elsif ($align eq 'left') {
! 764: $pre='\rlap{';
! 765: } elsif ($align eq 'right') {
! 766: $pre=' \hfill \llap{';
! 767: }
! 768: my $TeXsize=&Apache::lonxml::get_param('TeXsize',$parstack,$safeeval,undef,0);
! 769: if (not defined $TeXsize) {$TeXsize="large";}
! 770: $currentstring .= $pre.'{\\'.$TeXsize.' \textbf{';
1.122 albertel 771: }
772: return $currentstring;
773: }
774:
775: sub end_h5 {
1.125 ! sakharuk 776: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1.122 albertel 777: my $currentstring = '';
778: if ($target eq 'web') {
779: $currentstring .= $token->[2];
780: } elsif ($target eq 'tex') {
1.125 ! sakharuk 781: my $post;
! 782: my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1);
! 783: if (($align eq 'center') || (not defined $align)) {
! 784: $post='\end{center}';
! 785: } elsif ($align eq 'left') {
! 786: $post='} \hfill'.'\vskip 0 mm ';
! 787: } elsif ($align eq 'right') {
! 788: $post='}'.'\vskip 0 mm ';
! 789: }
! 790: $currentstring .= '}}'.$post;
1.122 albertel 791: }
792: return $currentstring;
793: }
794:
1.35 sakharuk 795: #-- <h6> tag
1.122 albertel 796: sub start_h6 {
1.125 ! sakharuk 797: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1.122 albertel 798: my $currentstring = '';
799: if ($target eq 'web') {
800: $currentstring .= $token->[4];
801: } elsif ($target eq 'tex') {
1.125 ! sakharuk 802: my $pre;
! 803: my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1);
! 804: if (($align eq 'center') || (not defined $align)) {
! 805: $pre='\begin{center}';
! 806: } elsif ($align eq 'left') {
! 807: $pre='\rlap{';
! 808: } elsif ($align eq 'right') {
! 809: $pre=' \hfill \llap{';
! 810: }
! 811: my $TeXsize=&Apache::lonxml::get_param('TeXsize',$parstack,$safeeval,undef,0);
! 812: if (not defined $TeXsize) {$TeXsize="large";}
! 813: $currentstring .= $pre.'{\\'.$TeXsize.' \textbf{';
1.122 albertel 814: }
815: return $currentstring;
816: }
817:
818: sub end_h6 {
1.125 ! sakharuk 819: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1.122 albertel 820: my $currentstring = '';
821: if ($target eq 'web') {
822: $currentstring .= $token->[2];
823: } elsif ($target eq 'tex') {
1.125 ! sakharuk 824: my $post;
! 825: my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1);
! 826: if (($align eq 'center') || (not defined $align)) {
! 827: $post='\end{center}';
! 828: } elsif ($align eq 'left') {
! 829: $post='} \hfill'.'\vskip 0 mm ';
! 830: } elsif ($align eq 'right') {
! 831: $post='}'.'\vskip 0 mm ';
! 832: }
! 833: $currentstring .= '}}'.$post;
1.122 albertel 834: }
835: return $currentstring;
836: }
837:
1.35 sakharuk 838: #--- <cite> tag
1.122 albertel 839: sub start_cite {
840: my ($target,$token) = @_;
841: my $currentstring = '';
842: if ($target eq 'web') {
843: $currentstring .= $token->[4];
844: } elsif ($target eq 'tex') {
845: $currentstring .= "\\textit{";
846: } elsif ($target eq 'latexsource') {
847: $currentstring .= "\\textit{";
848: }
849: return $currentstring;
850: }
851:
852: sub end_cite {
853: my ($target,$token) = @_;
854: my $currentstring = '';
855: if ($target eq 'web') {
856: $currentstring .= $token->[2];
857: } elsif ($target eq 'tex') {
858: $currentstring .= "}";
859: } elsif ($target eq 'latexsource') {
860: $currentstring .= "}";
861: }
862: return $currentstring;
863: }
864:
1.35 sakharuk 865: #-- <i> tag
1.122 albertel 866: sub start_i {
867: my ($target,$token) = @_;
868: my $currentstring = '';
869: if ($target eq 'web') {
870: $currentstring .= $token->[4];
871: } elsif ($target eq 'tex') {
872: $currentstring .= '\textit{';
873: } elsif ($target eq 'latexsource') {
874: $currentstring .= '\textit{';
875: }
876: return $currentstring;
877: }
878:
879: sub end_i {
880: my ($target,$token) = @_;
881: my $currentstring = '';
882: if ($target eq 'web') {
883: $currentstring .= $token->[2];
884: } elsif ($target eq 'tex') {
885: $currentstring .= '}';
886: } elsif ($target eq 'latexsource') {
887: $currentstring .= '}';
888: }
889: return $currentstring;
890: }
891:
1.35 sakharuk 892: #-- <address> tag
1.122 albertel 893: sub start_address {
894: my ($target,$token) = @_;
895: my $currentstring = '';
896: if ($target eq 'web') {
897: $currentstring .= $token->[4];
898: } elsif ($target eq 'tex') {
899: $currentstring .= "\\textit{";
900: } elsif ($target eq 'latexsource') {
901: $currentstring .= "\\textit{";
902: }
903: return $currentstring;
904: }
905:
906: sub end_address {
907: my ($target,$token) = @_;
908: my $currentstring = '';
909: if ($target eq 'web') {
910: $currentstring .= $token->[2];
911: } elsif ($target eq 'tex') {
912: $currentstring .= "}";
913: } elsif ($target eq 'latexsource') {
914: $currentstring .= "}";
915: }
916: return $currentstring;
917: }
918:
1.35 sakharuk 919: #-- <dfn> tag
1.122 albertel 920: sub start_dfn {
921: my ($target,$token) = @_;
922: my $currentstring = '';
923: if ($target eq 'web') {
924: $currentstring .= $token->[4];
925: } elsif ($target eq 'tex') {
926: $currentstring .= "\\textit{";
927: } elsif ($target eq 'latexsource') {
928: $currentstring .= "\\textit{";
929: }
930: return $currentstring;
931: }
932:
933: sub end_dfn {
934: my ($target,$token) = @_;
935: my $currentstring = '';
936: if ($target eq 'web') {
937: $currentstring .= $token->[2];
938: } elsif ($target eq 'tex') {
939: $currentstring .= "}";
940: } elsif ($target eq 'latexsource') {
941: $currentstring .= "}";
942: }
943: return $currentstring;
944: }
945:
1.35 sakharuk 946: #-- <tt> tag
1.122 albertel 947: sub start_tt {
948: my ($target,$token) = @_;
949: my $currentstring = '';
950: if ($target eq 'web') {
951: $currentstring .= $token->[4];
952: } elsif ($target eq 'tex') {
953: $currentstring .= '\texttt{';
954: } elsif ($target eq 'latexsource') {
955: $currentstring .= '\texttt{';
956: }
957: return $currentstring;
958: }
959:
960: sub end_tt {
961: my ($target,$token) = @_;
962: my $currentstring = '';
963: if ($target eq 'web') {
964: $currentstring .= $token->[2];
965: } elsif ($target eq 'tex') {
966: $currentstring .= '}';
967: } elsif ($target eq 'latexsource') {
968: $currentstring .= '}';
969: }
970: return $currentstring;
971: }
972:
1.35 sakharuk 973: #-- <kbd> tag
1.122 albertel 974: sub start_kbd {
975: my ($target,$token) = @_;
976: my $currentstring = '';
977: if ($target eq 'web') {
978: $currentstring .= $token->[4];
979: } elsif ($target eq 'tex') {
980: $currentstring .= "\\texttt";
981: } elsif ($target eq 'latexsource') {
982: $currentstring .= "\\texttt{";
983: }
984: return $currentstring;
985: }
986:
987: sub end_kbd {
988: my ($target,$token) = @_;
989: my $currentstring = '';
990: if ($target eq 'web') {
991: $currentstring .= $token->[2];
992: } elsif ($target eq 'tex') {
993: $currentstring .= "}";
994: } elsif ($target eq 'latexsource') {
995: $currentstring .= "}";
996: }
997: return $currentstring;
998: }
999:
1.35 sakharuk 1000: #-- <code> tag
1.122 albertel 1001: sub start_code {
1002: my ($target,$token) = @_;
1003: my $currentstring = '';
1004: if ($target eq 'web') {
1005: $currentstring .= $token->[4];
1006: } elsif ($target eq 'tex') {
1007: $currentstring .= '\texttt{';
1008: }
1009: return $currentstring;
1010: }
1011:
1012: sub end_code {
1013: my ($target,$token) = @_;
1014: my $currentstring = '';
1015: if ($target eq 'web') {
1016: $currentstring .= $token->[2];
1017: } elsif ($target eq 'tex') {
1018: $currentstring .= '}';
1019: }
1020: return $currentstring;
1021: }
1022:
1.35 sakharuk 1023: #-- <em> tag
1.122 albertel 1024: sub start_em {
1025: my ($target,$token) = @_;
1026: my $currentstring = '';
1027: if ($target eq 'web') {
1028: $currentstring .= $token->[4];
1029: } elsif ($target eq 'tex') {
1030: $currentstring .= '\emph{';
1031: } elsif ($target eq 'latexsource') {
1032: $currentstring .= '\emph{';
1033: }
1034: return $currentstring;
1035: }
1036:
1037: sub end_em {
1038: my ($target,$token) = @_;
1039: my $currentstring = '';
1040: if ($target eq 'web') {
1041: $currentstring .= $token->[2];
1042: } elsif ($target eq 'tex') {
1043: $currentstring .= '}';
1044: } elsif ($target eq 'latexsource') {
1045: $currentstring .= '}';
1046: }
1047: return $currentstring;
1048: }
1049:
1.35 sakharuk 1050: #-- <q> tag
1.122 albertel 1051: sub start_q {
1052: my ($target,$token) = @_;
1053: my $currentstring = '';
1054: if ($target eq 'web') {
1055: $currentstring .= $token->[4];
1056: } elsif ($target eq 'tex') {
1057: $currentstring .= "\\emph{";
1058: } elsif ($target eq 'latexsource') {
1059: $currentstring .= "\\emph{";
1060: }
1061: return $currentstring;
1062: }
1063:
1064: sub end_q {
1065: my ($target,$token) = @_;
1066: my $currentstring = '';
1067: if ($target eq 'web') {
1068: $currentstring .= $token->[2];
1069: } elsif ($target eq 'tex') {
1070: $currentstring .= "}";
1071: } elsif ($target eq 'latexsource') {
1072: $currentstring .= "}";
1073: }
1074: return $currentstring;
1075: }
1076:
1.35 sakharuk 1077: #-- <p> tag
1.122 albertel 1078: sub start_p {
1079: my ($target,$token) = @_;
1080: my $currentstring = '';
1081: if ($target eq 'web') {
1082: $currentstring .= $token->[4];
1083: } elsif ($target eq 'tex') {
1084: $currentstring .= '{\par ';
1085: } elsif ($target eq 'latexsource') {
1086: $currentstring .= '{\par ';
1087: }
1088: return $currentstring;
1089: }
1090:
1091: sub end_p {
1092: my ($target,$token) = @_;
1093: my $currentstring = '';
1094: if ($target eq 'web') {
1095: $currentstring .= $token->[2];
1096: } elsif ($target eq 'tex') {
1097: $currentstring .= '}';
1098: } elsif ($target eq 'latexsource') {
1099: $currentstring .= '}';
1100: }
1101: return $currentstring;
1102: }
1103:
1.35 sakharuk 1104: #-- <br> tag
1.122 albertel 1105: sub start_br {
1106: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1107: my $currentstring = '';
1108: if ($target eq 'web') {
1109: $currentstring .= $token->[4];
1110: } elsif ($target eq 'tex') {
1111: if ($$tagstack[-2] ne 'sub' && $$tagstack[-2] ne 'sup') {
1112: $currentstring .= '\vskip 0.2 mm';
1.1 sakharuk 1113: }
1.122 albertel 1114: } elsif ($target eq 'latexsource') {
1115: $currentstring .= '\\';
1116: }
1117: return $currentstring;
1118: }
1119:
1120: sub end_br {
1121: my ($target,$token) = @_;
1122: my $currentstring = '';
1123: if ($target eq 'web') {
1124: $currentstring .= $token->[2];
1125: }
1126: return $currentstring;
1127: }
1128:
1.35 sakharuk 1129: #-- <big> tag
1.122 albertel 1130: sub start_big {
1131: my ($target,$token) = @_;
1132: my $currentstring = '';
1133: if ($target eq 'web') {
1134: $currentstring .= $token->[4];
1135: } elsif ($target eq 'tex') {
1136: $currentstring .= '\large{';
1137: } elsif ($target eq 'latexsource') {
1138: $currentstring .= '{\Large ';
1139: }
1140: return $currentstring;
1141: }
1142:
1143: sub end_big {
1144: my ($target,$token) = @_;
1145: my $currentstring = '';
1146: if ($target eq 'web') {
1147: $currentstring .= $token->[2];
1148: } elsif ($target eq 'tex') {
1149: $currentstring .= '}';
1150: } elsif ($target eq 'latexsource') {
1151: $currentstring .= '}';
1152: }
1153: return $currentstring;
1154: }
1155:
1.35 sakharuk 1156: #-- <small> tag
1.122 albertel 1157: sub start_small {
1158: my ($target,$token) = @_;
1159: my $currentstring = '';
1160: if ($target eq 'web') {
1161: $currentstring .= $token->[4];
1162: } elsif ($target eq 'tex') {
1163: $currentstring .= '{\footnotesize ';
1164: } elsif ($target eq 'latexsource') {
1165: $currentstring .= '{\footnotesize ';
1166: }
1167: return $currentstring;
1168: }
1169:
1170: sub end_small {
1171: my ($target,$token) = @_;
1172: my $currentstring = '';
1173: if ($target eq 'web') {
1174: $currentstring .= $token->[2];
1175: } elsif ($target eq 'tex') {
1176: $currentstring .= '}';
1177: } elsif ($target eq 'latexsource') {
1178: $currentstring .= '}';
1179: }
1180: return $currentstring;
1181: }
1182:
1.35 sakharuk 1183: #-- <basefont> tag
1.122 albertel 1184: sub start_basefont {
1185: my ($target,$token) = @_;
1186: my $currentstring = '';
1187: if ($target eq 'web') {
1188: $currentstring = $token->[4];
1189: }
1190: return $currentstring;
1191: }
1192:
1193: sub end_basefont {
1194: my ($target,$token) = @_;
1195: my $currentstring = '';
1196: if ($target eq 'web') {
1197: $currentstring = $token->[4];
1198: }
1199: return $currentstring;
1200: }
1201:
1.35 sakharuk 1202: #-- <font> tag
1.122 albertel 1203: sub start_font {
1204: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1205: my $currentstring = '';
1206: if ($target eq 'web') {
1207: my $face=&Apache::lonxml::get_param('face',$parstack,$safeeval);
1208: if ($face=~/symbol/i) {$Apache::lonxml::prevent_entity_encode++;}
1209: $currentstring = $token->[4];
1210: }
1211: return $currentstring;
1212: }
1213:
1214: sub end_font {
1215: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1216: my $currentstring = '';
1217: if ($target eq 'web') {
1218: my $face=&Apache::lonxml::get_param('face',$parstack,$safeeval);
1219: if ($face=~/symbol/i) {$Apache::lonxml::prevent_entity_encode--;}
1220: $currentstring = $token->[2];
1221: }
1222: return $currentstring;
1223: }
1224:
1.35 sakharuk 1225: #-- <strike> tag
1.122 albertel 1226: sub start_strike {
1227: my ($target,$token) = @_;
1228: my $currentstring = '';
1229: if ($target eq 'web') {
1230: $currentstring .= $token->[4];
1231: } elsif ($target eq 'tex') {
1232: &Apache::lonxml::startredirection();
1233: }
1234: return $currentstring;
1235: }
1236:
1237: sub end_strike {
1238: my ($target,$token) = @_;
1239: my $currentstring = '';
1240: if ($target eq 'web') {
1241: $currentstring .= $token->[2];
1242: } elsif ($target eq 'tex') {
1243: $currentstring=&Apache::lonxml::endredirection();
1244: $currentstring=~s/(\S)(\s+)(\S)/$1\}$2\\underline\{$3/g;
1245: $currentstring=~s/^\s*(\S)/\\underline\{$1/;
1246: $currentstring=~s/(\S)\s*$/$1\}/;
1247: }
1248: return $currentstring;
1249: }
1250:
1.35 sakharuk 1251: #-- <s> tag
1.122 albertel 1252: sub start_s {
1253: my ($target,$token) = @_;
1254: my $currentstring = '';
1255: if ($target eq 'web') {
1256: $currentstring .= $token->[4];
1257: } elsif ($target eq 'tex') {
1258: &Apache::lonxml::startredirection();
1259: }
1260: return $currentstring;
1261: }
1262:
1263: sub end_s {
1264: my ($target,$token) = @_;
1265: my $currentstring = '';
1266: if ($target eq 'web') {
1267: $currentstring .= $token->[2];
1268: } elsif ($target eq 'tex') {
1269: $currentstring=&Apache::lonxml::endredirection();
1270: $currentstring=~s/(\S)(\s+)(\S)/$1\}$2\\underline\{$3/g;
1271: $currentstring=~s/^\s*(\S)/\\underline\{$1/;
1272: $currentstring=~s/(\S)\s*$/$1\}/;
1273: }
1274: return $currentstring;
1275: }
1276:
1.35 sakharuk 1277: #-- <sub> tag
1.122 albertel 1278: sub start_sub {
1279: my ($target,$token) = @_;
1280: my $currentstring = '';
1281: if ($target eq 'web') {
1282: $currentstring .= $token->[4];
1283: } elsif ($target eq 'tex') {
1284: $currentstring .= "\$_{ ";
1285: }
1286: return $currentstring;
1287: }
1288:
1289: sub end_sub {
1290: my ($target,$token) = @_;
1291: my $currentstring = '';
1292: if ($target eq 'web') {
1293: $currentstring .= $token->[2];
1294: } elsif ($target eq 'tex') {
1295: $currentstring .= " }\$";
1296: }
1297: return $currentstring;
1298: }
1299:
1.35 sakharuk 1300: #-- <sup> tag
1.122 albertel 1301: sub start_sup {
1302: my ($target,$token) = @_;
1303: my $currentstring = '';
1304: if ($target eq 'web') {
1305: $currentstring .= $token->[4];
1306: } elsif ($target eq 'tex') {
1307: $currentstring .= "\$^{ ";
1308: }
1309: return $currentstring;
1310: }
1311:
1312: sub end_sup {
1313: my ($target,$token) = @_;
1314: my $currentstring = '';
1315: if ($target eq 'web') {
1316: $currentstring .= $token->[2];
1317: } elsif ($target eq 'tex') {
1318: $currentstring .= " }\$";
1319: }
1320: return $currentstring;
1321: }
1322:
1.35 sakharuk 1323: #-- <hr> tag
1.122 albertel 1324: sub start_hr {
1.124 sakharuk 1325: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1.122 albertel 1326: my $currentstring = '';
1327: if ($target eq 'web') {
1328: $currentstring .= $token->[4];
1329: } elsif ($target eq 'tex') {
1.125 ! sakharuk 1330: my $LaTeXwidth = &Apache::lonxml::get_param('TeXwidth',$parstack,$safeeval,0);
1.124 sakharuk 1331: if (defined $LaTeXwidth) {
1332: if ($LaTeXwidth=~/^%/) {
1333: substr($LaTeXwidth,0,1)='';
1334: $LaTeXwidth=($LaTeXwidth/100).'\textwidth';
1335: }
1336: } else {
1337: $LaTeXwidth ='0.95\textwidth';
1338: }
1339: my ($pre,$post);
1340: my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1);
1341: if (($align eq 'center') || (not defined $align)) {
1342: $pre=''; $post='';
1343: } elsif ($align eq 'left') {
1344: $pre='\rlap{'; $post='} \hfill';
1345: } elsif ($align eq 'right') {
1346: $pre=' \hfill \llap{'; $post='}';
1347: }
1348: $currentstring .= ' \vskip 0 mm \noindent\makebox[\textwidth]{'.$pre.'\makebox['.
1349: $LaTeXwidth.'][b]{\hrulefill}'.$post.'}\vskip 0 mm ';
1.122 albertel 1350: }
1351: return $currentstring;
1352: }
1353:
1354: sub end_hr {
1355: my ($target,$token) = @_;
1356: my $currentstring = '';
1357: if ($target eq 'web') {
1358: $currentstring .= $token->[2];
1359: } elsif ($target eq 'tex') {
1360: }
1361: return $currentstring;
1362: }
1363:
1.85 sakharuk 1364: #-- <div> tag
1.122 albertel 1365: sub start_div {
1366: my ($target,$token) = @_;
1367: my $currentstring = '';
1368: if ($target eq 'web') {
1369: $currentstring .= $token->[4];
1370: }
1371: return $currentstring;
1372: }
1373:
1374: sub end_div {
1375: my ($target,$token) = @_;
1376: my $currentstring = '';
1377: if ($target eq 'web') {
1378: $currentstring .= $token->[2];
1379: }
1380: return $currentstring;
1381: }
1382:
1.35 sakharuk 1383: #-- <a> tag
1.122 albertel 1384: sub start_a {
1385: my ($target,$token) = @_;
1386: my $currentstring = '';
1387: if ($target eq 'web') {
1388: $currentstring .= $token->[4];
1389: } elsif ($target eq 'tex') {
1390: }
1391: return $currentstring;
1392: }
1393:
1394: sub end_a {
1395: my ($target,$token,$tagstack,$stackref) = @_;
1396: my $currentstring = '';
1397: if ($target eq 'web') {
1398: $currentstring .= $token->[2];
1399: } elsif ($target eq 'tex') {
1400: my $tempor_var = $stackref->[$#$stackref];
1401: if (index($tempor_var,'name') != -1 ) {
1402: $tempor_var =~ s/name=([^,]*),/$1/g;
1403: } elsif (index($tempor_var,'href') != -1 ) {
1404: $tempor_var =~ s/href=([^,]*),/$1/g;
1405: $currentstring .= " \\ref{$tempor_var}";
1.1 sakharuk 1406: }
1.122 albertel 1407: }
1408: return $currentstring;
1409: }
1410:
1.35 sakharuk 1411: #-- <li> tag
1.122 albertel 1412: sub start_li {
1413: my ($target,$token,$tagstack,$stackref) = @_;
1414: my $currentstring = '';
1415: if ($target eq 'web') {
1416: $currentstring = $token->[4];
1417: } elsif ($target eq 'tex') {
1418: my $tempor_var = $stackref->[$#$stackref];
1419: if (index($tempor_var,'circle') != -1 ) {
1420: $currentstring .= " \\item[o] ";
1421: } elsif (index($tempor_var,'square') != -1 ) {
1422: $currentstring .= " \\item[$\Box$] ";
1423: } elsif ($tempor_var ne '') {
1424: $_ = $tempor_var;
1425: m/my\s*([^=]*)=/;
1426: $currentstring .= " \\item[$1] ";
1427: } else {
1428: $currentstring .= " \\item ";
1429: }
1430: }
1431: return $currentstring;
1432: }
1433:
1434: sub end_li {
1435: my ($target,$token) = @_;
1436: my $currentstring = '';
1437: if ($target eq 'web') {
1438: $currentstring = $token->[2];
1439: }
1440: return $currentstring;
1441: }
1442:
1.35 sakharuk 1443: #-- <u> tag
1.122 albertel 1444: sub start_u {
1445: my ($target,$token) = @_;
1446: my $currentstring = '';
1447: if ($target eq 'web') {
1448: $currentstring .= $token->[4];
1449: } elsif ($target eq 'tex') {
1450: &Apache::lonxml::startredirection();
1451: }
1452: return $currentstring;
1453: }
1454:
1455: sub end_u {
1456: my ($target,$token) = @_;
1457: my $currentstring = '';
1458: if ($target eq 'web') {
1459: $currentstring .= $token->[2];
1460: } elsif ($target eq 'tex') {
1461: $currentstring=&Apache::lonxml::endredirection();
1462: $currentstring=~s/(\S)(\s+)(\S)/$1\}$2\\underline\{$3/g;
1463: $currentstring=~s/^\s*(\S)/\\underline\{$1/;
1464: $currentstring=~s/(\S)\s*$/$1\}/;
1465: }
1466: return $currentstring;
1467: }
1468:
1.35 sakharuk 1469: #-- <ul> tag
1.122 albertel 1470: sub start_ul {
1.125 ! sakharuk 1471: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1.122 albertel 1472: my $currentstring = '';
1473: if ($target eq 'web') {
1474: $currentstring = $token->[4];
1475: } elsif ($target eq 'tex') {
1.125 ! sakharuk 1476: my $TeXtype=&Apache::lonxml::get_param('type',$parstack,$safeeval,undef,0);
! 1477: if ($TeXtype eq 'disc') {
! 1478: $currentstring .= ' \renewcommand{\labelitemi}{$\bullet$}
! 1479: \renewcommand{\labelitemii}{$\bullet$}
! 1480: \renewcommand{\labelitemiii}{$\bullet$}
! 1481: \renewcommand{\labelitemiv}{$\bullet$}';
! 1482: } elsif ($TeXtype eq 'circle') {
! 1483: $currentstring .= ' \renewcommand{\labelitemi}{$\circ$}
! 1484: \renewcommand{\labelitemii}{$\circ$}
! 1485: \renewcommand{\labelitemiii}{$\circ$}
! 1486: \renewcommand{\labelitemiv}{$\circ$}';
! 1487: } elsif ($TeXtype eq 'square') {
! 1488: $currentstring .= ' \renewcommand{\labelitemi}{$\diamond$}
! 1489: \renewcommand{\labelitemii}{$\diamond$}
! 1490: \renewcommand{\labelitemiii}{$\diamond$}
! 1491: \renewcommand{\labelitemiv}{$\diamond$}';
! 1492: }
! 1493: $currentstring .= '\begin{itemize}';
1.122 albertel 1494: }
1495: return $currentstring;
1496: }
1497:
1498: sub end_ul {
1499: my ($target,$token) = @_;
1500: my $currentstring = '';
1501: if ($target eq 'web') {
1502: $currentstring = $token->[2];
1503: } elsif ($target eq 'tex') {
1.125 ! sakharuk 1504: $currentstring = '\end{itemize} \renewcommand{\labelitemi}{$\bullet$}
! 1505: \renewcommand{\labelitemii}{$\bullet$}
! 1506: \renewcommand{\labelitemiii}{$\bullet$}
! 1507: \renewcommand{\labelitemiv}{$\bullet$}';
1.122 albertel 1508: }
1509: return $currentstring;
1510: }
1511:
1.35 sakharuk 1512: #-- <menu> tag
1.122 albertel 1513: sub start_menu {
1514: my ($target,$token) = @_;
1515: my $currentstring = '';
1516: if ($target eq 'web') {
1517: $currentstring = $token->[4];
1518: } elsif ($target eq 'tex') {
1519: $currentstring = " \\begin{itemize} ";
1520: }
1521: return $currentstring;
1522: }
1523:
1524: sub end_menu {
1525: my ($target,$token) = @_;
1526: my $currentstring = '';
1527: if ($target eq 'web') {
1528: $currentstring = $token->[2];
1529: } elsif ($target eq 'tex') {
1530: $currentstring = " \\end{itemize}";
1531: }
1532: return $currentstring;
1533: }
1534:
1.35 sakharuk 1535: #-- <dir> tag
1.122 albertel 1536: sub start_dir {
1537: my ($target,$token) = @_;
1538: my $currentstring = '';
1539: if ($target eq 'web') {
1540: $currentstring = $token->[4];
1541: } elsif ($target eq 'tex') {
1542: $currentstring = " \\begin{itemize} ";
1543: }
1544: return $currentstring;
1545: }
1546:
1547: sub end_dir {
1548: my ($target,$token) = @_;
1549: my $currentstring = '';
1550: if ($target eq 'web') {
1551: $currentstring = $token->[2];
1552: } elsif ($target eq 'tex') {
1553: $currentstring = " \\end{itemize}";
1554: }
1555: return $currentstring;
1556: }
1557:
1.35 sakharuk 1558: #-- <ol> tag
1.122 albertel 1559: sub start_ol {
1.125 ! sakharuk 1560: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1.122 albertel 1561: my $currentstring = '';
1562: if ($target eq 'web') {
1563: $currentstring = $token->[4];
1564: } elsif ($target eq 'tex') {
1.125 ! sakharuk 1565: my $type=&Apache::lonxml::get_param('type',$parstack,$safeeval,undef,0);
! 1566: if ($type eq '1') {
! 1567: $currentstring .= ' \renewcommand{\labelenumi}{\arabic{enumi}.}
! 1568: \renewcommand{\labelenumii}{\arabic{enumii}.}
! 1569: \renewcommand{\labelenumiii}{\arabic{enumiii}.}
! 1570: \renewcommand{\labelenumiv}{\arabic{enumiv}.}';
! 1571: } elsif ($type eq 'A') {
! 1572: $currentstring .= ' \renewcommand{\labelenumi}{\Alph{enumi}.}
! 1573: \renewcommand{\labelenumii}{\Alph{enumii}.}
! 1574: \renewcommand{\labelenumiii}{\Alph{enumiii}.}
! 1575: \renewcommand{\labelenumiv}{\Alph{enumiv}.}';
! 1576: } elsif ($type eq 'a') {
! 1577: $currentstring .= ' \renewcommand{\labelenumi}{\alph{enumi}.}
! 1578: \renewcommand{\labelenumii}{\alph{enumii}.}
! 1579: \renewcommand{\labelenumiii}{\alph{enumiii}.}
! 1580: \renewcommand{\labelenumiv}{\alph{enumiv}.} ';
! 1581: } elsif ($type eq 'i') {
! 1582: $currentstring .= ' \renewcommand{\labelenumi}{\roman{enumi}.}
! 1583: \renewcommand{\labelenumii}{\roman{enumii}.}
! 1584: \renewcommand{\labelenumiii}{\roman{enumiii}.}
! 1585: \renewcommand{\labelenumiv}{\roman{enumiv}.} ';
! 1586: } elsif ($type eq 'I') {
! 1587: $currentstring .= ' \renewcommand{\labelenumi}{\Roman{enumi}.}
! 1588: \renewcommand{\labelenumii}{\Roman{enumii}.}
! 1589: \renewcommand{\labelenumiii}{\Roman{enumiii}.}
! 1590: \renewcommand{\labelenumiv}{\Roman{enumiv}.} ';
! 1591: }
! 1592: $currentstring .= '\begin{enumerate}';
1.122 albertel 1593: }
1594: return $currentstring;
1595: }
1596:
1597: sub end_ol {
1598: my ($target,$token) = @_;
1599: my $currentstring = '';
1600: if ($target eq 'web') {
1601: $currentstring = $token->[2];
1602: } elsif ($target eq 'tex') {
1.125 ! sakharuk 1603: $currentstring = '\end{enumerate} \renewcommand{\labelenumi}{\arabic{enumi}.}
! 1604: \renewcommand{\labelenumii}{\arabic{enumii}.}
! 1605: \renewcommand{\labelenumiii}{\arabic{enumiii}.}
! 1606: \renewcommand{\labelenumiv}{\arabic{enumiv}.}';
1.122 albertel 1607: }
1608: return $currentstring;
1609: }
1610:
1.35 sakharuk 1611: #-- <dl> tag
1.122 albertel 1612: sub start_dl {
1613: my ($target,$token) = @_;
1614: my $currentstring = '';
1615: if ($target eq 'web') {
1616: $currentstring = $token->[4];
1617: } elsif ($target eq 'tex') {
1618: $currentstring = '\begin{description}';
1619: }
1620: return $currentstring;
1621: }
1622:
1623: sub end_dl {
1624: my ($target,$token) = @_;
1625: my $currentstring = '';
1626: if ($target eq 'web') {
1627: $currentstring = $token->[2];
1628: } elsif ($target eq 'tex') {
1629: $currentstring = '\end{description}';
1630: }
1631: return $currentstring;
1632: }
1633:
1.35 sakharuk 1634: #-- <dt> tag
1.122 albertel 1635: sub start_dt {
1636: my ($target,$token) = @_;
1637: my $currentstring = '';
1638: if ($target eq 'web') {
1639: $currentstring = $token->[4];
1640: } elsif ($target eq 'tex') {
1641: $currentstring = '\item[';
1642: }
1643: return $currentstring;
1644: }
1645:
1646: sub end_dt {
1647: my ($target,$token) = @_;
1648: my $currentstring = '';
1649: if ($target eq 'web') {
1650: $currentstring = $token->[2];
1651: } elsif ($target eq 'tex') {
1652: $currentstring = ']';
1653: }
1654: return $currentstring;
1655: }
1656:
1.35 sakharuk 1657: #-- <dd> tag
1.122 albertel 1658: sub start_dd {
1659: my ($target,$token) = @_;
1660: my $currentstring = '';
1661: if ($target eq 'web') {
1662: $currentstring = $token->[4];
1663: }
1664: return $currentstring;
1665: }
1666:
1667: sub end_dd {
1668: my ($target,$token) = @_;
1669: my $currentstring = '';
1670: if ($target eq 'web') {
1671: $currentstring = $token->[2];
1672: }
1673: return $currentstring;
1674: }
1675:
1.35 sakharuk 1676: #-- <table> tag
1.91 sakharuk 1677: sub start_table {
1678: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1679: my $currentstring = '';
1680: if ($target eq 'web') {
1681: $currentstring = $token->[4];
1682: } elsif ($target eq 'tex') {
1683: my $aa = {};
1684: push @Apache::londefdef::table, $aa;
1685: $Apache::londefdef::table[-1]{'row_number'} = -1;
1686: $Apache::londefdef::table[-1]{'output'} = ' \noindent \begin{tabular} ';
1.101 sakharuk 1687: my $border = &Apache::lonxml::get_param('border',$parstack,$safeeval,undef,1);
1.91 sakharuk 1688: unless (defined $border) { $border = 0; }
1689: if ($border) {
1690: $Apache::londefdef::table[-1]{'hinc'} = '\hline ';
1691: $Apache::londefdef::table[-1]{'vinc'} = '&';
1692: $Apache::londefdef::table[-1]{'vvinc'} = '|';
1693: } else {
1694: $Apache::londefdef::table[-1]{'hinc'} = '';
1695: $Apache::londefdef::table[-1]{'vinc'} = '&';
1696: $Apache::londefdef::table[-1]{'vvinc'} = '';
1697: }
1698: my $width;
1699: foreach my $key (keys(%{$token->[2]})) {
1700: if ($key =~ /^width$/i) {
1.101 sakharuk 1701: $width = &Apache::lonxml::get_param($key,$parstack,$safeeval,undef,1);
1.91 sakharuk 1702: }
1.51 sakharuk 1703: }
1.91 sakharuk 1704: if (defined($width)) { $Apache::londefdef::table[-1]{'width'}=$width; }
1705: }
1706: return $currentstring;
1707: }
1.122 albertel 1708:
1709: sub end_table {
1710: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1711: my $currentstring = '';
1712: if ($target eq 'web') {
1713: $currentstring = $token->[2];
1714: } elsif ($target eq 'tex') {
1715: my $inmemory = '';
1716: my $output = '';
1717: #construct header of the table
1718: my $header_of_table = '{'.$Apache::londefdef::table[-1]{'vvinc'};
1719: my $in;
1720: for ($in=0;$in<=$Apache::londefdef::table[-1]{'counter_columns'};$in++) {
1721: $header_of_table .= $Apache::londefdef::table[-1]{'columns'}[$in].$Apache::londefdef::table[-1]{'vvinc'};
1722: }
1723: $header_of_table .= '}';
1724: #fill the table
1725: for ($in=0;$in<=$Apache::londefdef::table[-1]{'row_number'};$in++) {
1726: $output .= $Apache::londefdef::table[-1]{'rowdata'}[$in];
1727: chop $output;
1728: $output .= ' \\\\ ';
1729: }
1730: #define the length of the table cells
1731: my @lengthforoutput = split(/,/,$Apache::londefdef::table[-1]{'lengthrow'}[0]);
1732: my $how_many_columns = $#lengthforoutput + 1; #total number of columns in the table
1733: my $filled_columns = 0; #number of columns with information about width
1734: my $available_space = ' ';
1735: foreach my $tempo_length (@{ $Apache::londefdef::table[-1]{'lengthrow'} }) {
1736: my @length = split(/,/,$tempo_length);
1737: for (my $ico=0;$ico<=$#lengthforoutput;$ico++) {
1738: $lengthforoutput[$ico] =~ m/(\d*\.?\d*)\s*(\w+)/;
1739: my $old_value = $1;
1740: my $old_unit = $2;
1741: if ($old_unit eq 'cm') {
1742: $old_value = $old_value * 10;
1743: } elsif ($old_unit eq 'in') {
1744: $old_value = $old_value * 25.4;
1745: } elsif ($old_unit eq 'pt') {
1746: $old_value = $old_value * 25.4/72.27;
1747: } elsif ($old_unit eq 'pc') {
1748: $old_value = $old_value * 25.4/6.022;
1.50 sakharuk 1749: }
1.122 albertel 1750: $old_unit = 'mm';
1751: $length[$ico] =~ m/(\d*\.?\d*)\s*(\w+)/;
1752: my $new_value = $1;
1753: my $new_unit = $2;
1754: if ($new_unit eq 'cm') {
1755: $new_value = $new_value * 10;
1756: } elsif ($old_unit eq 'in') {
1757: $new_value = $new_value * 25.4;
1758: } elsif ($old_unit eq 'pt') {
1759: $new_value = $new_value * 25.4/72.27;
1760: } elsif ($old_unit eq 'pc') {
1761: $new_value = $new_value * 25.4/6.022;
1.71 sakharuk 1762: }
1.122 albertel 1763: $new_unit = 'mm';
1764: if ($old_value < $new_value) {
1765: $lengthforoutput[$ico] = $new_value.' mm';
1.91 sakharuk 1766: } else {
1.122 albertel 1767: $lengthforoutput[$ico] = $old_value.' mm';
1.53 sakharuk 1768: }
1.51 sakharuk 1769: }
1770: }
1.122 albertel 1771: for (my $ico=0;$ico<=$#lengthforoutput;$ico++) {
1772: if (not $lengthforoutput[$ico]=~m/^\s*0\s*\w*\s*$/) {
1773: $filled_columns++;
1774: $available_space = $available_space.' - '.$lengthforoutput[$ico];
1775: }
1776: }
1777: my $temp_file;
1778: my $filename = "/home/httpd/prtspool/$ENV{'user.name'}_$ENV{'user.domain'}_printout.tbl";
1779: if (-e $filename) {
1780: $temp_file = Apache::File->new($filename);
1781: my @tbl_file_content = <$temp_file>;
1782: my ($one,$two,$three) = split(/,/,$tbl_file_content[0]);
1783: $how_many_columns+=$one-1;
1784: $filled_columns+=$two;
1785: if($three=~/\S/) {$available_space = $available_space.' - '.$three;}
1786: } else {
1787: $temp_file = Apache::File->new('>>'.$filename);
1788: }
1789: print $temp_file "$how_many_columns,$filled_columns,$available_space\n";
1790: $output =~ s/\\parbox{TOBECHANGEDONNUMBER}{}/\\parbox{1 mm}{}/g;
1791: $output =~ s/\\parbox{TOBECHANGEDONNUMBER}/\\parbox{\$SpacePerColumn}/g;
1792: my @tagar = @$tagstack;
1793: my $signature = 1;
1794: for (my $ico=0;$ico<$#tagar;$ico++) {
1795: if ($tagar[$ico] eq 'table') { $signature = 0; }
1796: }
1797: if ($signature) {
1798: my $NumberEmptyLength = $how_many_columns - $filled_columns;
1799: my $SpacePerColumn = '(\textwidth '.$available_space.')/'.$NumberEmptyLength;
1800: my $shorthand = ($filled_columns+1)*4;
1801: $output =~ s/\$SpacePerColumn/$SpacePerColumn - $shorthand mm/g;
1802: }
1803: if ($how_many_columns==1) {
1804: #start of block with width correction for one column table
1805: $output=~s/^\s*\\parbox\{([^\}]*)\}/\\parbox\{\\textwidth - 1 cm\}/;
1806: #end of block with width correction for one column table
1807: }
1808: $Apache::londefdef::table[-1]{'output'} .= $header_of_table.$output.$Apache::londefdef::table[-1]{'hinc'}.'\end{tabular}\vskip 0 mm ';
1809: if ($#Apache::londefdef::table > 0) {
1810: $inmemory = $Apache::londefdef::table[-1]{'output'};
1811: pop @Apache::londefdef::table;
1812: $Apache::londefdef::table[-1]{'rowdata'}[$Apache::londefdef::table[-1]{'row_number'}] .= $inmemory
1813: } else {
1814: $currentstring = $Apache::londefdef::table[-1]{'output'};
1815: $currentstring =~ s/\\\\\s+\\\\/\\\\/g;
1816: pop @Apache::londefdef::table;
1817: if (-e $filename) {
1818: unlink $filename;
1819: }
1820: }
1821: }
1822: return $currentstring;
1823: }
1824:
1.51 sakharuk 1825: #-- <tr> tag
1.122 albertel 1826: sub start_tr {
1827: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1828: my $currentstring = '';
1829: if ($target eq 'web') {
1830: $currentstring = $token->[4];
1831: } elsif ($target eq 'tex') {
1832: $Apache::londefdef::table[-1]{'row_number'}++;
1833: my $alignchar = substr(&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1),0,1);
1834: if ($alignchar ne '') {
1835: push @ {$Apache::londefdef::table[-1]{'rows'} }, $alignchar;
1836: } else {
1837: push @ {$Apache::londefdef::table[-1]{'rows'} }, 'l';
1838: }
1839: push ( @{ $Apache::londefdef::table[-1]{'rowdata'} }, $Apache::londefdef::table[-1]{'hinc'});
1840: $Apache::londefdef::table[-1]{'counter_columns'} = -1;
1841: $Apache::londefdef::table[-1]{'length'} = '';
1842: }
1843: return $currentstring;
1844: }
1845:
1846: sub end_tr {
1847: my ($target,$token) = @_;
1848: my $currentstring = '';
1849: if ($target eq 'web') {
1850: $currentstring = $token->[2];
1851: } elsif ($target eq 'tex') {
1852: push @{ $Apache::londefdef::table[-1]{'lengthrow'} },$Apache::londefdef::table[-1]{'length'};
1853:
1854: }
1855: return $currentstring;
1856: }
1857:
1858: #-- <td> tag
1859: sub start_td {
1860: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1861: my $currentstring = '';
1862: if ($target eq 'web') {
1863: $currentstring = $token->[4];
1864: } elsif ($target eq 'tex') {
1865: my $what_to_push = substr(&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1),0,1);
1866: if ($what_to_push eq '') {
1867: $what_to_push = substr($Apache::londefdef::table[-1]{'rows'}[0],0,1);;
1868: }
1869: push @{ $Apache::londefdef::table[-1]{'columns'} }, $what_to_push;
1870: $Apache::londefdef::table[-1]{'counter_columns'}++;
1871: &Apache::lonxml::startredirection();
1872: }
1873: return $currentstring;
1874: }
1875:
1876: sub end_td {
1877: my ($target,$token) = @_;
1878: my $currentstring = '';
1879: my $tempolen = '';
1880: if ($target eq 'web') {
1881: $currentstring = $token->[2];
1882: } elsif ($target eq 'tex') {
1883: my $current_row = $Apache::londefdef::table[-1]{'row_number'};
1884: my $data=&Apache::lonxml::endredirection();
1885: if ($data=~m/width\s*=\s*(\d+\.?\d*\s*(mm|cm|in|pc|pt))/) {
1886: $Apache::londefdef::table[-1]{'length'} .= $1.',';
1887: $tempolen = $1;
1888: } else {
1889: if (length($data)<5) {
1890: $Apache::londefdef::table[-1]{'length'} .= '0 mm,';
1891: $tempolen = '6 mm';
1892: } else {
1893: $Apache::londefdef::table[-1]{'length'} .= '0 mm,';
1894: $tempolen = 'TOBECHANGEDONNUMBER';
1895: }
1896: }
1897: @{ $Apache::londefdef::table[-1]{'rowdata'} }[$current_row] .= '\parbox{'.$tempolen.'}{'.$data.'} '.$Apache::londefdef::table[-1]{'vinc'};
1898: }
1899: return $currentstring;
1900: }
1901:
1902: #-- <th> tag
1903: sub start_th {
1904: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1905: my $currentstring = '';
1906: if ($target eq 'web') {
1907: $currentstring = $token->[4];
1908: } elsif ($target eq 'tex') {
1909: my $what_to_push = substr(&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1),0,1);
1910: if ($what_to_push eq '') {
1911: $what_to_push = substr($Apache::londefdef::table[-1]{'rows'}[0],0,1);;
1912: }
1913: push @{ $Apache::londefdef::table[-1]{'columns'} }, $what_to_push;
1914: $Apache::londefdef::table[-1]{'counter_columns'}++;
1915: &Apache::lonxml::startredirection();
1916: ;
1917: }
1918: return $currentstring;
1919: }
1920:
1921: sub end_th {
1922: my ($target,$token) = @_;
1923: my $currentstring = '';
1924: if ($target eq 'web') {
1925: $currentstring = $token->[2];
1926: } elsif ($target eq 'tex') {
1927: my $current_row = $Apache::londefdef::table[-1]{'row_number'};
1928: my $data=&Apache::lonxml::endredirection();
1929: if ($data=~m/width\s*=\s*(\d+\.*\d*\s*(mm|cm))/) {
1930: $Apache::londefdef::table[-1]{'length'} .= $1.',';
1931: } else {
1932: $Apache::londefdef::table[-1]{'length'} .= '0 mm,';
1933: }
1934: @{ $Apache::londefdef::table[-1]{'rowdata'} }[$current_row] .= '\parbox{'.$1.'}{\textbf{'.$data.'}} '.$Apache::londefdef::table[-1]{'vinc'};
1935: }
1936: return $currentstring;
1937: }
1.79 sakharuk 1938:
1.122 albertel 1939: #-- <img> tag
1940: sub start_img {
1941: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1942: my $src = &Apache::lonxml::get_param('src',$parstack,$safeeval,
1943: undef,1);
1944: $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=$src;
1945: my $currentstring = '';
1946: my $width_param = '';
1947: my $height_param = '';
1948: my $scaling = .3;
1949:
1950: if ($target eq 'web') {
1951: if ($ENV{'browser.imagesuppress'} ne 'on') {
1952: $currentstring = $token->[4];
1953: } else {
1954: my $alttag= &Apache::lonxml::get_param
1955: ('alt',$parstack,$safeeval,undef,1);
1956: unless ($alttag) {
1957: $alttag=&Apache::lonmeta::alttag
1958: ($Apache::lonxml::pwd[-1],$src);
1.51 sakharuk 1959: }
1.122 albertel 1960: $currentstring='[IMAGE: '.$alttag.']';
1.1 sakharuk 1961: }
1.122 albertel 1962: } elsif ($target eq 'tex') {
1963: $src=&Apache::lonnet::filelocation($Apache::lonxml::pwd[-1],$src);
1964: &image_replication($src);
1965:
1966: #if original gif/jpg/png file exist do following:
1967: if (-e $src) {
1968: #defines the default size of image
1969: my $image = Image::Magick->new;
1970: my $current_figure = $image->Read($src);
1971: $width_param = $image->Get('width') * $scaling;;
1972: $height_param = $image->Get('height') * $scaling;;
1973: undef $image;
1974: #do we have any specified size of the picture?
1975: my $TeXwidth = &Apache::lonxml::get_param('TeXwidth',$parstack,$safeeval);
1976: my $TeXheight = &Apache::lonxml::get_param('TeXheight',$parstack,$safeeval);
1977: my $width = &Apache::lonxml::get_param('width',$parstack,$safeeval,
1978: undef,1);
1979: if ($TeXwidth ne '') {
1980: if ($TeXwidth=~/(\d+)\s*\%/) {
1981: $width_param = $1*$ENV{'form.textwidth'}/100;
1982: } else {
1983: $width_param = $TeXwidth;
1984: }
1985: } elsif ($TeXheight ne '') {
1986: $width_param = $TeXheight/$height_param*$width_param;
1987: } elsif ($width ne '') {
1988: $width_param = $width*$scaling;
1989: }
1990: my $file;
1991: my $path;
1992: if ($src =~ m!(.*)/([^/]*)$!) {
1993: $file = $2;
1994: $path = $1.'/';
1995: }
1996: my $newsrc = $src;
1997: $newsrc =~ s/\.(gif|jpg|png)$/.eps/i;
1998: $file=~s/\.(gif|jpg|png)$/.eps/i;
1999: #where can we find the picture?
2000: if (-e $newsrc) {
2001: #eps counterpart for image exist
2002: if ($path) {
2003: $currentstring .= '\vskip 1 mm \noindent\graphicspath{{'.$path.'}}\includegraphics[width='.$width_param.' mm]{'.$file.'} ';
1.51 sakharuk 2004: }
1.122 albertel 2005: } else {
2006: #there is no eps counterpart for image - check for ps one
2007: $newsrc =~ s/\.eps$/\.ps/;
2008: if (-e $newsrc) {
2009: #ps counterpart for image exist
2010: $file =~ s/\.eps$/\.ps/;
2011: if ($path) {
2012: $currentstring .= '\vskip 1 mm \noindent\graphicspath{{'.$path.'}}\includegraphics[width='.$width_param.' mm]{'.$file.'} ';
2013: }
1.78 sakharuk 2014: } else {
1.122 albertel 2015: #there aren't eps or ps - so create eps
2016: my $temp_file;
2017: my $filename = "/home/httpd/prtspool/$ENV{'user.name'}_$ENV{'user.domain'}_printout.dat";
2018: $temp_file = Apache::File->new('>>'.$filename);
2019: print $temp_file "$src\n";
2020: $currentstring .= '\vskip 1 mm \graphicspath{{/home/httpd/prtspool/}}\includegraphics[width='.$width_param.' mm]{'.$file.'} ';
2021: }
2022: }
2023: } else {
2024: #original image file doesn't exist so check the alt attribute
2025: my $alt =
2026: &Apache::lonxml::get_param('alt',$parstack,$safeeval,undef,1);
2027: unless ($alt) {
2028: $alt=&Apache::lonmeta::alttag($Apache::lonxml::pwd[-1],$src);
2029: }
2030:
2031: if ($alt) {
2032: $currentstring .= ' '.$alt.' ';
2033: } else {
2034: #<allow> tag will care about replication
1.59 sakharuk 2035: }
2036: }
1.122 albertel 2037: }
2038: return $currentstring;
2039: }
2040:
2041: sub end_img {
2042: my ($target,$token) = @_;
2043: my $currentstring = '';
2044: if ($target eq 'web') {
2045: $currentstring = $token->[2];
2046: } elsif ($target eq 'tex') {
2047: $currentstring = '';
2048: }
2049: return $currentstring;
2050: }
2051:
2052: #-- <applet> tag
2053: sub start_applet {
2054: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
2055:
2056: my $code=&Apache::lonxml::get_param('code',$parstack,$safeeval,undef,1);
2057: $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=$code;
2058:
2059: my $archive=&Apache::lonxml::get_param('archive',$parstack,$safeeval,
2060: undef,1);
2061: $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=$archive;
2062:
2063: my $currentstring = '';
2064: if ($target eq 'web') {
2065: if ($ENV{'browser.appletsuppress'} ne 'on') {
2066: $currentstring = $token->[4];
2067: } else {
2068: my $alttag= &Apache::lonxml::get_param('alt',$parstack,
2069: $safeeval,undef,1);
2070: unless ($alttag) {
2071: $alttag=&Apache::lonmeta::alttag($Apache::lonxml::pwd[-1],
2072: $code);
1.44 sakharuk 2073: }
1.122 albertel 2074: $currentstring='[APPLET: '.$alttag.']';
1.1 sakharuk 2075: }
1.122 albertel 2076: } elsif ($target eq 'tex') {
2077: $currentstring = " \\begin{figure} ";
2078: }
2079: return $currentstring;
2080: }
2081:
2082: sub end_applet {
2083: my ($target,$token) = @_;
2084: my $currentstring = '';
2085: if ($target eq 'web') {
2086: $currentstring = $token->[2];
2087: } elsif ($target eq 'tex') {
2088: $currentstring = " \\end{figure}";
2089: }
2090: return $currentstring;
2091: }
2092:
2093: #-- <embed> tag
2094: sub start_embed {
2095: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
2096: my $src=&Apache::lonxml::get_param('src',$parstack,$safeeval,undef,1);
2097: $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=$src;
2098: my $currentstring = '';
2099: if ($target eq 'web') {
2100: if ($ENV{'browser.embedsuppress'} ne 'on') {
2101: $currentstring = $token->[4];
2102: } else {
2103: my $alttag=&Apache::lonxml::get_param
2104: ('alt',$parstack,$safeeval,undef,1);
2105: unless ($alttag) {
2106: $alttag=&Apache::lonmeta::alttag($Apache::lonxml::pwd[-1],$src);
1.42 albertel 2107: }
1.122 albertel 2108: $currentstring='[EMBED: '.$alttag.']';
1.10 www 2109: }
1.122 albertel 2110: } elsif ($target eq 'tex') {
2111: $currentstring = " \\begin{figure} ";
2112: }
2113: return $currentstring;
2114: }
2115:
2116: sub end_embed {
2117: my ($target,$token) = @_;
2118: my $currentstring = '';
2119: if ($target eq 'web') {
2120: $currentstring = $token->[2];
2121: } elsif ($target eq 'tex') {
2122: $currentstring = " \\end{figure}";
2123: }
2124: return $currentstring;
2125: }
2126:
2127: #-- <param> tag
2128: sub start_param {
2129: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
2130: if (&Apache::lonxml::get_param
2131: ('name',$parstack,$safeeval,undef,1)=~/^cabbase$/i) {
2132: $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=
2133: &Apache::lonxml::get_param('value',$parstack,$safeeval,undef,1);
2134: }
2135: $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=
2136: &Apache::lonxml::get_param('src',$parstack,$safeeval,undef,1);
2137: my $currentstring = '';
2138: if ($target eq 'web') {
2139: $currentstring = $token->[4];
2140: } elsif ($target eq 'tex') {
2141: $currentstring = " \\begin{figure} ";
2142: }
2143: return $currentstring;
2144: }
2145:
2146: sub end_param {
2147: my ($target,$token) = @_;
2148: my $currentstring = '';
2149: if ($target eq 'web') {
2150: $currentstring = $token->[2];
2151: } elsif ($target eq 'tex') {
2152: $currentstring = " \\end{figure}";
2153: }
2154: return $currentstring;
2155: }
2156:
2157: #-- <allow> tag
2158: sub start_allow {
2159: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
2160: my $src = &Apache::lonxml::get_param('src',$parstack,$safeeval,undef,1);
2161: $src=&Apache::lonnet::filelocation($Apache::lonxml::pwd[-1],$src);
2162: $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=$src;
2163: &image_replication($src);
2164: my $result;
2165: if ($target eq 'edit') {
2166: $result .=&Apache::edit::tag_start($target,$token);
2167: $result .=&Apache::edit::text_arg('File Spec:','src',$token,70);
2168: $result .=&Apache::edit::end_row();#.&Apache::edit::start_spanning_row();
2169: } elsif ($target eq 'modified') {
2170: my $constructtag=&Apache::edit::get_new_args($token,$parstack,
2171: $safeeval,'src');
2172: if ($constructtag) { $result = &Apache::edit::rebuild_tag($token); }
2173: }
2174: return $result;
2175: }
2176:
2177: sub end_allow {
2178: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
2179: if ( $target eq 'edit') { return (&Apache::edit::end_table()); }
2180: return '';
2181: }
1.119 www 2182:
1.122 albertel 2183: #-- Frames
2184: sub start_frameset {
2185: my ($target,$token) = @_;
2186: my $currentstring = '';
2187: if ($target eq 'web') {
2188: if (!$Apache::lonxml::registered) {
2189: $currentstring.='<head>'.
2190: &Apache::lonmenu::registerurl(undef,$target).'</head>';
1.10 www 2191: }
1.122 albertel 2192: $currentstring .= $token->[4];
2193: }
2194: return $currentstring;
2195: }
2196:
2197: sub end_frameset {
2198: my ($target,$token) = @_;
2199: my $currentstring = '';
2200: if ($target eq 'web') {
2201: $currentstring = $token->[2];
2202: }
2203: return $currentstring;
2204: }
2205:
2206: #-- <pre>
2207: sub start_pre {
2208: my ($target,$token) = @_;
2209: my $currentstring = '';
2210: if ($target eq 'web') {
2211: $currentstring .= $token->[4];
2212: } elsif ($target eq 'tex') {
2213: $currentstring .= '\begin{verbatim}';
2214: }
2215: return $currentstring;
2216: }
2217:
2218: sub end_pre {
2219: my ($target,$token) = @_;
2220: my $currentstring = '';
2221: if ($target eq 'web') {
2222: $currentstring .= $token->[2];
2223: } elsif ($target eq 'tex') {
2224: $currentstring .= '\end{verbatim}';
2225: }
2226: return $currentstring;
2227: }
2228:
2229: #-- <insert>
2230: sub start_insert {
2231: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
2232: my $currentstring = '';
2233: if ($target eq 'web') {
2234: my $display = &Apache::lonxml::get_param('display',$parstack,$safeeval,undef,1);
2235: $currentstring .= '<b>'.$display.'</b>';;
2236: }
2237: return $currentstring;
2238: }
2239:
2240: sub end_insert {
2241: my ($target,$token) = @_;
2242: my $currentstring = '';
2243: if ($target eq 'web') {
2244: $currentstring .= '';
2245: }
2246: return $currentstring;
2247: }
2248:
2249: #-- <externallink>
2250: sub start_externallink {
2251: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
2252: my $currentstring = '';
2253: if ($target eq 'web') {
2254: my $display = &Apache::lonxml::get_param('display',$parstack,$safeeval,undef,1);
2255: $currentstring .= '<b>'.$display.'</b>';;
2256: }
2257: return $currentstring;
2258: }
2259:
2260: sub end_externallink {
2261: my ($target,$token) = @_;
2262: my $currentstring = '';
2263: if ($target eq 'web') {
2264: $currentstring .= '';
2265: }
2266: return $currentstring;
2267: }
2268:
2269: #-- <blankspace heigth="">
2270: sub start_blankspace {
2271: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
2272: my $currentstring = '';
2273: if ($target eq 'tex') {
2274: my $howmuch = &Apache::lonxml::get_param('heigth',$parstack,$safeeval,undef,1);
2275: $currentstring .= '\vskip '.$howmuch.' ';
2276: }
2277: return $currentstring;
2278: }
2279:
2280: sub end_blankspace {
2281: my ($target,$token) = @_;
2282: my $currentstring = '';
2283: if ($target eq 'tex') {
2284: $currentstring .= '';
2285: }
2286: return $currentstring;
2287: }
2288:
2289: #-- <abbr> tag
2290: sub start_abbr {
2291: my ($target,$token) = @_;
2292: my $currentstring = '';
2293: if ($target eq 'web') {
2294: $currentstring = $token->[4];
2295: }
2296: return $currentstring;
2297: }
2298:
2299: sub end_abbr {
2300: my ($target,$token) = @_;
2301: my $currentstring = '';
2302: if ($target eq 'web') {
2303: $currentstring = $token->[2];
2304: }
2305: return $currentstring;
2306: }
2307:
2308: #-- <acronym> tag
2309: sub start_acronym {
2310: my ($target,$token) = @_;
2311: my $currentstring = '';
2312: if ($target eq 'web') {
2313: $currentstring = $token->[4];
2314: }
2315: return $currentstring;
2316: }
2317:
2318: sub end_acronym {
2319: my ($target,$token) = @_;
2320: my $currentstring = '';
2321: if ($target eq 'web') {
2322: $currentstring = $token->[2];
2323: }
2324: return $currentstring;
2325: }
2326:
2327: #-- <area> tag
2328: sub start_area {
2329: my ($target,$token) = @_;
2330: my $currentstring = '';
2331: if ($target eq 'web') {
2332: $currentstring = $token->[4];
2333: }
2334: return $currentstring;
2335: }
2336:
2337: sub end_area {
2338: my ($target,$token) = @_;
2339: my $currentstring = '';
2340: if ($target eq 'web') {
2341: $currentstring = $token->[2];
2342: }
2343: return $currentstring;
2344: }
2345:
2346: #-- <base> tag
2347: sub start_base {
2348: my ($target,$token) = @_;
2349: my $currentstring = '';
2350: if ($target eq 'web') {
2351: $currentstring = $token->[4];
2352: }
2353: return $currentstring;
2354: }
2355:
2356: sub end_base {
2357: my ($target,$token) = @_;
2358: my $currentstring = '';
2359: if ($target eq 'web') {
2360: $currentstring = $token->[2];
2361: }
2362: return $currentstring;
2363: }
2364:
2365: #-- <bdo> tag
2366: sub start_bdo {
2367: my ($target,$token) = @_;
2368: my $currentstring = '';
2369: if ($target eq 'web') {
2370: $currentstring = $token->[4];
2371: }
2372: return $currentstring;
2373: }
2374:
2375: sub end_bdo {
2376: my ($target,$token) = @_;
2377: my $currentstring = '';
2378: if ($target eq 'web') {
2379: $currentstring = $token->[2];
2380: }
2381: return $currentstring;
2382: }
2383:
2384: #-- <bgsound> tag
2385: sub start_bgsound {
2386: my ($target,$token) = @_;
2387: my $currentstring = '';
2388: if ($target eq 'web') {
2389: $currentstring = $token->[4];
2390: }
2391: return $currentstring;
2392: }
2393:
2394: sub end_bgsound {
2395: my ($target,$token) = @_;
2396: my $currentstring = '';
2397: if ($target eq 'web') {
2398: $currentstring = $token->[2];
2399: }
2400: return $currentstring;
2401: }
2402:
2403: #-- <blink> tag
2404: sub start_blink {
2405: my ($target,$token) = @_;
2406: my $currentstring = '';
2407: if ($target eq 'web') {
2408: $currentstring = $token->[4];
2409: }
2410: return $currentstring;
2411: }
2412:
2413: sub end_blink {
2414: my ($target,$token) = @_;
2415: my $currentstring = '';
2416: if ($target eq 'web') {
2417: $currentstring = $token->[2];
2418: }
2419: return $currentstring;
2420: }
2421:
2422: #-- <blockquote> tag
2423: sub start_blockquote {
2424: my ($target,$token) = @_;
2425: my $currentstring = '';
2426: if ($target eq 'web') {
2427: $currentstring = $token->[4];
2428: }
2429: return $currentstring;
2430: }
2431:
2432: sub end_blockquote {
2433: my ($target,$token) = @_;
2434: my $currentstring = '';
2435: if ($target eq 'web') {
2436: $currentstring = $token->[2];
2437: }
2438: return $currentstring;
2439: }
2440:
2441: #-- <button> tag
2442: sub start_button {
2443: my ($target,$token) = @_;
2444: my $currentstring = '';
2445: if ($target eq 'web') {
2446: $currentstring = $token->[4];
2447: }
2448: return $currentstring;
2449: }
2450:
2451: sub end_button {
2452: my ($target,$token) = @_;
2453: my $currentstring = '';
2454: if ($target eq 'web') {
2455: $currentstring = $token->[2];
2456: }
2457: return $currentstring;
2458: }
2459:
2460: #-- <caption> tag
2461: sub start_caption {
2462: my ($target,$token) = @_;
2463: my $currentstring = '';
2464: if ($target eq 'web') {
2465: $currentstring = $token->[4];
2466: }
2467: return $currentstring;
2468: }
2469:
2470: sub end_caption {
2471: my ($target,$token) = @_;
2472: my $currentstring = '';
2473: if ($target eq 'web') {
2474: $currentstring = $token->[2];
2475: }
2476: return $currentstring;
2477: }
2478:
2479: #-- <col> tag
2480: sub start_col {
2481: my ($target,$token) = @_;
2482: my $currentstring = '';
2483: if ($target eq 'web') {
2484: $currentstring = $token->[4];
2485: }
2486: return $currentstring;
2487: }
2488:
2489: sub end_col {
2490: my ($target,$token) = @_;
2491: my $currentstring = '';
2492: if ($target eq 'web') {
2493: $currentstring = $token->[2];
2494: }
2495: return $currentstring;
2496: }
2497:
2498: #-- <colgroup> tag
2499: sub start_colgroup {
2500: my ($target,$token) = @_;
2501: my $currentstring = '';
2502: if ($target eq 'web') {
2503: $currentstring = $token->[4];
2504: }
2505: return $currentstring;
2506: }
2507:
2508: sub end_colgroup {
2509: my ($target,$token) = @_;
2510: my $currentstring = '';
2511: if ($target eq 'web') {
2512: $currentstring = $token->[2];
2513: }
2514: return $currentstring;
2515: }
2516:
2517: #-- <del> tag
2518: sub start_del {
2519: my ($target,$token) = @_;
2520: my $currentstring = '';
2521: if ($target eq 'web') {
2522: $currentstring = $token->[4];
2523: }
2524: return $currentstring;
2525: }
2526:
2527: sub end_del {
2528: my ($target,$token) = @_;
2529: my $currentstring = '';
2530: if ($target eq 'web') {
2531: $currentstring = $token->[2];
2532: }
2533: return $currentstring;
2534: }
2535:
2536: #-- <fieldset> tag
2537: sub start_fieldset {
2538: my ($target,$token) = @_;
2539: my $currentstring = '';
2540: if ($target eq 'web') {
2541: $currentstring = $token->[4];
2542: }
2543: return $currentstring;
2544: }
2545:
2546: sub end_fieldset {
2547: my ($target,$token) = @_;
2548: my $currentstring = '';
2549: if ($target eq 'web') {
2550: $currentstring = $token->[2];
2551: }
2552: return $currentstring;
2553: }
2554:
2555: #-- <frame> tag
2556: sub start_frame {
2557: my ($target,$token) = @_;
2558: my $currentstring = '';
2559: if ($target eq 'web') {
2560: $currentstring = $token->[4];
2561: }
2562: return $currentstring;
2563: }
2564:
2565: sub end_frame {
2566: my ($target,$token) = @_;
2567: my $currentstring = '';
2568: if ($target eq 'web') {
2569: $currentstring = $token->[2];
2570: }
2571: return $currentstring;
2572: }
2573:
2574: #-- <iframe> tag
2575: sub start_iframe {
2576: my ($target,$token) = @_;
2577: my $currentstring = '';
2578: if ($target eq 'web') {
2579: $currentstring = $token->[4];
2580: }
2581: return $currentstring;
2582: }
2583:
2584: sub end_iframe {
2585: my ($target,$token) = @_;
2586: my $currentstring = '';
2587: if ($target eq 'web') {
2588: $currentstring = $token->[2];
2589: }
2590: return $currentstring;
2591: }
2592:
2593: #-- <ins> tag
2594: sub start_ins {
2595: my ($target,$token) = @_;
2596: my $currentstring = '';
2597: if ($target eq 'web') {
2598: $currentstring = $token->[4];
2599: }
2600: return $currentstring;
2601: }
2602:
2603: sub end_ins {
2604: my ($target,$token) = @_;
2605: my $currentstring = '';
2606: if ($target eq 'web') {
2607: $currentstring = $token->[2];
2608: }
2609: return $currentstring;
2610: }
2611:
2612: #-- <isindex> tag
2613: sub start_isindex {
2614: my ($target,$token) = @_;
2615: my $currentstring = '';
2616: if ($target eq 'web') {
2617: $currentstring = $token->[4];
2618: }
2619: return $currentstring;
2620: }
2621:
2622: sub end_isindex {
2623: my ($target,$token) = @_;
2624: my $currentstring = '';
2625: if ($target eq 'web') {
2626: $currentstring = $token->[2];
2627: }
2628: return $currentstring;
2629: }
2630:
2631: #-- <keygen> tag
2632: sub start_keygen {
2633: my ($target,$token) = @_;
2634: my $currentstring = '';
2635: if ($target eq 'web') {
2636: $currentstring = $token->[4];
2637: }
2638: return $currentstring;
2639: }
2640:
2641: sub end_keygen {
2642: my ($target,$token) = @_;
2643: my $currentstring = '';
2644: if ($target eq 'web') {
2645: $currentstring = $token->[2];
2646: }
2647: return $currentstring;
2648: }
2649:
2650: #-- <label> tag
2651: sub start_label {
2652: my ($target,$token) = @_;
2653: my $currentstring = '';
2654: if ($target eq 'web') {
2655: $currentstring = $token->[4];
2656: }
2657: return $currentstring;
2658: }
2659:
2660: sub end_label {
2661: my ($target,$token) = @_;
2662: my $currentstring = '';
2663: if ($target eq 'web') {
2664: $currentstring = $token->[2];
2665: }
2666: return $currentstring;
2667: }
2668:
2669: #-- <layer> tag
2670: sub start_layer {
2671: my ($target,$token) = @_;
2672: my $currentstring = '';
2673: if ($target eq 'web') {
2674: $currentstring = $token->[4];
2675: }
2676: return $currentstring;
2677: }
2678:
2679: sub end_layer {
2680: my ($target,$token) = @_;
2681: my $currentstring = '';
2682: if ($target eq 'web') {
2683: $currentstring = $token->[2];
2684: }
2685: return $currentstring;
2686: }
2687:
2688: #-- <legend> tag
2689: sub start_legend {
2690: my ($target,$token) = @_;
2691: my $currentstring = '';
2692: if ($target eq 'web') {
2693: $currentstring = $token->[4];
2694: }
2695: return $currentstring;
2696: }
2697:
2698: sub end_legend {
2699: my ($target,$token) = @_;
2700: my $currentstring = '';
2701: if ($target eq 'web') {
2702: $currentstring = $token->[2];
2703: }
2704: return $currentstring;
2705: }
2706:
2707: #-- <link> tag
2708: sub start_link {
2709: my ($target,$token) = @_;
2710: my $currentstring = '';
2711: if ($target eq 'web') {
2712: $currentstring = $token->[4];
2713: }
2714: return $currentstring;
2715: }
2716:
2717: sub end_link {
2718: my ($target,$token) = @_;
2719: my $currentstring = '';
2720: if ($target eq 'web') {
2721: $currentstring = $token->[2];
2722: }
2723: return $currentstring;
2724: }
2725:
2726: #-- <marquee> tag
2727: sub start_marquee {
2728: my ($target,$token) = @_;
2729: my $currentstring = '';
2730: if ($target eq 'web') {
2731: $currentstring = $token->[4];
2732: }
2733: return $currentstring;
2734: }
2735:
2736: sub end_marquee {
2737: my ($target,$token) = @_;
2738: my $currentstring = '';
2739: if ($target eq 'web') {
2740: $currentstring = $token->[2];
2741: }
2742: return $currentstring;
2743: }
2744:
2745: #-- <malticol> tag
2746: sub start_malticol {
2747: my ($target,$token) = @_;
2748: my $currentstring = '';
2749: if ($target eq 'web') {
2750: $currentstring = $token->[4];
2751: }
2752: return $currentstring;
2753: }
2754:
2755: sub end_malticol {
2756: my ($target,$token) = @_;
2757: my $currentstring = '';
2758: if ($target eq 'web') {
2759: $currentstring = $token->[2];
2760: }
2761: return $currentstring;
2762: }
2763:
2764: #-- <nobr> tag
2765: sub start_nobr {
2766: my ($target,$token) = @_;
2767: my $currentstring = '';
2768: if ($target eq 'web') {
2769: $currentstring = $token->[4];
2770: }
2771: return $currentstring;
2772: }
2773:
2774: sub end_nobr {
2775: my ($target,$token) = @_;
2776: my $currentstring = '';
2777: if ($target eq 'web') {
2778: $currentstring = $token->[2];
2779: }
2780: return $currentstring;
2781: }
2782:
2783: #-- <noembed> tag
2784: sub start_noembed {
2785: my ($target,$token) = @_;
2786: my $currentstring = '';
2787: if ($target eq 'web') {
2788: $currentstring = $token->[4];
2789: }
2790: return $currentstring;
2791: }
2792:
2793: sub end_noembed {
2794: my ($target,$token) = @_;
2795: my $currentstring = '';
2796: if ($target eq 'web') {
2797: $currentstring = $token->[2];
2798: }
2799: return $currentstring;
2800: }
2801:
2802: #-- <noframes> tag
2803: sub start_noframes {
2804: my ($target,$token) = @_;
2805: my $currentstring = '';
2806: if ($target eq 'web') {
2807: $currentstring = $token->[4];
2808: }
2809: return $currentstring;
2810: }
2811:
2812: sub end_noframes {
2813: my ($target,$token) = @_;
2814: my $currentstring = '';
2815: if ($target eq 'web') {
2816: $currentstring = $token->[2];
2817: }
2818: return $currentstring;
2819: }
2820:
2821: #-- <nolayer> tag
2822: sub start_nolayer {
2823: my ($target,$token) = @_;
2824: my $currentstring = '';
2825: if ($target eq 'web') {
2826: $currentstring = $token->[4];
2827: }
2828: return $currentstring;
2829: }
2830:
2831: sub end_nolayer {
2832: my ($target,$token) = @_;
2833: my $currentstring = '';
2834: if ($target eq 'web') {
2835: $currentstring = $token->[2];
2836: }
2837: return $currentstring;
2838: }
2839:
2840: #-- <noscript> tag
2841: sub start_noscript {
2842: my ($target,$token) = @_;
2843: my $currentstring = '';
2844: if ($target eq 'web') {
2845: $currentstring = $token->[4];
2846: }
2847: return $currentstring;
2848: }
2849:
2850: sub end_noscript {
2851: my ($target,$token) = @_;
2852: my $currentstring = '';
2853: if ($target eq 'web') {
2854: $currentstring = $token->[2];
2855: }
2856: return $currentstring;
2857: }
2858:
2859: #-- <object> tag
2860: sub start_object {
2861: my ($target,$token) = @_;
2862: my $currentstring = '';
2863: if ($target eq 'web') {
2864: $currentstring = $token->[4];
2865: }
2866: return $currentstring;
2867: }
2868:
2869: sub end_object {
2870: my ($target,$token) = @_;
2871: my $currentstring = '';
2872: if ($target eq 'web') {
2873: $currentstring = $token->[2];
2874: }
2875: return $currentstring;
2876: }
2877:
2878: #-- <optgroup> tag
2879: sub start_optgroup {
2880: my ($target,$token) = @_;
2881: my $currentstring = '';
2882: if ($target eq 'web') {
2883: $currentstring = $token->[4];
2884: }
2885: return $currentstring;
2886: }
2887:
2888: sub end_optgroup {
2889: my ($target,$token) = @_;
2890: my $currentstring = '';
2891: if ($target eq 'web') {
2892: $currentstring = $token->[2];
2893: }
2894: return $currentstring;
2895: }
2896:
2897: #-- <samp> tag
2898: sub start_samp {
2899: my ($target,$token) = @_;
2900: my $currentstring = '';
2901: if ($target eq 'web') {
2902: $currentstring = $token->[4];
2903: }
2904: return $currentstring;
2905: }
2906:
2907: sub end_samp {
2908: my ($target,$token) = @_;
2909: my $currentstring = '';
2910: if ($target eq 'web') {
2911: $currentstring = $token->[2];
2912: }
2913: return $currentstring;
2914: }
2915:
2916: #-- <server> tag
2917: sub start_server {
2918: my ($target,$token) = @_;
2919: my $currentstring = '';
2920: if ($target eq 'web') {
2921: $currentstring = $token->[4];
2922: }
2923: return $currentstring;
2924: }
2925:
2926: sub end_server {
2927: my ($target,$token) = @_;
2928: my $currentstring = '';
2929: if ($target eq 'web') {
2930: $currentstring = $token->[2];
2931: }
2932: return $currentstring;
2933: }
2934:
2935: #-- <spacer> tag
2936: sub start_spacer {
2937: my ($target,$token) = @_;
2938: my $currentstring = '';
2939: if ($target eq 'web') {
2940: $currentstring = $token->[4];
2941: }
2942: return $currentstring;
2943: }
2944:
2945: sub end_spacer {
2946: my ($target,$token) = @_;
2947: my $currentstring = '';
2948: if ($target eq 'web') {
2949: $currentstring = $token->[2];
2950: }
2951: return $currentstring;
2952: }
2953:
2954: #-- <span> tag
2955: sub start_span {
2956: my ($target,$token) = @_;
2957: my $currentstring = '';
2958: if ($target eq 'web') {
2959: $currentstring = $token->[4];
2960: }
2961: return $currentstring;
2962: }
2963:
2964: sub end_span {
2965: my ($target,$token) = @_;
2966: my $currentstring = '';
2967: if ($target eq 'web') {
2968: $currentstring = $token->[2];
2969: }
2970: return $currentstring;
2971: }
2972:
2973: #-- <tbody> tag
2974: sub start_tbody {
2975: my ($target,$token) = @_;
2976: my $currentstring = '';
2977: if ($target eq 'web') {
2978: $currentstring = $token->[4];
2979: }
2980: return $currentstring;
2981: }
2982:
2983: sub end_tbody {
2984: my ($target,$token) = @_;
2985: my $currentstring = '';
2986: if ($target eq 'web') {
2987: $currentstring = $token->[2];
2988: }
2989: return $currentstring;
2990: }
2991:
2992: #-- <tfoot> tag
2993: sub start_tfoot {
2994: my ($target,$token) = @_;
2995: my $currentstring = '';
2996: if ($target eq 'web') {
2997: $currentstring = $token->[4];
2998: }
2999: return $currentstring;
3000: }
3001:
3002: sub end_tfoot {
3003: my ($target,$token) = @_;
3004: my $currentstring = '';
3005: if ($target eq 'web') {
3006: $currentstring = $token->[2];
3007: }
3008: return $currentstring;
3009: }
3010:
3011: #-- <thead> tag
3012: sub start_thead {
3013: my ($target,$token) = @_;
3014: my $currentstring = '';
3015: if ($target eq 'web') {
3016: $currentstring = $token->[4];
3017: }
3018: return $currentstring;
3019: }
1.10 www 3020:
1.122 albertel 3021: sub end_thead {
3022: my ($target,$token) = @_;
3023: my $currentstring = '';
3024: if ($target eq 'web') {
3025: $currentstring = $token->[2];
3026: }
3027: return $currentstring;
3028: }
1.119 www 3029:
1.122 albertel 3030: #-- <var> tag
3031: sub start_var {
1.44 sakharuk 3032: my ($target,$token) = @_;
3033: my $currentstring = '';
3034: if ($target eq 'web') {
1.122 albertel 3035: $currentstring = $token->[4];
1.44 sakharuk 3036: }
3037: return $currentstring;
3038: }
1.10 www 3039:
1.122 albertel 3040: sub end_var {
3041: my ($target,$token) = @_;
1.44 sakharuk 3042: my $currentstring = '';
3043: if ($target eq 'web') {
1.122 albertel 3044: $currentstring = $token->[2];
1.44 sakharuk 3045: }
3046: return $currentstring;
3047: }
1.119 www 3048:
1.122 albertel 3049: #-- <wbr> tag
3050: sub start_wbr {
3051: my ($target,$token) = @_;
3052: my $currentstring = '';
3053: if ($target eq 'web') {
3054: $currentstring = $token->[4];
3055: }
3056: return $currentstring;
1.98 albertel 3057: }
3058:
1.122 albertel 3059: sub end_wbr {
3060: my ($target,$token) = @_;
3061: my $currentstring = '';
3062: if ($target eq 'web') {
3063: $currentstring = $token->[2];
3064: }
3065: return $currentstring;
1.98 albertel 3066: }
1.94 sakharuk 3067:
3068: sub image_replication {
3069: my $src = shift;
1.118 www 3070: if (not -e $src) {
1.94 sakharuk 3071: #replicates image itself
1.118 www 3072: &Apache::lonnet::repcopy($src);
1.94 sakharuk 3073: #replicates eps or ps
3074: my $newsrc = $src;
1.118 www 3075: $newsrc =~ s/\.(gif|jpg|jpeg|png)$/.eps/i;
3076: if (not -e $newsrc) {
1.122 albertel 3077: if (&Apache::lonnet::repcopy($newsrc) ne 'OK') {
3078: $newsrc =~ s/\.eps$/\.ps/;
3079: &Apache::lonnet::repcopy($newsrc);
3080: }
1.94 sakharuk 3081: }
3082: }
3083: return '';
3084: }
3085:
1.1 sakharuk 3086: 1;
3087: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>