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