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