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