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