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