Annotation of loncom/xml/londefdef.pm, revision 1.158
1.1 sakharuk 1: # The LearningOnline Network with CAPA
2: # Tags Default Definition Module
3: #
1.158 ! sakharuk 4: # $Id: londefdef.pm,v 1.157 2003/07/31 21:00:55 sakharuk Exp $
1.41 sakharuk 5: #
1.34 www 6: #
7: # Copyright Michigan State University Board of Trustees
8: #
9: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
10: #
11: # LON-CAPA is free software; you can redistribute it and/or modify
12: # it under the terms of the GNU General Public License as published by
13: # the Free Software Foundation; either version 2 of the License, or
14: # (at your option) any later version.
15: #
16: # LON-CAPA is distributed in the hope that it will be useful,
17: # but WITHOUT ANY WARRANTY; without even the implied warranty of
18: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19: # GNU General Public License for more details.
20: #
21: # You should have received a copy of the GNU General Public License
22: # along with LON-CAPA; if not, write to the Free Software
23: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24: #
25: # /home/httpd/html/adm/gpl.txt
26: #
27: # http://www.lon-capa.org/
1.156 sakharuk 28: ## Copyright for TtHfunc and TtMfunc by Ian Hutchinson.
1.34 www 29: # TtHfunc and TtMfunc (the "Code") may be compiled and linked into
30: # binary executable programs or libraries distributed by the
31: # Michigan State University (the "Licensee"), but any binaries so
32: # distributed are hereby licensed only for use in the context
33: # of a program or computational system for which the Licensee is the
34: # primary author or distributor, and which performs substantial
35: # additional tasks beyond the translation of (La)TeX into HTML.
36: # The C source of the Code may not be distributed by the Licensee
37: # to any other parties under any circumstances.
38: #
39: #
1.1 sakharuk 40: # last modified 06/26/00 by Alexander Sakharuk
1.28 www 41: # 11/6,11/30,02/01/01,5/4 Gerd Kortemeyer
1.41 sakharuk 42: # 01/18 Alex Sakharuk
1.1 sakharuk 43:
1.2 albertel 44: package Apache::londefdef;
1.1 sakharuk 45:
1.118 www 46: use Apache::lonnet();
1.1 sakharuk 47: use strict;
1.124 sakharuk 48: use Apache::lonxml;
1.57 sakharuk 49: use Apache::File();
1.70 sakharuk 50: use Image::Magick;
1.118 www 51: use Apache::lonmenu();
52: use Apache::lonmeta();
1.54 sakharuk 53:
1.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 {
1.157 sakharuk 1081: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1.122 albertel 1082: my $currentstring = '';
1083: if ($target eq 'web') {
1084: $currentstring .= $token->[4];
1085: } elsif ($target eq 'tex') {
1.157 sakharuk 1086: my $signal=1;
1.158 ! sakharuk 1087: foreach my $tag (@$tagstack) {if (lc($tag) eq 'b') {$signal=0;}}
1.157 sakharuk 1088: if ($signal) {$currentstring .= '\par ';}
1.144 sakharuk 1089: }
1.122 albertel 1090: return $currentstring;
1091: }
1092:
1093: sub end_p {
1094: my ($target,$token) = @_;
1095: my $currentstring = '';
1096: if ($target eq 'web') {
1097: $currentstring .= $token->[2];
1098: }
1099: return $currentstring;
1100: }
1101:
1.35 sakharuk 1102: #-- <br> tag
1.122 albertel 1103: sub start_br {
1104: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1105: my $currentstring = '';
1106: if ($target eq 'web') {
1107: $currentstring .= $token->[4];
1108: } elsif ($target eq 'tex') {
1109: if ($$tagstack[-2] ne 'sub' && $$tagstack[-2] ne 'sup') {
1.148 sakharuk 1110: $currentstring .= '\vskip 0.2 mm ';
1.1 sakharuk 1111: }
1.144 sakharuk 1112: }
1.122 albertel 1113: return $currentstring;
1114: }
1115:
1116: sub end_br {
1117: my ($target,$token) = @_;
1118: my $currentstring = '';
1119: if ($target eq 'web') {
1120: $currentstring .= $token->[2];
1121: }
1122: return $currentstring;
1123: }
1124:
1.35 sakharuk 1125: #-- <big> tag
1.122 albertel 1126: sub start_big {
1127: my ($target,$token) = @_;
1128: my $currentstring = '';
1129: if ($target eq 'web') {
1130: $currentstring .= $token->[4];
1131: } elsif ($target eq 'tex') {
1.137 sakharuk 1132: $currentstring .= '{\large ';
1.144 sakharuk 1133: }
1.122 albertel 1134: return $currentstring;
1135: }
1136:
1137: sub end_big {
1138: my ($target,$token) = @_;
1139: my $currentstring = '';
1140: if ($target eq 'web') {
1141: $currentstring .= $token->[2];
1142: } elsif ($target eq 'tex') {
1143: $currentstring .= '}';
1144: }
1145: return $currentstring;
1146: }
1147:
1.35 sakharuk 1148: #-- <small> tag
1.122 albertel 1149: sub start_small {
1150: my ($target,$token) = @_;
1151: my $currentstring = '';
1152: if ($target eq 'web') {
1153: $currentstring .= $token->[4];
1154: } elsif ($target eq 'tex') {
1155: $currentstring .= '{\footnotesize ';
1.144 sakharuk 1156: }
1.122 albertel 1157: return $currentstring;
1158: }
1159:
1160: sub end_small {
1161: my ($target,$token) = @_;
1162: my $currentstring = '';
1163: if ($target eq 'web') {
1164: $currentstring .= $token->[2];
1165: } elsif ($target eq 'tex') {
1166: $currentstring .= '}';
1167: }
1168: return $currentstring;
1169: }
1170:
1.35 sakharuk 1171: #-- <basefont> tag
1.122 albertel 1172: sub start_basefont {
1.126 sakharuk 1173: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1.122 albertel 1174: my $currentstring = '';
1175: if ($target eq 'web') {
1176: $currentstring = $token->[4];
1.126 sakharuk 1177: } elsif ($target eq 'tex') {
1178: my $basesize=&Apache::lonxml::get_param('TeXsize',$parstack,$safeeval);
1179: if (defined $basesize) {
1180: $currentstring = '{\\'.$basesize.' ';
1181: }
1182: }
1.122 albertel 1183: return $currentstring;
1184: }
1185:
1186: sub end_basefont {
1.126 sakharuk 1187: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1.122 albertel 1188: my $currentstring = '';
1189: if ($target eq 'web') {
1190: $currentstring = $token->[4];
1.126 sakharuk 1191: } elsif ($target eq 'tex') {
1192: my $basesize=&Apache::lonxml::get_param('TeXsize',$parstack,$safeeval);
1193: if (defined $basesize) {
1194: $currentstring = '}';
1195: }
1196: }
1.122 albertel 1197: return $currentstring;
1198: }
1199:
1.35 sakharuk 1200: #-- <font> tag
1.122 albertel 1201: sub start_font {
1202: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1203: my $currentstring = '';
1204: if ($target eq 'web') {
1205: my $face=&Apache::lonxml::get_param('face',$parstack,$safeeval);
1.155 www 1206: if ($face=~/symbol/i) {
1207: $Apache::lonxml::prevent_entity_encode++;
1208: } else {
1209: if (($ENV{'browser.fontenhance'} eq 'on') ||
1210: ($ENV{'browser.blackwhite'} eq 'on')) { return ''; }
1211: }
1.122 albertel 1212: $currentstring = $token->[4];
1.126 sakharuk 1213: } elsif ($target eq 'tex') {
1214: my $fontsize=&Apache::lonxml::get_param('TeXsize',$parstack,$safeeval);
1215: if (defined $fontsize) {
1216: $currentstring = '{\\'.$fontsize.' ';
1217: }
1218: }
1.122 albertel 1219: return $currentstring;
1220: }
1221:
1222: sub end_font {
1223: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1224: my $currentstring = '';
1225: if ($target eq 'web') {
1226: my $face=&Apache::lonxml::get_param('face',$parstack,$safeeval);
1227: if ($face=~/symbol/i) {$Apache::lonxml::prevent_entity_encode--;}
1228: $currentstring = $token->[2];
1.126 sakharuk 1229: } elsif ($target eq 'tex') {
1230: my $fontsize=&Apache::lonxml::get_param('TeXsize',$parstack,$safeeval);
1231: if (defined $fontsize) {
1232: $currentstring = '}';
1233: }
1234: }
1.122 albertel 1235: return $currentstring;
1236: }
1237:
1.35 sakharuk 1238: #-- <strike> tag
1.122 albertel 1239: sub start_strike {
1240: my ($target,$token) = @_;
1241: my $currentstring = '';
1242: if ($target eq 'web') {
1243: $currentstring .= $token->[4];
1244: } elsif ($target eq 'tex') {
1245: &Apache::lonxml::startredirection();
1246: }
1247: return $currentstring;
1248: }
1249:
1250: sub end_strike {
1251: my ($target,$token) = @_;
1252: my $currentstring = '';
1253: if ($target eq 'web') {
1254: $currentstring .= $token->[2];
1255: } elsif ($target eq 'tex') {
1256: $currentstring=&Apache::lonxml::endredirection();
1257: $currentstring=~s/(\S)(\s+)(\S)/$1\}$2\\underline\{$3/g;
1258: $currentstring=~s/^\s*(\S)/\\underline\{$1/;
1259: $currentstring=~s/(\S)\s*$/$1\}/;
1260: }
1261: return $currentstring;
1262: }
1263:
1.35 sakharuk 1264: #-- <s> tag
1.122 albertel 1265: sub start_s {
1266: my ($target,$token) = @_;
1267: my $currentstring = '';
1268: if ($target eq 'web') {
1269: $currentstring .= $token->[4];
1270: } elsif ($target eq 'tex') {
1271: &Apache::lonxml::startredirection();
1272: }
1273: return $currentstring;
1274: }
1275:
1276: sub end_s {
1277: my ($target,$token) = @_;
1278: my $currentstring = '';
1279: if ($target eq 'web') {
1280: $currentstring .= $token->[2];
1281: } elsif ($target eq 'tex') {
1282: $currentstring=&Apache::lonxml::endredirection();
1283: $currentstring=~s/(\S)(\s+)(\S)/$1\}$2\\underline\{$3/g;
1284: $currentstring=~s/^\s*(\S)/\\underline\{$1/;
1285: $currentstring=~s/(\S)\s*$/$1\}/;
1286: }
1287: return $currentstring;
1288: }
1289:
1.35 sakharuk 1290: #-- <sub> tag
1.122 albertel 1291: sub start_sub {
1292: my ($target,$token) = @_;
1293: my $currentstring = '';
1294: if ($target eq 'web') {
1295: $currentstring .= $token->[4];
1296: } elsif ($target eq 'tex') {
1297: $currentstring .= "\$_{ ";
1298: }
1299: return $currentstring;
1300: }
1301:
1302: sub end_sub {
1303: my ($target,$token) = @_;
1304: my $currentstring = '';
1305: if ($target eq 'web') {
1306: $currentstring .= $token->[2];
1307: } elsif ($target eq 'tex') {
1308: $currentstring .= " }\$";
1309: }
1310: return $currentstring;
1311: }
1312:
1.35 sakharuk 1313: #-- <sup> tag
1.122 albertel 1314: sub start_sup {
1315: my ($target,$token) = @_;
1316: my $currentstring = '';
1317: if ($target eq 'web') {
1318: $currentstring .= $token->[4];
1319: } elsif ($target eq 'tex') {
1320: $currentstring .= "\$^{ ";
1321: }
1322: return $currentstring;
1323: }
1324:
1325: sub end_sup {
1326: my ($target,$token) = @_;
1327: my $currentstring = '';
1328: if ($target eq 'web') {
1329: $currentstring .= $token->[2];
1330: } elsif ($target eq 'tex') {
1331: $currentstring .= " }\$";
1332: }
1333: return $currentstring;
1334: }
1335:
1.35 sakharuk 1336: #-- <hr> tag
1.122 albertel 1337: sub start_hr {
1.124 sakharuk 1338: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1.122 albertel 1339: my $currentstring = '';
1340: if ($target eq 'web') {
1341: $currentstring .= $token->[4];
1342: } elsif ($target eq 'tex') {
1.149 sakharuk 1343: my $LaTeXwidth = &Apache::lonxml::get_param('TeXwidth',$parstack,$safeeval,undef,0);
1.124 sakharuk 1344: if (defined $LaTeXwidth) {
1345: if ($LaTeXwidth=~/^%/) {
1346: substr($LaTeXwidth,0,1)='';
1347: $LaTeXwidth=($LaTeXwidth/100).'\textwidth';
1348: }
1349: } else {
1.148 sakharuk 1350: $LaTeXwidth ='0.9\textwidth';
1.124 sakharuk 1351: }
1352: my ($pre,$post);
1353: my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1);
1354: if (($align eq 'center') || (not defined $align)) {
1355: $pre=''; $post='';
1356: } elsif ($align eq 'left') {
1357: $pre='\rlap{'; $post='} \hfill';
1358: } elsif ($align eq 'right') {
1359: $pre=' \hfill \llap{'; $post='}';
1360: }
1.148 sakharuk 1361: $currentstring .= ' \vskip 0 mm \noindent\makebox['.$LaTeXwidth.']{'.$pre.'\makebox['.
1.124 sakharuk 1362: $LaTeXwidth.'][b]{\hrulefill}'.$post.'}\vskip 0 mm ';
1.122 albertel 1363: }
1364: return $currentstring;
1365: }
1366:
1367: sub end_hr {
1368: my ($target,$token) = @_;
1369: my $currentstring = '';
1370: if ($target eq 'web') {
1371: $currentstring .= $token->[2];
1.148 sakharuk 1372: }
1.122 albertel 1373: return $currentstring;
1374: }
1375:
1.85 sakharuk 1376: #-- <div> tag
1.122 albertel 1377: sub start_div {
1378: my ($target,$token) = @_;
1379: my $currentstring = '';
1380: if ($target eq 'web') {
1381: $currentstring .= $token->[4];
1382: }
1383: return $currentstring;
1384: }
1385:
1386: sub end_div {
1387: my ($target,$token) = @_;
1388: my $currentstring = '';
1389: if ($target eq 'web') {
1390: $currentstring .= $token->[2];
1391: }
1392: return $currentstring;
1393: }
1394:
1.35 sakharuk 1395: #-- <a> tag
1.122 albertel 1396: sub start_a {
1.149 sakharuk 1397: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1.122 albertel 1398: my $currentstring = '';
1399: if ($target eq 'web') {
1400: $currentstring .= $token->[4];
1401: } elsif ($target eq 'tex') {
1.149 sakharuk 1402: my $a=&Apache::lonxml::get_param('href',$parstack,$safeeval,undef,1);
1403: $a=~s/([^\\])%/$1\\\%/g;
1404: $currentstring .= '\ref{'.$a.'}';
1.122 albertel 1405: }
1406: return $currentstring;
1407: }
1408:
1409: sub end_a {
1.146 sakharuk 1410: my ($target,$token,$tagstack,$parstack,$safeeval) = @_;
1.122 albertel 1411: my $currentstring = '';
1412: if ($target eq 'web') {
1413: $currentstring .= $token->[2];
1414: }
1415: return $currentstring;
1416: }
1417:
1.35 sakharuk 1418: #-- <li> tag
1.122 albertel 1419: sub start_li {
1.146 sakharuk 1420: my ($target,$token,$tagstack,$parstack,$safeeval) = @_;
1.122 albertel 1421: my $currentstring = '';
1422: if ($target eq 'web') {
1423: $currentstring = $token->[4];
1424: } elsif ($target eq 'tex') {
1.146 sakharuk 1425: my $type=&Apache::lonxml::get_param('type',$parstack,$safeeval,undef,1);
1426: if ($type=~/circle/) {
1427: $currentstring .= ' \item[o] ';
1428: } elsif ($type=~/square/) {
1429: $currentstring .= ' \item[$\Box$] ';
1430: } elsif ($type ne '') {
1431: $currentstring .= ' \item['.$type.'] ';
1.122 albertel 1432: } else {
1.146 sakharuk 1433: $currentstring .= ' \item ';
1.122 albertel 1434: }
1435: }
1436: return $currentstring;
1437: }
1438:
1439: sub end_li {
1440: my ($target,$token) = @_;
1441: my $currentstring = '';
1442: if ($target eq 'web') {
1443: $currentstring = $token->[2];
1444: }
1445: return $currentstring;
1446: }
1447:
1.35 sakharuk 1448: #-- <u> tag
1.122 albertel 1449: sub start_u {
1450: my ($target,$token) = @_;
1451: my $currentstring = '';
1452: if ($target eq 'web') {
1453: $currentstring .= $token->[4];
1454: } elsif ($target eq 'tex') {
1455: &Apache::lonxml::startredirection();
1456: }
1457: return $currentstring;
1458: }
1459:
1460: sub end_u {
1461: my ($target,$token) = @_;
1462: my $currentstring = '';
1463: if ($target eq 'web') {
1464: $currentstring .= $token->[2];
1465: } elsif ($target eq 'tex') {
1466: $currentstring=&Apache::lonxml::endredirection();
1467: $currentstring=~s/(\S)(\s+)(\S)/$1\}$2\\underline\{$3/g;
1468: $currentstring=~s/^\s*(\S)/\\underline\{$1/;
1469: $currentstring=~s/(\S)\s*$/$1\}/;
1470: }
1471: return $currentstring;
1472: }
1473:
1.35 sakharuk 1474: #-- <ul> tag
1.122 albertel 1475: sub start_ul {
1.125 sakharuk 1476: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1.122 albertel 1477: my $currentstring = '';
1478: if ($target eq 'web') {
1479: $currentstring = $token->[4];
1480: } elsif ($target eq 'tex') {
1.125 sakharuk 1481: my $TeXtype=&Apache::lonxml::get_param('type',$parstack,$safeeval,undef,0);
1482: if ($TeXtype eq 'disc') {
1483: $currentstring .= ' \renewcommand{\labelitemi}{$\bullet$}
1484: \renewcommand{\labelitemii}{$\bullet$}
1485: \renewcommand{\labelitemiii}{$\bullet$}
1486: \renewcommand{\labelitemiv}{$\bullet$}';
1487: } elsif ($TeXtype eq 'circle') {
1488: $currentstring .= ' \renewcommand{\labelitemi}{$\circ$}
1489: \renewcommand{\labelitemii}{$\circ$}
1490: \renewcommand{\labelitemiii}{$\circ$}
1491: \renewcommand{\labelitemiv}{$\circ$}';
1492: } elsif ($TeXtype eq 'square') {
1493: $currentstring .= ' \renewcommand{\labelitemi}{$\diamond$}
1494: \renewcommand{\labelitemii}{$\diamond$}
1495: \renewcommand{\labelitemiii}{$\diamond$}
1496: \renewcommand{\labelitemiv}{$\diamond$}';
1497: }
1498: $currentstring .= '\begin{itemize}';
1.122 albertel 1499: }
1500: return $currentstring;
1501: }
1502:
1503: sub end_ul {
1504: my ($target,$token) = @_;
1505: my $currentstring = '';
1506: if ($target eq 'web') {
1507: $currentstring = $token->[2];
1508: } elsif ($target eq 'tex') {
1.125 sakharuk 1509: $currentstring = '\end{itemize} \renewcommand{\labelitemi}{$\bullet$}
1510: \renewcommand{\labelitemii}{$\bullet$}
1511: \renewcommand{\labelitemiii}{$\bullet$}
1512: \renewcommand{\labelitemiv}{$\bullet$}';
1.122 albertel 1513: }
1514: return $currentstring;
1515: }
1516:
1.35 sakharuk 1517: #-- <menu> tag
1.122 albertel 1518: sub start_menu {
1519: my ($target,$token) = @_;
1520: my $currentstring = '';
1521: if ($target eq 'web') {
1522: $currentstring = $token->[4];
1523: } elsif ($target eq 'tex') {
1524: $currentstring = " \\begin{itemize} ";
1525: }
1526: return $currentstring;
1527: }
1528:
1529: sub end_menu {
1530: my ($target,$token) = @_;
1531: my $currentstring = '';
1532: if ($target eq 'web') {
1533: $currentstring = $token->[2];
1534: } elsif ($target eq 'tex') {
1535: $currentstring = " \\end{itemize}";
1536: }
1537: return $currentstring;
1538: }
1539:
1.35 sakharuk 1540: #-- <dir> tag
1.122 albertel 1541: sub start_dir {
1542: my ($target,$token) = @_;
1543: my $currentstring = '';
1544: if ($target eq 'web') {
1545: $currentstring = $token->[4];
1546: } elsif ($target eq 'tex') {
1547: $currentstring = " \\begin{itemize} ";
1548: }
1549: return $currentstring;
1550: }
1551:
1552: sub end_dir {
1553: my ($target,$token) = @_;
1554: my $currentstring = '';
1555: if ($target eq 'web') {
1556: $currentstring = $token->[2];
1557: } elsif ($target eq 'tex') {
1558: $currentstring = " \\end{itemize}";
1559: }
1560: return $currentstring;
1561: }
1562:
1.35 sakharuk 1563: #-- <ol> tag
1.122 albertel 1564: sub start_ol {
1.125 sakharuk 1565: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1.122 albertel 1566: my $currentstring = '';
1567: if ($target eq 'web') {
1568: $currentstring = $token->[4];
1569: } elsif ($target eq 'tex') {
1.125 sakharuk 1570: my $type=&Apache::lonxml::get_param('type',$parstack,$safeeval,undef,0);
1571: if ($type eq '1') {
1572: $currentstring .= ' \renewcommand{\labelenumi}{\arabic{enumi}.}
1573: \renewcommand{\labelenumii}{\arabic{enumii}.}
1574: \renewcommand{\labelenumiii}{\arabic{enumiii}.}
1575: \renewcommand{\labelenumiv}{\arabic{enumiv}.}';
1576: } elsif ($type eq 'A') {
1577: $currentstring .= ' \renewcommand{\labelenumi}{\Alph{enumi}.}
1578: \renewcommand{\labelenumii}{\Alph{enumii}.}
1579: \renewcommand{\labelenumiii}{\Alph{enumiii}.}
1580: \renewcommand{\labelenumiv}{\Alph{enumiv}.}';
1581: } elsif ($type eq 'a') {
1582: $currentstring .= ' \renewcommand{\labelenumi}{\alph{enumi}.}
1583: \renewcommand{\labelenumii}{\alph{enumii}.}
1584: \renewcommand{\labelenumiii}{\alph{enumiii}.}
1585: \renewcommand{\labelenumiv}{\alph{enumiv}.} ';
1586: } elsif ($type eq 'i') {
1587: $currentstring .= ' \renewcommand{\labelenumi}{\roman{enumi}.}
1588: \renewcommand{\labelenumii}{\roman{enumii}.}
1589: \renewcommand{\labelenumiii}{\roman{enumiii}.}
1590: \renewcommand{\labelenumiv}{\roman{enumiv}.} ';
1591: } elsif ($type eq 'I') {
1592: $currentstring .= ' \renewcommand{\labelenumi}{\Roman{enumi}.}
1593: \renewcommand{\labelenumii}{\Roman{enumii}.}
1594: \renewcommand{\labelenumiii}{\Roman{enumiii}.}
1595: \renewcommand{\labelenumiv}{\Roman{enumiv}.} ';
1596: }
1597: $currentstring .= '\begin{enumerate}';
1.122 albertel 1598: }
1599: return $currentstring;
1600: }
1601:
1602: sub end_ol {
1603: my ($target,$token) = @_;
1604: my $currentstring = '';
1605: if ($target eq 'web') {
1606: $currentstring = $token->[2];
1607: } elsif ($target eq 'tex') {
1.125 sakharuk 1608: $currentstring = '\end{enumerate} \renewcommand{\labelenumi}{\arabic{enumi}.}
1609: \renewcommand{\labelenumii}{\arabic{enumii}.}
1610: \renewcommand{\labelenumiii}{\arabic{enumiii}.}
1611: \renewcommand{\labelenumiv}{\arabic{enumiv}.}';
1.122 albertel 1612: }
1613: return $currentstring;
1614: }
1615:
1.35 sakharuk 1616: #-- <dl> tag
1.122 albertel 1617: sub start_dl {
1618: my ($target,$token) = @_;
1619: my $currentstring = '';
1620: if ($target eq 'web') {
1621: $currentstring = $token->[4];
1622: } elsif ($target eq 'tex') {
1623: $currentstring = '\begin{description}';
1624: }
1625: return $currentstring;
1626: }
1627:
1628: sub end_dl {
1629: my ($target,$token) = @_;
1630: my $currentstring = '';
1631: if ($target eq 'web') {
1632: $currentstring = $token->[2];
1633: } elsif ($target eq 'tex') {
1634: $currentstring = '\end{description}';
1635: }
1636: return $currentstring;
1637: }
1638:
1.35 sakharuk 1639: #-- <dt> tag
1.122 albertel 1640: sub start_dt {
1641: my ($target,$token) = @_;
1642: my $currentstring = '';
1643: if ($target eq 'web') {
1644: $currentstring = $token->[4];
1645: } elsif ($target eq 'tex') {
1646: $currentstring = '\item[';
1647: }
1648: return $currentstring;
1649: }
1650:
1651: sub end_dt {
1652: my ($target,$token) = @_;
1653: my $currentstring = '';
1654: if ($target eq 'web') {
1655: $currentstring = $token->[2];
1656: } elsif ($target eq 'tex') {
1657: $currentstring = ']';
1658: }
1659: return $currentstring;
1660: }
1661:
1.35 sakharuk 1662: #-- <dd> tag
1.122 albertel 1663: sub start_dd {
1.147 sakharuk 1664: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1.122 albertel 1665: my $currentstring = '';
1666: if ($target eq 'web') {
1667: $currentstring = $token->[4];
1.147 sakharuk 1668: } elsif ($target eq 'tex') {
1669: if ($$tagstack[-2] eq 'dl') {
1670: $currentstring = ' \item [] ';
1.152 sakharuk 1671: } elsif ($$tagstack[-2] eq 'dt') {
1672: $currentstring = ']';
1.147 sakharuk 1673: }
1.122 albertel 1674: }
1675: return $currentstring;
1676: }
1677:
1678: sub end_dd {
1679: my ($target,$token) = @_;
1680: my $currentstring = '';
1681: if ($target eq 'web') {
1682: $currentstring = $token->[2];
1683: }
1684: return $currentstring;
1685: }
1686:
1.35 sakharuk 1687: #-- <table> tag
1.91 sakharuk 1688: sub start_table {
1689: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1.141 sakharuk 1690: my $textwidth='';
1.131 sakharuk 1691: if (not defined @Apache::londefdef::table) {
1.127 sakharuk 1692: $textwidth=&recalc($ENV{'form.textwidth'});
1.139 sakharuk 1693: $textwidth=~/(\d+\.?\d*)/;
1694: $textwidth=0.95*$1;
1.127 sakharuk 1695: } else {
1696: $textwidth=&Apache::lonxml::get_param('TeXwidth',$parstack,$safeeval,undef,0);
1697: }
1.91 sakharuk 1698: my $currentstring = '';
1699: if ($target eq 'web') {
1700: $currentstring = $token->[4];
1701: } elsif ($target eq 'tex') {
1702: my $aa = {};
1703: push @Apache::londefdef::table, $aa;
1704: $Apache::londefdef::table[-1]{'row_number'} = -1;
1.126 sakharuk 1705: #table's width
1706: my $TeXwidth = &Apache::lonxml::get_param('TeXwidth',$parstack,$safeeval,undef,0);
1707: if (not defined $TeXwidth) {
1708: my $htmlwidth = &Apache::lonxml::get_param('width',$parstack,$safeeval,undef,1);
1709: if ($htmlwidth=~/%/) {
1710: $htmlwidth=~/(\d+)/;
1711: my $value=$1*$textwidth/100;
1712: $Apache::londefdef::table[-1]{'width'}=$value;
1713: } else {
1714: $Apache::londefdef::table[-1]{'width'}=$textwidth;
1715: }
1716: } elsif ($TeXwidth=~/%/) {
1717: $TeXwidth=~/(\d+)/;
1718: my $value=$1*$textwidth/100;
1719: $Apache::londefdef::table[-1]{'width'}=$value;
1720: } else {
1721: $Apache::londefdef::table[-1]{'width'}=$textwidth;
1722: }
1723: #table's border
1.101 sakharuk 1724: my $border = &Apache::lonxml::get_param('border',$parstack,$safeeval,undef,1);
1.91 sakharuk 1725: unless (defined $border) { $border = 0; }
1726: if ($border) {
1727: $Apache::londefdef::table[-1]{'hinc'} = '\hline ';
1728: $Apache::londefdef::table[-1]{'vinc'} = '&';
1729: $Apache::londefdef::table[-1]{'vvinc'} = '|';
1730: } else {
1731: $Apache::londefdef::table[-1]{'hinc'} = '';
1732: $Apache::londefdef::table[-1]{'vinc'} = '&';
1733: $Apache::londefdef::table[-1]{'vvinc'} = '';
1734: }
1.126 sakharuk 1735: $Apache::londefdef::table[-1]{'output'} = ' \noindent \begin{tabular} ';
1.143 sakharuk 1736: $currentstring = '\keephidden{NEW TABLE ENTRY}';
1.91 sakharuk 1737: }
1738: return $currentstring;
1739: }
1.122 albertel 1740:
1741: sub end_table {
1742: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1743: my $currentstring = '';
1744: if ($target eq 'web') {
1745: $currentstring = $token->[2];
1746: } elsif ($target eq 'tex') {
1747: my $inmemory = '';
1748: my $output = '';
1749: #construct header of the table
1750: my $header_of_table = '{'.$Apache::londefdef::table[-1]{'vvinc'};
1.126 sakharuk 1751: for (my $in=0;$in<=$Apache::londefdef::table[-1]{'counter_columns'};$in++) {
1.122 albertel 1752: $header_of_table .= $Apache::londefdef::table[-1]{'columns'}[$in].$Apache::londefdef::table[-1]{'vvinc'};
1753: }
1754: $header_of_table .= '}';
1.126 sakharuk 1755: #define the length of the table cells
1756: #always starts with TeXwidth (if defined everything else is ignored)
1757: my @length_row_final = split(/,/,$Apache::londefdef::table[-1]{'TeXlengthrow'}[0]);
1758: for (my $in=1;$in<=$Apache::londefdef::table[-1]{'row_number'};$in++) {
1759: my @length_row = split(/,/,$Apache::londefdef::table[-1]{'TeXlengthrow'}[$in]);
1760: for (my $jn=0;$jn<=$#length_row;$jn++) {
1761: if ($length_row_final[$jn]<$length_row[$jn]) {$length_row_final[$jn]=$length_row[$jn];}
1762: }
1763: }
1764: #continues trying estimate the width of raw data
1765: my @length_raw_row = split(/,/,$Apache::londefdef::table[-1]{'lengthrow'}[0]);
1766: for (my $in=1;$in<=$Apache::londefdef::table[-1]{'row_number'};$in++) {
1767: my @length_row = split(/,/,$Apache::londefdef::table[-1]{'lengthrow'}[$in]);
1768: for (my $jn=0;$jn<=$#length_row;$jn++) {
1769: if ($length_raw_row[$jn]<$length_row[$jn]) {$length_raw_row[$jn]=$length_row[$jn];}
1770: }
1771: }
1772: #comparing of TeXwidth and raw data width
1773: my $available_length=$Apache::londefdef::table[-1]{'width'};
1774: my $needed=0;
1775: for (my $jn=0;$jn<=$#length_row_final;$jn++) {
1776: if ($length_row_final[$jn]!=0) {
1777: $available_length=$available_length-$length_row_final[$jn];
1778: $needed++;
1779: }
1.122 albertel 1780: }
1.126 sakharuk 1781: $needed=$#length_row_final-$needed+1;
1782: for (my $jn=0;$jn<=$#length_row_final;$jn++) {
1783: if ($length_row_final[$jn]==0) {
1784: if ($length_raw_row[$jn]<$available_length/3) {
1785: $length_row_final[$jn]=$length_raw_row[$jn];
1786: $available_length=$available_length-$length_raw_row[$jn];
1787: $needed--;
1.53 sakharuk 1788: }
1.51 sakharuk 1789: }
1790: }
1.126 sakharuk 1791: for (my $jn=0;$jn<=$#length_row_final;$jn++) {
1792: if ($length_row_final[$jn]==0) {
1793: $length_row_final[$jn]=0.9*$available_length/$needed;
1.122 albertel 1794: }
1795: }
1.126 sakharuk 1796: #fill the table
1797: for (my $in=0;$in<=$Apache::londefdef::table[-1]{'row_number'};$in++) {
1798: for (my $jn=0;$jn<=$#length_row_final;$jn++) {
1799: my $substituted=$length_row_final[$jn];
1800: $Apache::londefdef::table[-1]{'rowdata'}[$in]=~s/TOBECHANGEDONNUMBER/$substituted mm/;
1.122 albertel 1801: }
1.126 sakharuk 1802: $output .= $Apache::londefdef::table[-1]{'rowdata'}[$in];
1803: chop $output;
1804: $output .= ' \\\\ ';
1.122 albertel 1805: }
1.126 sakharuk 1806: $Apache::londefdef::table[-1]{'output'} .= $header_of_table.$output.$Apache::londefdef::table[-1]{'hinc'}.'\end{tabular}\vskip 0 mm ';
1.127 sakharuk 1807: if ($#Apache::londefdef::table > 0) {
1808: my $inmemory = $Apache::londefdef::table[-1]{'output'};
1809: pop @Apache::londefdef::table;
1.129 sakharuk 1810: push @{$Apache::londefdef::table[-1]{'include'}}, $inmemory;
1.127 sakharuk 1811: } else {
1812: $currentstring .= $Apache::londefdef::table[-1]{'output'};
1813: pop @Apache::londefdef::table;
1.143 sakharuk 1814: undef @Apache::londefdef::table;
1.127 sakharuk 1815: }
1.122 albertel 1816: }
1817: return $currentstring;
1818: }
1819:
1.51 sakharuk 1820: #-- <tr> tag
1.122 albertel 1821: sub start_tr {
1822: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1823: my $currentstring = '';
1824: if ($target eq 'web') {
1825: $currentstring = $token->[4];
1826: } elsif ($target eq 'tex') {
1827: $Apache::londefdef::table[-1]{'row_number'}++;
1828: my $alignchar = substr(&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1),0,1);
1829: if ($alignchar ne '') {
1830: push @ {$Apache::londefdef::table[-1]{'rows'} }, $alignchar;
1831: } else {
1832: push @ {$Apache::londefdef::table[-1]{'rows'} }, 'l';
1833: }
1834: push ( @{ $Apache::londefdef::table[-1]{'rowdata'} }, $Apache::londefdef::table[-1]{'hinc'});
1835: $Apache::londefdef::table[-1]{'counter_columns'} = -1;
1.126 sakharuk 1836: $Apache::londefdef::table[-1]{'TeXlength'} = '';
1837: $Apache::londefdef::table[-1]{'length'} = '';
1.122 albertel 1838: }
1839: return $currentstring;
1840: }
1841:
1842: sub end_tr {
1843: my ($target,$token) = @_;
1844: my $currentstring = '';
1845: if ($target eq 'web') {
1846: $currentstring = $token->[2];
1847: } elsif ($target eq 'tex') {
1.126 sakharuk 1848: push @{ $Apache::londefdef::table[-1]{'TeXlengthrow'} },$Apache::londefdef::table[-1]{'TeXlength'};
1.122 albertel 1849: push @{ $Apache::londefdef::table[-1]{'lengthrow'} },$Apache::londefdef::table[-1]{'length'};
1850: }
1851: return $currentstring;
1852: }
1853:
1854: #-- <td> tag
1855: sub start_td {
1856: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1857: my $currentstring = '';
1858: if ($target eq 'web') {
1859: $currentstring = $token->[4];
1860: } elsif ($target eq 'tex') {
1861: my $what_to_push = substr(&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1),0,1);
1862: if ($what_to_push eq '') {
1863: $what_to_push = substr($Apache::londefdef::table[-1]{'rows'}[0],0,1);;
1864: }
1865: push @{ $Apache::londefdef::table[-1]{'columns'} }, $what_to_push;
1866: $Apache::londefdef::table[-1]{'counter_columns'}++;
1867: &Apache::lonxml::startredirection();
1868: }
1869: return $currentstring;
1870: }
1871:
1872: sub end_td {
1.126 sakharuk 1873: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1.122 albertel 1874: my $currentstring = '';
1875: if ($target eq 'web') {
1876: $currentstring = $token->[2];
1877: } elsif ($target eq 'tex') {
1878: my $current_row = $Apache::londefdef::table[-1]{'row_number'};
1879: my $data=&Apache::lonxml::endredirection();
1.126 sakharuk 1880: my $TeXwidth=&Apache::lonxml::get_param('TeXwidth',$parstack,$safeeval,undef,0);
1881: if (defined $TeXwidth) {
1882: my $current_length=&recalc($TeXwidth);
1883: $current_length=~/(\d+)/;
1884: $Apache::londefdef::table[-1]{'TeXlength'} .= $1.',';
1885: $Apache::londefdef::table[-1]{'length'} .= '0,';
1.122 albertel 1886: } else {
1.126 sakharuk 1887: if ($data=~m/width\s*=\s*(\d+\.?\d*\s*(mm|cm|in|pc|pt)*)/) {
1888: my $current_length=&recalc($1);
1.132 sakharuk 1889: $current_length=~/(\d+\.?\d*)/;
1.126 sakharuk 1890: $Apache::londefdef::table[-1]{'TeXlength'} .= $1.',';
1891: $Apache::londefdef::table[-1]{'length'} .= '0,';
1.148 sakharuk 1892: } else {
1893: $data=~s/^\s+(\S.*)/$1/;
1894: $data=~s/(.*\S)\s+$/$1/;
1.126 sakharuk 1895: my $current_length=2*length($data);
1896: $Apache::londefdef::table[-1]{'length'} .= $current_length.',';
1897: $Apache::londefdef::table[-1]{'TeXlength'} .= '0,';
1898: }
1.129 sakharuk 1899: }
1.143 sakharuk 1900: for (my $in=0; $in<=$#{$Apache::londefdef::table[-1]{'include'}};$in++) {
1.129 sakharuk 1901: $data=~s/\\keephidden\{NEW TABLE ENTRY\}/$Apache::londefdef::table[-1]{'include'}[$in]/;
1902: }
1.128 sakharuk 1903: @{ $Apache::londefdef::table[-1]{'rowdata'} }[$current_row] .= '\parbox{TOBECHANGEDONNUMBER}{'.$data.'} '.$Apache::londefdef::table[-1]{'vinc'};
1.122 albertel 1904: }
1905: return $currentstring;
1906: }
1907:
1908: #-- <th> tag
1909: sub start_th {
1910: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1911: my $currentstring = '';
1912: if ($target eq 'web') {
1913: $currentstring = $token->[4];
1914: } elsif ($target eq 'tex') {
1915: my $what_to_push = substr(&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1),0,1);
1916: if ($what_to_push eq '') {
1917: $what_to_push = substr($Apache::londefdef::table[-1]{'rows'}[0],0,1);;
1918: }
1919: push @{ $Apache::londefdef::table[-1]{'columns'} }, $what_to_push;
1920: $Apache::londefdef::table[-1]{'counter_columns'}++;
1921: &Apache::lonxml::startredirection();
1922: }
1923: return $currentstring;
1.130 sakharuk 1924: }
1925:
1.122 albertel 1926: sub end_th {
1.130 sakharuk 1927: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1.122 albertel 1928: my $currentstring = '';
1929: if ($target eq 'web') {
1930: $currentstring = $token->[2];
1931: } elsif ($target eq 'tex') {
1932: my $current_row = $Apache::londefdef::table[-1]{'row_number'};
1933: my $data=&Apache::lonxml::endredirection();
1.130 sakharuk 1934: my $TeXwidth=&Apache::lonxml::get_param('TeXwidth',$parstack,$safeeval,undef,0);
1935: if (defined $TeXwidth) {
1936: my $current_length=&recalc($TeXwidth);
1937: $current_length=~/(\d+)/;
1938: $Apache::londefdef::table[-1]{'TeXlength'} .= $1.',';
1939: $Apache::londefdef::table[-1]{'length'} .= '0,';
1.122 albertel 1940: } else {
1.130 sakharuk 1941: if ($data=~m/width\s*=\s*(\d+\.?\d*\s*(mm|cm|in|pc|pt)*)/) {
1942: my $current_length=&recalc($1);
1943: $current_length=~/(\d+)/;
1944: $Apache::londefdef::table[-1]{'TeXlength'} .= $1.',';
1945: $Apache::londefdef::table[-1]{'length'} .= '0,';
1946: } else {
1947: $data=~/^\s*(\S.*)/;
1948: $data=$1;
1949: $data=~/(.*\S)\s*$/;
1950: $data=$1;
1951: my $current_length=2*length($data);
1952: $Apache::londefdef::table[-1]{'length'} .= $current_length.',';
1953: $Apache::londefdef::table[-1]{'TeXlength'} .= '0,';
1954: }
1955: }
1956: for (my $in=0; $in<=$#{$Apache::londefdef::table[-1]{'include'}};$in++) {
1957: $data=~s/\\keephidden\{NEW TABLE ENTRY\}/$Apache::londefdef::table[-1]{'include'}[$in]/;
1958: }
1959: $data='\textbf{'.$data.'}';
1960: @{ $Apache::londefdef::table[-1]{'rowdata'} }[$current_row] .= '\parbox{TOBECHANGEDONNUMBER}{'.$data.'} '.$Apache::londefdef::table[-1]{'vinc'};
1.122 albertel 1961: }
1962: return $currentstring;
1963: }
1964: #-- <img> tag
1965: sub start_img {
1966: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1967: my $src = &Apache::lonxml::get_param('src',$parstack,$safeeval,
1968: undef,1);
1969: $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=$src;
1970: my $currentstring = '';
1971: my $width_param = '';
1972: my $height_param = '';
1973: my $scaling = .3;
1974: if ($target eq 'web') {
1975: if ($ENV{'browser.imagesuppress'} ne 'on') {
1.158 ! sakharuk 1976: $currentstring.= $token->[4];
1.122 albertel 1977: } else {
1978: my $alttag= &Apache::lonxml::get_param
1979: ('alt',$parstack,$safeeval,undef,1);
1980: unless ($alttag) {
1981: $alttag=&Apache::lonmeta::alttag
1982: ($Apache::lonxml::pwd[-1],$src);
1.51 sakharuk 1983: }
1.158 ! sakharuk 1984: $currentstring.='[IMAGE: '.$alttag.']';
1.1 sakharuk 1985: }
1.122 albertel 1986: } elsif ($target eq 'tex') {
1987: $src=&Apache::lonnet::filelocation($Apache::lonxml::pwd[-1],$src);
1988: &image_replication($src);
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>