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