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