Annotation of loncom/xml/londefdef.pm, revision 1.163
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: #-- <pre>
2322: sub start_pre {
1.126 sakharuk 2323: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1.122 albertel 2324: my $currentstring = '';
2325: if ($target eq 'web') {
2326: $currentstring .= $token->[4];
2327: } elsif ($target eq 'tex') {
1.136 sakharuk 2328: $currentstring .= '\begin{verbatim}';
1.122 albertel 2329: }
2330: return $currentstring;
2331: }
2332:
2333: sub end_pre {
2334: my ($target,$token) = @_;
2335: my $currentstring = '';
2336: if ($target eq 'web') {
2337: $currentstring .= $token->[2];
2338: } elsif ($target eq 'tex') {
1.136 sakharuk 2339: $currentstring .= '\end{verbatim}';
1.122 albertel 2340: }
2341: return $currentstring;
2342: }
2343:
2344: #-- <insert>
2345: sub start_insert {
2346: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
2347: my $currentstring = '';
2348: if ($target eq 'web') {
2349: my $display = &Apache::lonxml::get_param('display',$parstack,$safeeval,undef,1);
2350: $currentstring .= '<b>'.$display.'</b>';;
2351: }
2352: return $currentstring;
2353: }
2354:
2355: sub end_insert {
2356: my ($target,$token) = @_;
2357: my $currentstring = '';
2358: if ($target eq 'web') {
2359: $currentstring .= '';
2360: }
2361: return $currentstring;
2362: }
2363:
2364: #-- <externallink>
2365: sub start_externallink {
2366: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
2367: my $currentstring = '';
2368: if ($target eq 'web') {
2369: my $display = &Apache::lonxml::get_param('display',$parstack,$safeeval,undef,1);
2370: $currentstring .= '<b>'.$display.'</b>';;
2371: }
2372: return $currentstring;
2373: }
2374:
2375: sub end_externallink {
2376: my ($target,$token) = @_;
2377: my $currentstring = '';
2378: if ($target eq 'web') {
2379: $currentstring .= '';
2380: }
2381: return $currentstring;
2382: }
2383:
2384: #-- <blankspace heigth="">
2385: sub start_blankspace {
2386: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
2387: my $currentstring = '';
2388: if ($target eq 'tex') {
2389: my $howmuch = &Apache::lonxml::get_param('heigth',$parstack,$safeeval,undef,1);
2390: $currentstring .= '\vskip '.$howmuch.' ';
2391: }
2392: return $currentstring;
2393: }
2394:
2395: sub end_blankspace {
2396: my ($target,$token) = @_;
2397: my $currentstring = '';
2398: if ($target eq 'tex') {
2399: $currentstring .= '';
2400: }
2401: return $currentstring;
2402: }
2403:
2404: #-- <abbr> tag
2405: sub start_abbr {
2406: my ($target,$token) = @_;
2407: my $currentstring = '';
2408: if ($target eq 'web') {
2409: $currentstring = $token->[4];
2410: }
2411: return $currentstring;
2412: }
2413:
2414: sub end_abbr {
2415: my ($target,$token) = @_;
2416: my $currentstring = '';
2417: if ($target eq 'web') {
2418: $currentstring = $token->[2];
2419: }
2420: return $currentstring;
2421: }
2422:
2423: #-- <acronym> tag
2424: sub start_acronym {
2425: my ($target,$token) = @_;
2426: my $currentstring = '';
2427: if ($target eq 'web') {
2428: $currentstring = $token->[4];
2429: }
2430: return $currentstring;
2431: }
2432:
2433: sub end_acronym {
2434: my ($target,$token) = @_;
2435: my $currentstring = '';
2436: if ($target eq 'web') {
2437: $currentstring = $token->[2];
2438: }
2439: return $currentstring;
2440: }
2441:
2442: #-- <area> tag
2443: sub start_area {
2444: my ($target,$token) = @_;
2445: my $currentstring = '';
2446: if ($target eq 'web') {
2447: $currentstring = $token->[4];
2448: }
2449: return $currentstring;
2450: }
2451:
2452: sub end_area {
2453: my ($target,$token) = @_;
2454: my $currentstring = '';
2455: if ($target eq 'web') {
2456: $currentstring = $token->[2];
2457: }
2458: return $currentstring;
2459: }
2460:
2461: #-- <base> tag
2462: sub start_base {
2463: my ($target,$token) = @_;
2464: my $currentstring = '';
2465: if ($target eq 'web') {
2466: $currentstring = $token->[4];
1.161 sakharuk 2467: }
1.122 albertel 2468: return $currentstring;
2469: }
2470:
2471: sub end_base {
2472: my ($target,$token) = @_;
2473: my $currentstring = '';
2474: if ($target eq 'web') {
2475: $currentstring = $token->[2];
2476: }
2477: return $currentstring;
2478: }
2479:
2480: #-- <bdo> tag
2481: sub start_bdo {
2482: my ($target,$token) = @_;
2483: my $currentstring = '';
2484: if ($target eq 'web') {
2485: $currentstring = $token->[4];
2486: }
2487: return $currentstring;
2488: }
2489:
2490: sub end_bdo {
2491: my ($target,$token) = @_;
2492: my $currentstring = '';
2493: if ($target eq 'web') {
2494: $currentstring = $token->[2];
2495: }
2496: return $currentstring;
2497: }
2498:
2499: #-- <bgsound> tag
2500: sub start_bgsound {
2501: my ($target,$token) = @_;
2502: my $currentstring = '';
2503: if ($target eq 'web') {
2504: $currentstring = $token->[4];
2505: }
2506: return $currentstring;
2507: }
2508:
2509: sub end_bgsound {
2510: my ($target,$token) = @_;
2511: my $currentstring = '';
2512: if ($target eq 'web') {
2513: $currentstring = $token->[2];
2514: }
2515: return $currentstring;
2516: }
2517:
2518: #-- <blink> tag
2519: sub start_blink {
2520: my ($target,$token) = @_;
2521: my $currentstring = '';
2522: if ($target eq 'web') {
2523: $currentstring = $token->[4];
2524: }
2525: return $currentstring;
2526: }
2527:
2528: sub end_blink {
2529: my ($target,$token) = @_;
2530: my $currentstring = '';
2531: if ($target eq 'web') {
2532: $currentstring = $token->[2];
2533: }
2534: return $currentstring;
2535: }
2536:
2537: #-- <blockquote> tag
2538: sub start_blockquote {
2539: my ($target,$token) = @_;
2540: my $currentstring = '';
2541: if ($target eq 'web') {
2542: $currentstring = $token->[4];
2543: }
2544: return $currentstring;
2545: }
2546:
2547: sub end_blockquote {
2548: my ($target,$token) = @_;
2549: my $currentstring = '';
2550: if ($target eq 'web') {
2551: $currentstring = $token->[2];
2552: }
2553: return $currentstring;
2554: }
2555:
2556: #-- <button> tag
2557: sub start_button {
2558: my ($target,$token) = @_;
2559: my $currentstring = '';
2560: if ($target eq 'web') {
2561: $currentstring = $token->[4];
2562: }
2563: return $currentstring;
2564: }
2565:
2566: sub end_button {
2567: my ($target,$token) = @_;
2568: my $currentstring = '';
2569: if ($target eq 'web') {
2570: $currentstring = $token->[2];
2571: }
2572: return $currentstring;
2573: }
2574:
2575: #-- <caption> tag
2576: sub start_caption {
2577: my ($target,$token) = @_;
2578: my $currentstring = '';
2579: if ($target eq 'web') {
2580: $currentstring = $token->[4];
2581: }
2582: return $currentstring;
2583: }
2584:
2585: sub end_caption {
2586: my ($target,$token) = @_;
2587: my $currentstring = '';
2588: if ($target eq 'web') {
2589: $currentstring = $token->[2];
2590: }
2591: return $currentstring;
2592: }
2593:
2594: #-- <col> tag
2595: sub start_col {
2596: my ($target,$token) = @_;
2597: my $currentstring = '';
2598: if ($target eq 'web') {
2599: $currentstring = $token->[4];
2600: }
2601: return $currentstring;
2602: }
2603:
2604: sub end_col {
2605: my ($target,$token) = @_;
2606: my $currentstring = '';
2607: if ($target eq 'web') {
2608: $currentstring = $token->[2];
2609: }
2610: return $currentstring;
2611: }
2612:
2613: #-- <colgroup> tag
2614: sub start_colgroup {
2615: my ($target,$token) = @_;
2616: my $currentstring = '';
2617: if ($target eq 'web') {
2618: $currentstring = $token->[4];
2619: }
2620: return $currentstring;
2621: }
2622:
2623: sub end_colgroup {
2624: my ($target,$token) = @_;
2625: my $currentstring = '';
2626: if ($target eq 'web') {
2627: $currentstring = $token->[2];
2628: }
2629: return $currentstring;
2630: }
2631:
2632: #-- <del> tag
2633: sub start_del {
2634: my ($target,$token) = @_;
2635: my $currentstring = '';
2636: if ($target eq 'web') {
2637: $currentstring = $token->[4];
2638: }
2639: return $currentstring;
2640: }
2641:
2642: sub end_del {
2643: my ($target,$token) = @_;
2644: my $currentstring = '';
2645: if ($target eq 'web') {
2646: $currentstring = $token->[2];
2647: }
2648: return $currentstring;
2649: }
2650:
2651: #-- <fieldset> tag
2652: sub start_fieldset {
2653: my ($target,$token) = @_;
2654: my $currentstring = '';
2655: if ($target eq 'web') {
2656: $currentstring = $token->[4];
2657: }
2658: return $currentstring;
2659: }
2660:
2661: sub end_fieldset {
2662: my ($target,$token) = @_;
2663: my $currentstring = '';
2664: if ($target eq 'web') {
2665: $currentstring = $token->[2];
2666: }
2667: return $currentstring;
2668: }
2669:
2670: #-- <frame> tag
2671: sub start_frame {
2672: my ($target,$token) = @_;
2673: my $currentstring = '';
2674: if ($target eq 'web') {
2675: $currentstring = $token->[4];
2676: }
2677: return $currentstring;
2678: }
2679:
2680: sub end_frame {
2681: my ($target,$token) = @_;
2682: my $currentstring = '';
2683: if ($target eq 'web') {
2684: $currentstring = $token->[2];
2685: }
2686: return $currentstring;
2687: }
2688:
2689: #-- <iframe> tag
2690: sub start_iframe {
2691: my ($target,$token) = @_;
2692: my $currentstring = '';
2693: if ($target eq 'web') {
2694: $currentstring = $token->[4];
2695: }
2696: return $currentstring;
2697: }
2698:
2699: sub end_iframe {
2700: my ($target,$token) = @_;
2701: my $currentstring = '';
2702: if ($target eq 'web') {
2703: $currentstring = $token->[2];
2704: }
2705: return $currentstring;
2706: }
2707:
2708: #-- <ins> tag
2709: sub start_ins {
2710: my ($target,$token) = @_;
2711: my $currentstring = '';
2712: if ($target eq 'web') {
2713: $currentstring = $token->[4];
2714: }
2715: return $currentstring;
2716: }
2717:
2718: sub end_ins {
2719: my ($target,$token) = @_;
2720: my $currentstring = '';
2721: if ($target eq 'web') {
2722: $currentstring = $token->[2];
2723: }
2724: return $currentstring;
2725: }
2726:
2727: #-- <isindex> tag
2728: sub start_isindex {
2729: my ($target,$token) = @_;
2730: my $currentstring = '';
2731: if ($target eq 'web') {
2732: $currentstring = $token->[4];
2733: }
2734: return $currentstring;
2735: }
2736:
2737: sub end_isindex {
2738: my ($target,$token) = @_;
2739: my $currentstring = '';
2740: if ($target eq 'web') {
2741: $currentstring = $token->[2];
2742: }
2743: return $currentstring;
2744: }
2745:
2746: #-- <keygen> tag
2747: sub start_keygen {
2748: my ($target,$token) = @_;
2749: my $currentstring = '';
2750: if ($target eq 'web') {
2751: $currentstring = $token->[4];
2752: }
2753: return $currentstring;
2754: }
2755:
2756: sub end_keygen {
2757: my ($target,$token) = @_;
2758: my $currentstring = '';
2759: if ($target eq 'web') {
2760: $currentstring = $token->[2];
2761: }
2762: return $currentstring;
2763: }
2764:
2765: #-- <label> tag
2766: sub start_label {
2767: my ($target,$token) = @_;
2768: my $currentstring = '';
2769: if ($target eq 'web') {
2770: $currentstring = $token->[4];
2771: }
2772: return $currentstring;
2773: }
2774:
2775: sub end_label {
2776: my ($target,$token) = @_;
2777: my $currentstring = '';
2778: if ($target eq 'web') {
2779: $currentstring = $token->[2];
2780: }
2781: return $currentstring;
2782: }
2783:
2784: #-- <layer> tag
2785: sub start_layer {
2786: my ($target,$token) = @_;
2787: my $currentstring = '';
2788: if ($target eq 'web') {
2789: $currentstring = $token->[4];
2790: }
2791: return $currentstring;
2792: }
2793:
2794: sub end_layer {
2795: my ($target,$token) = @_;
2796: my $currentstring = '';
2797: if ($target eq 'web') {
2798: $currentstring = $token->[2];
2799: }
2800: return $currentstring;
2801: }
2802:
2803: #-- <legend> tag
2804: sub start_legend {
2805: my ($target,$token) = @_;
2806: my $currentstring = '';
2807: if ($target eq 'web') {
2808: $currentstring = $token->[4];
2809: }
2810: return $currentstring;
2811: }
2812:
2813: sub end_legend {
2814: my ($target,$token) = @_;
2815: my $currentstring = '';
2816: if ($target eq 'web') {
2817: $currentstring = $token->[2];
2818: }
2819: return $currentstring;
2820: }
2821:
2822: #-- <link> tag
2823: sub start_link {
2824: my ($target,$token) = @_;
2825: my $currentstring = '';
2826: if ($target eq 'web') {
2827: $currentstring = $token->[4];
2828: }
2829: return $currentstring;
2830: }
2831:
2832: sub end_link {
2833: my ($target,$token) = @_;
2834: my $currentstring = '';
2835: if ($target eq 'web') {
2836: $currentstring = $token->[2];
2837: }
2838: return $currentstring;
2839: }
2840:
2841: #-- <marquee> tag
2842: sub start_marquee {
2843: my ($target,$token) = @_;
2844: my $currentstring = '';
2845: if ($target eq 'web') {
2846: $currentstring = $token->[4];
2847: }
2848: return $currentstring;
2849: }
2850:
2851: sub end_marquee {
2852: my ($target,$token) = @_;
2853: my $currentstring = '';
2854: if ($target eq 'web') {
2855: $currentstring = $token->[2];
2856: }
2857: return $currentstring;
2858: }
2859:
2860: #-- <malticol> tag
2861: sub start_malticol {
2862: my ($target,$token) = @_;
2863: my $currentstring = '';
2864: if ($target eq 'web') {
2865: $currentstring = $token->[4];
2866: }
2867: return $currentstring;
2868: }
2869:
2870: sub end_malticol {
2871: my ($target,$token) = @_;
2872: my $currentstring = '';
2873: if ($target eq 'web') {
2874: $currentstring = $token->[2];
2875: }
2876: return $currentstring;
2877: }
2878:
2879: #-- <nobr> tag
2880: sub start_nobr {
2881: my ($target,$token) = @_;
2882: my $currentstring = '';
2883: if ($target eq 'web') {
2884: $currentstring = $token->[4];
2885: }
2886: return $currentstring;
2887: }
2888:
2889: sub end_nobr {
2890: my ($target,$token) = @_;
2891: my $currentstring = '';
2892: if ($target eq 'web') {
2893: $currentstring = $token->[2];
2894: }
2895: return $currentstring;
2896: }
2897:
2898: #-- <noembed> tag
2899: sub start_noembed {
2900: my ($target,$token) = @_;
2901: my $currentstring = '';
2902: if ($target eq 'web') {
2903: $currentstring = $token->[4];
2904: }
2905: return $currentstring;
2906: }
2907:
2908: sub end_noembed {
2909: my ($target,$token) = @_;
2910: my $currentstring = '';
2911: if ($target eq 'web') {
2912: $currentstring = $token->[2];
2913: }
2914: return $currentstring;
2915: }
2916:
2917: #-- <noframes> tag
2918: sub start_noframes {
2919: my ($target,$token) = @_;
2920: my $currentstring = '';
2921: if ($target eq 'web') {
2922: $currentstring = $token->[4];
2923: }
2924: return $currentstring;
2925: }
2926:
2927: sub end_noframes {
2928: my ($target,$token) = @_;
2929: my $currentstring = '';
2930: if ($target eq 'web') {
2931: $currentstring = $token->[2];
2932: }
2933: return $currentstring;
2934: }
2935:
2936: #-- <nolayer> tag
2937: sub start_nolayer {
2938: my ($target,$token) = @_;
2939: my $currentstring = '';
2940: if ($target eq 'web') {
2941: $currentstring = $token->[4];
2942: }
2943: return $currentstring;
2944: }
2945:
2946: sub end_nolayer {
2947: my ($target,$token) = @_;
2948: my $currentstring = '';
2949: if ($target eq 'web') {
2950: $currentstring = $token->[2];
2951: }
2952: return $currentstring;
2953: }
2954:
2955: #-- <noscript> tag
2956: sub start_noscript {
2957: my ($target,$token) = @_;
2958: my $currentstring = '';
2959: if ($target eq 'web') {
2960: $currentstring = $token->[4];
2961: }
2962: return $currentstring;
2963: }
2964:
2965: sub end_noscript {
2966: my ($target,$token) = @_;
2967: my $currentstring = '';
2968: if ($target eq 'web') {
2969: $currentstring = $token->[2];
2970: }
2971: return $currentstring;
2972: }
2973:
2974: #-- <object> tag
2975: sub start_object {
2976: my ($target,$token) = @_;
2977: my $currentstring = '';
2978: if ($target eq 'web') {
2979: $currentstring = $token->[4];
2980: }
2981: return $currentstring;
2982: }
2983:
2984: sub end_object {
2985: my ($target,$token) = @_;
2986: my $currentstring = '';
2987: if ($target eq 'web') {
2988: $currentstring = $token->[2];
2989: }
2990: return $currentstring;
2991: }
2992:
2993: #-- <optgroup> tag
2994: sub start_optgroup {
2995: my ($target,$token) = @_;
2996: my $currentstring = '';
2997: if ($target eq 'web') {
2998: $currentstring = $token->[4];
2999: }
3000: return $currentstring;
3001: }
3002:
3003: sub end_optgroup {
3004: my ($target,$token) = @_;
3005: my $currentstring = '';
3006: if ($target eq 'web') {
3007: $currentstring = $token->[2];
3008: }
3009: return $currentstring;
3010: }
3011:
3012: #-- <samp> tag
3013: sub start_samp {
3014: my ($target,$token) = @_;
3015: my $currentstring = '';
3016: if ($target eq 'web') {
3017: $currentstring = $token->[4];
3018: }
3019: return $currentstring;
3020: }
3021:
3022: sub end_samp {
3023: my ($target,$token) = @_;
3024: my $currentstring = '';
3025: if ($target eq 'web') {
3026: $currentstring = $token->[2];
3027: }
3028: return $currentstring;
3029: }
3030:
3031: #-- <server> tag
3032: sub start_server {
3033: my ($target,$token) = @_;
3034: my $currentstring = '';
3035: if ($target eq 'web') {
3036: $currentstring = $token->[4];
3037: }
3038: return $currentstring;
3039: }
3040:
3041: sub end_server {
3042: my ($target,$token) = @_;
3043: my $currentstring = '';
3044: if ($target eq 'web') {
3045: $currentstring = $token->[2];
3046: }
3047: return $currentstring;
3048: }
3049:
3050: #-- <spacer> tag
3051: sub start_spacer {
3052: my ($target,$token) = @_;
3053: my $currentstring = '';
3054: if ($target eq 'web') {
3055: $currentstring = $token->[4];
3056: }
3057: return $currentstring;
3058: }
3059:
3060: sub end_spacer {
3061: my ($target,$token) = @_;
3062: my $currentstring = '';
3063: if ($target eq 'web') {
3064: $currentstring = $token->[2];
3065: }
3066: return $currentstring;
3067: }
3068:
3069: #-- <span> tag
3070: sub start_span {
3071: my ($target,$token) = @_;
3072: my $currentstring = '';
3073: if ($target eq 'web') {
3074: $currentstring = $token->[4];
3075: }
3076: return $currentstring;
3077: }
3078:
3079: sub end_span {
3080: my ($target,$token) = @_;
3081: my $currentstring = '';
3082: if ($target eq 'web') {
3083: $currentstring = $token->[2];
3084: }
3085: return $currentstring;
3086: }
3087:
3088: #-- <tbody> tag
3089: sub start_tbody {
3090: my ($target,$token) = @_;
3091: my $currentstring = '';
3092: if ($target eq 'web') {
3093: $currentstring = $token->[4];
3094: }
3095: return $currentstring;
3096: }
3097:
3098: sub end_tbody {
3099: my ($target,$token) = @_;
3100: my $currentstring = '';
3101: if ($target eq 'web') {
3102: $currentstring = $token->[2];
3103: }
3104: return $currentstring;
3105: }
3106:
3107: #-- <tfoot> tag
3108: sub start_tfoot {
3109: my ($target,$token) = @_;
3110: my $currentstring = '';
3111: if ($target eq 'web') {
3112: $currentstring = $token->[4];
3113: }
3114: return $currentstring;
3115: }
3116:
3117: sub end_tfoot {
3118: my ($target,$token) = @_;
3119: my $currentstring = '';
3120: if ($target eq 'web') {
3121: $currentstring = $token->[2];
3122: }
3123: return $currentstring;
3124: }
3125:
3126: #-- <thead> tag
3127: sub start_thead {
3128: my ($target,$token) = @_;
3129: my $currentstring = '';
3130: if ($target eq 'web') {
3131: $currentstring = $token->[4];
3132: }
3133: return $currentstring;
3134: }
1.10 www 3135:
1.122 albertel 3136: sub end_thead {
3137: my ($target,$token) = @_;
3138: my $currentstring = '';
3139: if ($target eq 'web') {
3140: $currentstring = $token->[2];
3141: }
3142: return $currentstring;
3143: }
1.119 www 3144:
1.122 albertel 3145: #-- <var> tag
3146: sub start_var {
1.44 sakharuk 3147: my ($target,$token) = @_;
3148: my $currentstring = '';
3149: if ($target eq 'web') {
1.122 albertel 3150: $currentstring = $token->[4];
1.163 ! sakharuk 3151: } elsif ($target eq 'tex') {
! 3152: $currentstring = '\textit{';
! 3153: }
1.44 sakharuk 3154: return $currentstring;
3155: }
1.10 www 3156:
1.122 albertel 3157: sub end_var {
3158: my ($target,$token) = @_;
1.44 sakharuk 3159: my $currentstring = '';
3160: if ($target eq 'web') {
1.163 ! sakharuk 3161: $currentstring = $token->[2];
! 3162: } elsif ($target eq 'tex') {
! 3163: $currentstring = '}';
1.44 sakharuk 3164: }
3165: return $currentstring;
3166: }
1.119 www 3167:
1.163 ! sakharuk 3168: #-- <wbr> tag (end tag forbidden)
1.122 albertel 3169: sub start_wbr {
3170: my ($target,$token) = @_;
3171: my $currentstring = '';
3172: if ($target eq 'web') {
3173: $currentstring = $token->[4];
3174: }
3175: return $currentstring;
1.98 albertel 3176: }
3177:
1.122 albertel 3178: sub end_wbr {
3179: my ($target,$token) = @_;
3180: my $currentstring = '';
3181: if ($target eq 'web') {
3182: $currentstring = $token->[2];
3183: }
3184: return $currentstring;
1.98 albertel 3185: }
1.134 sakharuk 3186:
3187: #-- <hideweboutput> tag
3188: sub start_hideweboutput {
3189: my ($target,$token) = @_;
3190: if ($target eq 'web') {
3191: &Apache::lonxml::startredirection();
3192: }
3193: return '';
3194: }
3195:
3196: sub end_hideweboutput {
3197: my ($target,$token) = @_;
3198: my $currentstring = '';
3199: if ($target eq 'web') {
3200: $currentstring = &Apache::lonxml::endredirection();
3201: }
3202: return '';
3203: }
3204:
1.94 sakharuk 3205:
3206: sub image_replication {
3207: my $src = shift;
1.118 www 3208: if (not -e $src) {
1.94 sakharuk 3209: #replicates image itself
1.118 www 3210: &Apache::lonnet::repcopy($src);
1.94 sakharuk 3211: #replicates eps or ps
3212: my $newsrc = $src;
1.118 www 3213: $newsrc =~ s/\.(gif|jpg|jpeg|png)$/.eps/i;
3214: if (not -e $newsrc) {
1.122 albertel 3215: if (&Apache::lonnet::repcopy($newsrc) ne 'OK') {
3216: $newsrc =~ s/\.eps$/\.ps/;
3217: &Apache::lonnet::repcopy($newsrc);
3218: }
1.94 sakharuk 3219: }
3220: }
3221: return '';
1.126 sakharuk 3222: }
3223:
3224: sub recalc {
3225: my $argument = shift;
3226: if (not $argument=~/(mm|cm|in|pc|pt)/) {return $argument.' mm';}
1.132 sakharuk 3227: $argument=~/\s*(\d+\.?\d*)\s*(mm|cm|in|pc|pt)/;
1.126 sakharuk 3228: my $value=$1;
3229: my $units=$2;
3230: if ($units eq 'cm') {
3231: $value*=10;
3232: } elsif ($units eq 'in') {
3233: $value*=25.4;
3234: } elsif ($units eq 'pc') {
3235: $value*=(25.4*12/72.27);
3236: } elsif ($units eq 'pt') {
3237: $value*=(25.4/72.27);
3238: }
3239: return $value.' mm';
1.94 sakharuk 3240: }
3241:
1.1 sakharuk 3242: 1;
3243: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>