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