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