Annotation of loncom/xml/londefdef.pm, revision 1.146
1.1 sakharuk 1: # The LearningOnline Network with CAPA
2: # Tags Default Definition Module
3: #
1.146 ! sakharuk 4: # $Id: londefdef.pm,v 1.145 2003/06/27 14:01:19 albertel Exp $
1.41 sakharuk 5: #
1.34 www 6: #
7: # Copyright Michigan State University Board of Trustees
8: #
9: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
10: #
11: # LON-CAPA is free software; you can redistribute it and/or modify
12: # it under the terms of the GNU General Public License as published by
13: # the Free Software Foundation; either version 2 of the License, or
14: # (at your option) any later version.
15: #
16: # LON-CAPA is distributed in the hope that it will be useful,
17: # but WITHOUT ANY WARRANTY; without even the implied warranty of
18: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19: # GNU General Public License for more details.
20: #
21: # You should have received a copy of the GNU General Public License
22: # along with LON-CAPA; if not, write to the Free Software
23: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24: #
25: # /home/httpd/html/adm/gpl.txt
26: #
27: # http://www.lon-capa.org/
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 {
1617: my ($target,$token) = @_;
1618: my $currentstring = '';
1619: if ($target eq 'web') {
1620: $currentstring = $token->[4];
1621: }
1622: return $currentstring;
1623: }
1624:
1625: sub end_dd {
1626: my ($target,$token) = @_;
1627: my $currentstring = '';
1628: if ($target eq 'web') {
1629: $currentstring = $token->[2];
1630: }
1631: return $currentstring;
1632: }
1633:
1.35 sakharuk 1634: #-- <table> tag
1.91 sakharuk 1635: sub start_table {
1636: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1.141 sakharuk 1637: my $textwidth='';
1.131 sakharuk 1638: if (not defined @Apache::londefdef::table) {
1.127 sakharuk 1639: $textwidth=&recalc($ENV{'form.textwidth'});
1.139 sakharuk 1640: $textwidth=~/(\d+\.?\d*)/;
1641: $textwidth=0.95*$1;
1.127 sakharuk 1642: } else {
1643: $textwidth=&Apache::lonxml::get_param('TeXwidth',$parstack,$safeeval,undef,0);
1644: }
1.91 sakharuk 1645: my $currentstring = '';
1646: if ($target eq 'web') {
1647: $currentstring = $token->[4];
1648: } elsif ($target eq 'tex') {
1649: my $aa = {};
1650: push @Apache::londefdef::table, $aa;
1651: $Apache::londefdef::table[-1]{'row_number'} = -1;
1.126 sakharuk 1652: #table's width
1653: my $TeXwidth = &Apache::lonxml::get_param('TeXwidth',$parstack,$safeeval,undef,0);
1654: if (not defined $TeXwidth) {
1655: my $htmlwidth = &Apache::lonxml::get_param('width',$parstack,$safeeval,undef,1);
1656: if ($htmlwidth=~/%/) {
1657: $htmlwidth=~/(\d+)/;
1658: my $value=$1*$textwidth/100;
1659: $Apache::londefdef::table[-1]{'width'}=$value;
1660: } else {
1661: $Apache::londefdef::table[-1]{'width'}=$textwidth;
1662: }
1663: } elsif ($TeXwidth=~/%/) {
1664: $TeXwidth=~/(\d+)/;
1665: my $value=$1*$textwidth/100;
1666: $Apache::londefdef::table[-1]{'width'}=$value;
1667: } else {
1668: $Apache::londefdef::table[-1]{'width'}=$textwidth;
1669: }
1670: #table's border
1.101 sakharuk 1671: my $border = &Apache::lonxml::get_param('border',$parstack,$safeeval,undef,1);
1.91 sakharuk 1672: unless (defined $border) { $border = 0; }
1673: if ($border) {
1674: $Apache::londefdef::table[-1]{'hinc'} = '\hline ';
1675: $Apache::londefdef::table[-1]{'vinc'} = '&';
1676: $Apache::londefdef::table[-1]{'vvinc'} = '|';
1677: } else {
1678: $Apache::londefdef::table[-1]{'hinc'} = '';
1679: $Apache::londefdef::table[-1]{'vinc'} = '&';
1680: $Apache::londefdef::table[-1]{'vvinc'} = '';
1681: }
1.126 sakharuk 1682: $Apache::londefdef::table[-1]{'output'} = ' \noindent \begin{tabular} ';
1.143 sakharuk 1683: $currentstring = '\keephidden{NEW TABLE ENTRY}';
1.91 sakharuk 1684: }
1685: return $currentstring;
1686: }
1.122 albertel 1687:
1688: sub end_table {
1689: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1690: my $currentstring = '';
1691: if ($target eq 'web') {
1692: $currentstring = $token->[2];
1693: } elsif ($target eq 'tex') {
1694: my $inmemory = '';
1695: my $output = '';
1696: #construct header of the table
1697: my $header_of_table = '{'.$Apache::londefdef::table[-1]{'vvinc'};
1.126 sakharuk 1698: for (my $in=0;$in<=$Apache::londefdef::table[-1]{'counter_columns'};$in++) {
1.122 albertel 1699: $header_of_table .= $Apache::londefdef::table[-1]{'columns'}[$in].$Apache::londefdef::table[-1]{'vvinc'};
1700: }
1701: $header_of_table .= '}';
1.126 sakharuk 1702: #define the length of the table cells
1703: #always starts with TeXwidth (if defined everything else is ignored)
1704: my @length_row_final = split(/,/,$Apache::londefdef::table[-1]{'TeXlengthrow'}[0]);
1705: for (my $in=1;$in<=$Apache::londefdef::table[-1]{'row_number'};$in++) {
1706: my @length_row = split(/,/,$Apache::londefdef::table[-1]{'TeXlengthrow'}[$in]);
1707: for (my $jn=0;$jn<=$#length_row;$jn++) {
1708: if ($length_row_final[$jn]<$length_row[$jn]) {$length_row_final[$jn]=$length_row[$jn];}
1709: }
1710: }
1711: #continues trying estimate the width of raw data
1712: my @length_raw_row = split(/,/,$Apache::londefdef::table[-1]{'lengthrow'}[0]);
1713: for (my $in=1;$in<=$Apache::londefdef::table[-1]{'row_number'};$in++) {
1714: my @length_row = split(/,/,$Apache::londefdef::table[-1]{'lengthrow'}[$in]);
1715: for (my $jn=0;$jn<=$#length_row;$jn++) {
1716: if ($length_raw_row[$jn]<$length_row[$jn]) {$length_raw_row[$jn]=$length_row[$jn];}
1717: }
1718: }
1719: #comparing of TeXwidth and raw data width
1720: my $available_length=$Apache::londefdef::table[-1]{'width'};
1721: my $needed=0;
1722: for (my $jn=0;$jn<=$#length_row_final;$jn++) {
1723: if ($length_row_final[$jn]!=0) {
1724: $available_length=$available_length-$length_row_final[$jn];
1725: $needed++;
1726: }
1.122 albertel 1727: }
1.126 sakharuk 1728: $needed=$#length_row_final-$needed+1;
1729: for (my $jn=0;$jn<=$#length_row_final;$jn++) {
1730: if ($length_row_final[$jn]==0) {
1731: if ($length_raw_row[$jn]<$available_length/3) {
1732: $length_row_final[$jn]=$length_raw_row[$jn];
1733: $available_length=$available_length-$length_raw_row[$jn];
1734: $needed--;
1.53 sakharuk 1735: }
1.51 sakharuk 1736: }
1737: }
1.126 sakharuk 1738: for (my $jn=0;$jn<=$#length_row_final;$jn++) {
1739: if ($length_row_final[$jn]==0) {
1740: $length_row_final[$jn]=0.9*$available_length/$needed;
1.122 albertel 1741: }
1742: }
1.126 sakharuk 1743: #fill the table
1744: for (my $in=0;$in<=$Apache::londefdef::table[-1]{'row_number'};$in++) {
1745: for (my $jn=0;$jn<=$#length_row_final;$jn++) {
1746: my $substituted=$length_row_final[$jn];
1747: $Apache::londefdef::table[-1]{'rowdata'}[$in]=~s/TOBECHANGEDONNUMBER/$substituted mm/;
1.122 albertel 1748: }
1.126 sakharuk 1749: $output .= $Apache::londefdef::table[-1]{'rowdata'}[$in];
1750: chop $output;
1751: $output .= ' \\\\ ';
1.122 albertel 1752: }
1.126 sakharuk 1753: $Apache::londefdef::table[-1]{'output'} .= $header_of_table.$output.$Apache::londefdef::table[-1]{'hinc'}.'\end{tabular}\vskip 0 mm ';
1.127 sakharuk 1754: if ($#Apache::londefdef::table > 0) {
1755: my $inmemory = $Apache::londefdef::table[-1]{'output'};
1756: pop @Apache::londefdef::table;
1.129 sakharuk 1757: push @{$Apache::londefdef::table[-1]{'include'}}, $inmemory;
1.127 sakharuk 1758: } else {
1759: $currentstring .= $Apache::londefdef::table[-1]{'output'};
1760: pop @Apache::londefdef::table;
1.143 sakharuk 1761: undef @Apache::londefdef::table;
1.127 sakharuk 1762: }
1.122 albertel 1763: }
1764: return $currentstring;
1765: }
1766:
1.51 sakharuk 1767: #-- <tr> tag
1.122 albertel 1768: sub start_tr {
1769: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1770: my $currentstring = '';
1771: if ($target eq 'web') {
1772: $currentstring = $token->[4];
1773: } elsif ($target eq 'tex') {
1774: $Apache::londefdef::table[-1]{'row_number'}++;
1775: my $alignchar = substr(&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1),0,1);
1776: if ($alignchar ne '') {
1777: push @ {$Apache::londefdef::table[-1]{'rows'} }, $alignchar;
1778: } else {
1779: push @ {$Apache::londefdef::table[-1]{'rows'} }, 'l';
1780: }
1781: push ( @{ $Apache::londefdef::table[-1]{'rowdata'} }, $Apache::londefdef::table[-1]{'hinc'});
1782: $Apache::londefdef::table[-1]{'counter_columns'} = -1;
1.126 sakharuk 1783: $Apache::londefdef::table[-1]{'TeXlength'} = '';
1784: $Apache::londefdef::table[-1]{'length'} = '';
1.122 albertel 1785: }
1786: return $currentstring;
1787: }
1788:
1789: sub end_tr {
1790: my ($target,$token) = @_;
1791: my $currentstring = '';
1792: if ($target eq 'web') {
1793: $currentstring = $token->[2];
1794: } elsif ($target eq 'tex') {
1.126 sakharuk 1795: push @{ $Apache::londefdef::table[-1]{'TeXlengthrow'} },$Apache::londefdef::table[-1]{'TeXlength'};
1.122 albertel 1796: push @{ $Apache::londefdef::table[-1]{'lengthrow'} },$Apache::londefdef::table[-1]{'length'};
1797: }
1798: return $currentstring;
1799: }
1800:
1801: #-- <td> tag
1802: sub start_td {
1803: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1804: my $currentstring = '';
1805: if ($target eq 'web') {
1806: $currentstring = $token->[4];
1807: } elsif ($target eq 'tex') {
1808: my $what_to_push = substr(&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1),0,1);
1809: if ($what_to_push eq '') {
1810: $what_to_push = substr($Apache::londefdef::table[-1]{'rows'}[0],0,1);;
1811: }
1812: push @{ $Apache::londefdef::table[-1]{'columns'} }, $what_to_push;
1813: $Apache::londefdef::table[-1]{'counter_columns'}++;
1814: &Apache::lonxml::startredirection();
1815: }
1816: return $currentstring;
1817: }
1818:
1819: sub end_td {
1.126 sakharuk 1820: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1.122 albertel 1821: my $currentstring = '';
1822: if ($target eq 'web') {
1823: $currentstring = $token->[2];
1824: } elsif ($target eq 'tex') {
1825: my $current_row = $Apache::londefdef::table[-1]{'row_number'};
1826: my $data=&Apache::lonxml::endredirection();
1.146 ! sakharuk 1827:
! 1828: $currentstring.=' SSSS '.$data.' FFFF ';
! 1829:
1.126 sakharuk 1830: my $TeXwidth=&Apache::lonxml::get_param('TeXwidth',$parstack,$safeeval,undef,0);
1831: if (defined $TeXwidth) {
1832: my $current_length=&recalc($TeXwidth);
1833: $current_length=~/(\d+)/;
1834: $Apache::londefdef::table[-1]{'TeXlength'} .= $1.',';
1835: $Apache::londefdef::table[-1]{'length'} .= '0,';
1.122 albertel 1836: } else {
1.126 sakharuk 1837: if ($data=~m/width\s*=\s*(\d+\.?\d*\s*(mm|cm|in|pc|pt)*)/) {
1838: my $current_length=&recalc($1);
1.132 sakharuk 1839: $current_length=~/(\d+\.?\d*)/;
1.126 sakharuk 1840: $Apache::londefdef::table[-1]{'TeXlength'} .= $1.',';
1841: $Apache::londefdef::table[-1]{'length'} .= '0,';
1842: } else {
1843: $data=~/^\s*(\S.*)/;
1844: $data=$1;
1845: $data=~/(.*\S)\s*$/;
1846: $data=$1;
1847: my $current_length=2*length($data);
1848: $Apache::londefdef::table[-1]{'length'} .= $current_length.',';
1849: $Apache::londefdef::table[-1]{'TeXlength'} .= '0,';
1850: }
1.129 sakharuk 1851: }
1.143 sakharuk 1852: for (my $in=0; $in<=$#{$Apache::londefdef::table[-1]{'include'}};$in++) {
1.129 sakharuk 1853: $data=~s/\\keephidden\{NEW TABLE ENTRY\}/$Apache::londefdef::table[-1]{'include'}[$in]/;
1854: }
1.128 sakharuk 1855: @{ $Apache::londefdef::table[-1]{'rowdata'} }[$current_row] .= '\parbox{TOBECHANGEDONNUMBER}{'.$data.'} '.$Apache::londefdef::table[-1]{'vinc'};
1.122 albertel 1856: }
1857: return $currentstring;
1858: }
1859:
1860: #-- <th> tag
1861: sub start_th {
1862: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1863: my $currentstring = '';
1864: if ($target eq 'web') {
1865: $currentstring = $token->[4];
1866: } elsif ($target eq 'tex') {
1867: my $what_to_push = substr(&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1),0,1);
1868: if ($what_to_push eq '') {
1869: $what_to_push = substr($Apache::londefdef::table[-1]{'rows'}[0],0,1);;
1870: }
1871: push @{ $Apache::londefdef::table[-1]{'columns'} }, $what_to_push;
1872: $Apache::londefdef::table[-1]{'counter_columns'}++;
1873: &Apache::lonxml::startredirection();
1874: }
1875: return $currentstring;
1.130 sakharuk 1876: }
1877:
1.122 albertel 1878: sub end_th {
1.130 sakharuk 1879: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1.122 albertel 1880: my $currentstring = '';
1881: if ($target eq 'web') {
1882: $currentstring = $token->[2];
1883: } elsif ($target eq 'tex') {
1884: my $current_row = $Apache::londefdef::table[-1]{'row_number'};
1885: my $data=&Apache::lonxml::endredirection();
1.130 sakharuk 1886: my $TeXwidth=&Apache::lonxml::get_param('TeXwidth',$parstack,$safeeval,undef,0);
1887: if (defined $TeXwidth) {
1888: my $current_length=&recalc($TeXwidth);
1889: $current_length=~/(\d+)/;
1890: $Apache::londefdef::table[-1]{'TeXlength'} .= $1.',';
1891: $Apache::londefdef::table[-1]{'length'} .= '0,';
1.122 albertel 1892: } else {
1.130 sakharuk 1893: if ($data=~m/width\s*=\s*(\d+\.?\d*\s*(mm|cm|in|pc|pt)*)/) {
1894: my $current_length=&recalc($1);
1895: $current_length=~/(\d+)/;
1896: $Apache::londefdef::table[-1]{'TeXlength'} .= $1.',';
1897: $Apache::londefdef::table[-1]{'length'} .= '0,';
1898: } else {
1899: $data=~/^\s*(\S.*)/;
1900: $data=$1;
1901: $data=~/(.*\S)\s*$/;
1902: $data=$1;
1903: my $current_length=2*length($data);
1904: $Apache::londefdef::table[-1]{'length'} .= $current_length.',';
1905: $Apache::londefdef::table[-1]{'TeXlength'} .= '0,';
1906: }
1907: }
1908: for (my $in=0; $in<=$#{$Apache::londefdef::table[-1]{'include'}};$in++) {
1909: $data=~s/\\keephidden\{NEW TABLE ENTRY\}/$Apache::londefdef::table[-1]{'include'}[$in]/;
1910: }
1911: $data='\textbf{'.$data.'}';
1912: @{ $Apache::londefdef::table[-1]{'rowdata'} }[$current_row] .= '\parbox{TOBECHANGEDONNUMBER}{'.$data.'} '.$Apache::londefdef::table[-1]{'vinc'};
1.122 albertel 1913: }
1914: return $currentstring;
1915: }
1916: #-- <img> tag
1917: sub start_img {
1918: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1919: my $src = &Apache::lonxml::get_param('src',$parstack,$safeeval,
1920: undef,1);
1921: $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=$src;
1922: my $currentstring = '';
1923: my $width_param = '';
1924: my $height_param = '';
1925: my $scaling = .3;
1926:
1927: if ($target eq 'web') {
1928: if ($ENV{'browser.imagesuppress'} ne 'on') {
1929: $currentstring = $token->[4];
1930: } else {
1931: my $alttag= &Apache::lonxml::get_param
1932: ('alt',$parstack,$safeeval,undef,1);
1933: unless ($alttag) {
1934: $alttag=&Apache::lonmeta::alttag
1935: ($Apache::lonxml::pwd[-1],$src);
1.51 sakharuk 1936: }
1.122 albertel 1937: $currentstring='[IMAGE: '.$alttag.']';
1.1 sakharuk 1938: }
1.122 albertel 1939: } elsif ($target eq 'tex') {
1940: $src=&Apache::lonnet::filelocation($Apache::lonxml::pwd[-1],$src);
1941: &image_replication($src);
1942:
1943: #if original gif/jpg/png file exist do following:
1944: if (-e $src) {
1945: #defines the default size of image
1946: my $image = Image::Magick->new;
1947: my $current_figure = $image->Read($src);
1948: $width_param = $image->Get('width') * $scaling;;
1949: $height_param = $image->Get('height') * $scaling;;
1950: undef $image;
1951: #do we have any specified size of the picture?
1952: my $TeXwidth = &Apache::lonxml::get_param('TeXwidth',$parstack,$safeeval);
1953: my $TeXheight = &Apache::lonxml::get_param('TeXheight',$parstack,$safeeval);
1954: my $width = &Apache::lonxml::get_param('width',$parstack,$safeeval,
1955: undef,1);
1956: if ($TeXwidth ne '') {
1957: if ($TeXwidth=~/(\d+)\s*\%/) {
1958: $width_param = $1*$ENV{'form.textwidth'}/100;
1959: } else {
1960: $width_param = $TeXwidth;
1961: }
1962: } elsif ($TeXheight ne '') {
1963: $width_param = $TeXheight/$height_param*$width_param;
1964: } elsif ($width ne '') {
1965: $width_param = $width*$scaling;
1966: }
1967: my $file;
1968: my $path;
1969: if ($src =~ m!(.*)/([^/]*)$!) {
1970: $file = $2;
1971: $path = $1.'/';
1972: }
1973: my $newsrc = $src;
1974: $newsrc =~ s/\.(gif|jpg|png)$/.eps/i;
1975: $file=~s/\.(gif|jpg|png)$/.eps/i;
1976: #where can we find the picture?
1977: if (-e $newsrc) {
1978: #eps counterpart for image exist
1979: if ($path) {
1980: $currentstring .= '\vskip 1 mm \noindent\graphicspath{{'.$path.'}}\includegraphics[width='.$width_param.' mm]{'.$file.'} ';
1.51 sakharuk 1981: }
1.122 albertel 1982: } else {
1983: #there is no eps counterpart for image - check for ps one
1984: $newsrc =~ s/\.eps$/\.ps/;
1985: if (-e $newsrc) {
1986: #ps counterpart for image exist
1987: $file =~ s/\.eps$/\.ps/;
1988: if ($path) {
1989: $currentstring .= '\vskip 1 mm \noindent\graphicspath{{'.$path.'}}\includegraphics[width='.$width_param.' mm]{'.$file.'} ';
1990: }
1.78 sakharuk 1991: } else {
1.122 albertel 1992: #there aren't eps or ps - so create eps
1993: my $temp_file;
1994: my $filename = "/home/httpd/prtspool/$ENV{'user.name'}_$ENV{'user.domain'}_printout.dat";
1995: $temp_file = Apache::File->new('>>'.$filename);
1996: print $temp_file "$src\n";
1997: $currentstring .= '\vskip 1 mm \graphicspath{{/home/httpd/prtspool/}}\includegraphics[width='.$width_param.' mm]{'.$file.'} ';
1998: }
1999: }
2000: } else {
2001: #original image file doesn't exist so check the alt attribute
2002: my $alt =
2003: &Apache::lonxml::get_param('alt',$parstack,$safeeval,undef,1);
2004: unless ($alt) {
2005: $alt=&Apache::lonmeta::alttag($Apache::lonxml::pwd[-1],$src);
2006: }
2007:
2008: if ($alt) {
2009: $currentstring .= ' '.$alt.' ';
2010: } else {
2011: #<allow> tag will care about replication
1.59 sakharuk 2012: }
2013: }
1.122 albertel 2014: }
2015: return $currentstring;
2016: }
2017:
2018: sub end_img {
2019: my ($target,$token) = @_;
2020: my $currentstring = '';
2021: if ($target eq 'web') {
2022: $currentstring = $token->[2];
2023: } elsif ($target eq 'tex') {
2024: $currentstring = '';
2025: }
2026: return $currentstring;
2027: }
2028:
2029: #-- <applet> tag
2030: sub start_applet {
2031: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
2032:
2033: my $code=&Apache::lonxml::get_param('code',$parstack,$safeeval,undef,1);
2034: $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=$code;
2035:
2036: my $archive=&Apache::lonxml::get_param('archive',$parstack,$safeeval,
2037: undef,1);
2038: $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=$archive;
2039:
2040: my $currentstring = '';
2041: if ($target eq 'web') {
2042: if ($ENV{'browser.appletsuppress'} ne 'on') {
2043: $currentstring = $token->[4];
2044: } else {
2045: my $alttag= &Apache::lonxml::get_param('alt',$parstack,
2046: $safeeval,undef,1);
2047: unless ($alttag) {
2048: $alttag=&Apache::lonmeta::alttag($Apache::lonxml::pwd[-1],
2049: $code);
1.44 sakharuk 2050: }
1.122 albertel 2051: $currentstring='[APPLET: '.$alttag.']';
1.1 sakharuk 2052: }
1.122 albertel 2053: } elsif ($target eq 'tex') {
2054: $currentstring = " \\begin{figure} ";
2055: }
2056: return $currentstring;
2057: }
2058:
2059: sub end_applet {
2060: my ($target,$token) = @_;
2061: my $currentstring = '';
2062: if ($target eq 'web') {
2063: $currentstring = $token->[2];
2064: } elsif ($target eq 'tex') {
2065: $currentstring = " \\end{figure}";
2066: }
2067: return $currentstring;
2068: }
2069:
2070: #-- <embed> tag
2071: sub start_embed {
2072: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
2073: my $src=&Apache::lonxml::get_param('src',$parstack,$safeeval,undef,1);
2074: $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=$src;
2075: my $currentstring = '';
2076: if ($target eq 'web') {
2077: if ($ENV{'browser.embedsuppress'} ne 'on') {
2078: $currentstring = $token->[4];
2079: } else {
2080: my $alttag=&Apache::lonxml::get_param
2081: ('alt',$parstack,$safeeval,undef,1);
2082: unless ($alttag) {
2083: $alttag=&Apache::lonmeta::alttag($Apache::lonxml::pwd[-1],$src);
1.42 albertel 2084: }
1.122 albertel 2085: $currentstring='[EMBED: '.$alttag.']';
1.10 www 2086: }
1.122 albertel 2087: } elsif ($target eq 'tex') {
2088: $currentstring = " \\begin{figure} ";
2089: }
2090: return $currentstring;
2091: }
2092:
2093: sub end_embed {
2094: my ($target,$token) = @_;
2095: my $currentstring = '';
2096: if ($target eq 'web') {
2097: $currentstring = $token->[2];
2098: } elsif ($target eq 'tex') {
2099: $currentstring = " \\end{figure}";
2100: }
2101: return $currentstring;
2102: }
2103:
2104: #-- <param> tag
2105: sub start_param {
2106: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
2107: if (&Apache::lonxml::get_param
2108: ('name',$parstack,$safeeval,undef,1)=~/^cabbase$/i) {
2109: $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=
2110: &Apache::lonxml::get_param('value',$parstack,$safeeval,undef,1);
2111: }
2112: $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=
2113: &Apache::lonxml::get_param('src',$parstack,$safeeval,undef,1);
2114: my $currentstring = '';
2115: if ($target eq 'web') {
2116: $currentstring = $token->[4];
2117: } elsif ($target eq 'tex') {
2118: $currentstring = " \\begin{figure} ";
2119: }
2120: return $currentstring;
2121: }
2122:
2123: sub end_param {
2124: my ($target,$token) = @_;
2125: my $currentstring = '';
2126: if ($target eq 'web') {
2127: $currentstring = $token->[2];
2128: } elsif ($target eq 'tex') {
2129: $currentstring = " \\end{figure}";
2130: }
2131: return $currentstring;
2132: }
2133:
2134: #-- <allow> tag
2135: sub start_allow {
2136: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
2137: my $src = &Apache::lonxml::get_param('src',$parstack,$safeeval,undef,1);
2138: $src=&Apache::lonnet::filelocation($Apache::lonxml::pwd[-1],$src);
1.138 www 2139: $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=
2140: &Apache::lonnet::clutter($src);
1.122 albertel 2141: &image_replication($src);
2142: my $result;
2143: if ($target eq 'edit') {
2144: $result .=&Apache::edit::tag_start($target,$token);
2145: $result .=&Apache::edit::text_arg('File Spec:','src',$token,70);
2146: $result .=&Apache::edit::end_row();#.&Apache::edit::start_spanning_row();
2147: } elsif ($target eq 'modified') {
2148: my $constructtag=&Apache::edit::get_new_args($token,$parstack,
2149: $safeeval,'src');
2150: if ($constructtag) { $result = &Apache::edit::rebuild_tag($token); }
2151: }
2152: return $result;
2153: }
2154:
2155: sub end_allow {
2156: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
2157: if ( $target eq 'edit') { return (&Apache::edit::end_table()); }
2158: return '';
2159: }
1.119 www 2160:
1.122 albertel 2161: #-- Frames
2162: sub start_frameset {
2163: my ($target,$token) = @_;
2164: my $currentstring = '';
2165: if ($target eq 'web') {
2166: if (!$Apache::lonxml::registered) {
2167: $currentstring.='<head>'.
2168: &Apache::lonmenu::registerurl(undef,$target).'</head>';
1.10 www 2169: }
1.133 www 2170: my $onLoad='';
2171: foreach my $key (keys(%{$token->[2]})) {
2172: if ($key =~ /^onload$/i) {
2173: $onLoad.=$token->[2]->{$key}.';';
2174: delete($token->[2]->{$key});
2175: }
2176: }
2177: $token->[2]->{'onload'}=&Apache::lonmenu::loadevents().';'.$onLoad;
2178: my $onUnload='';
2179: foreach my $key (keys(%{$token->[2]})) {
2180: if ($key =~ /^onunload$/i) {
2181: $onUnload.=$token->[2]->{$key}.';';
2182: delete($token->[2]->{$key});
2183: }
2184: }
2185: $token->[2]->{'onunload'}=&Apache::lonmenu::unloadevents().
2186: ';'.$onUnload;
2187:
2188: $currentstring .= '<'.$token->[1];
2189: foreach (keys %{$token->[2]}) {
2190: $currentstring.=' '.$_.'="'.$token->[2]->{$_}.'"';
2191: }
2192: $currentstring.='>';
1.122 albertel 2193: }
2194: return $currentstring;
2195: }
2196:
2197: sub end_frameset {
2198: my ($target,$token) = @_;
2199: my $currentstring = '';
2200: if ($target eq 'web') {
2201: $currentstring = $token->[2];
2202: }
2203: return $currentstring;
2204: }
2205:
2206: #-- <pre>
2207: sub start_pre {
1.126 sakharuk 2208: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1.122 albertel 2209: my $currentstring = '';
2210: if ($target eq 'web') {
2211: $currentstring .= $token->[4];
2212: } elsif ($target eq 'tex') {
1.136 sakharuk 2213: $currentstring .= '\begin{verbatim}';
1.122 albertel 2214: }
2215: return $currentstring;
2216: }
2217:
2218: sub end_pre {
2219: my ($target,$token) = @_;
2220: my $currentstring = '';
2221: if ($target eq 'web') {
2222: $currentstring .= $token->[2];
2223: } elsif ($target eq 'tex') {
1.136 sakharuk 2224: $currentstring .= '\end{verbatim}';
1.122 albertel 2225: }
2226: return $currentstring;
2227: }
2228:
2229: #-- <insert>
2230: sub start_insert {
2231: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
2232: my $currentstring = '';
2233: if ($target eq 'web') {
2234: my $display = &Apache::lonxml::get_param('display',$parstack,$safeeval,undef,1);
2235: $currentstring .= '<b>'.$display.'</b>';;
2236: }
2237: return $currentstring;
2238: }
2239:
2240: sub end_insert {
2241: my ($target,$token) = @_;
2242: my $currentstring = '';
2243: if ($target eq 'web') {
2244: $currentstring .= '';
2245: }
2246: return $currentstring;
2247: }
2248:
2249: #-- <externallink>
2250: sub start_externallink {
2251: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
2252: my $currentstring = '';
2253: if ($target eq 'web') {
2254: my $display = &Apache::lonxml::get_param('display',$parstack,$safeeval,undef,1);
2255: $currentstring .= '<b>'.$display.'</b>';;
2256: }
2257: return $currentstring;
2258: }
2259:
2260: sub end_externallink {
2261: my ($target,$token) = @_;
2262: my $currentstring = '';
2263: if ($target eq 'web') {
2264: $currentstring .= '';
2265: }
2266: return $currentstring;
2267: }
2268:
2269: #-- <blankspace heigth="">
2270: sub start_blankspace {
2271: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
2272: my $currentstring = '';
2273: if ($target eq 'tex') {
2274: my $howmuch = &Apache::lonxml::get_param('heigth',$parstack,$safeeval,undef,1);
2275: $currentstring .= '\vskip '.$howmuch.' ';
2276: }
2277: return $currentstring;
2278: }
2279:
2280: sub end_blankspace {
2281: my ($target,$token) = @_;
2282: my $currentstring = '';
2283: if ($target eq 'tex') {
2284: $currentstring .= '';
2285: }
2286: return $currentstring;
2287: }
2288:
2289: #-- <abbr> tag
2290: sub start_abbr {
2291: my ($target,$token) = @_;
2292: my $currentstring = '';
2293: if ($target eq 'web') {
2294: $currentstring = $token->[4];
2295: }
2296: return $currentstring;
2297: }
2298:
2299: sub end_abbr {
2300: my ($target,$token) = @_;
2301: my $currentstring = '';
2302: if ($target eq 'web') {
2303: $currentstring = $token->[2];
2304: }
2305: return $currentstring;
2306: }
2307:
2308: #-- <acronym> tag
2309: sub start_acronym {
2310: my ($target,$token) = @_;
2311: my $currentstring = '';
2312: if ($target eq 'web') {
2313: $currentstring = $token->[4];
2314: }
2315: return $currentstring;
2316: }
2317:
2318: sub end_acronym {
2319: my ($target,$token) = @_;
2320: my $currentstring = '';
2321: if ($target eq 'web') {
2322: $currentstring = $token->[2];
2323: }
2324: return $currentstring;
2325: }
2326:
2327: #-- <area> tag
2328: sub start_area {
2329: my ($target,$token) = @_;
2330: my $currentstring = '';
2331: if ($target eq 'web') {
2332: $currentstring = $token->[4];
2333: }
2334: return $currentstring;
2335: }
2336:
2337: sub end_area {
2338: my ($target,$token) = @_;
2339: my $currentstring = '';
2340: if ($target eq 'web') {
2341: $currentstring = $token->[2];
2342: }
2343: return $currentstring;
2344: }
2345:
2346: #-- <base> tag
2347: sub start_base {
2348: my ($target,$token) = @_;
2349: my $currentstring = '';
2350: if ($target eq 'web') {
2351: $currentstring = $token->[4];
2352: }
2353: return $currentstring;
2354: }
2355:
2356: sub end_base {
2357: my ($target,$token) = @_;
2358: my $currentstring = '';
2359: if ($target eq 'web') {
2360: $currentstring = $token->[2];
2361: }
2362: return $currentstring;
2363: }
2364:
2365: #-- <bdo> tag
2366: sub start_bdo {
2367: my ($target,$token) = @_;
2368: my $currentstring = '';
2369: if ($target eq 'web') {
2370: $currentstring = $token->[4];
2371: }
2372: return $currentstring;
2373: }
2374:
2375: sub end_bdo {
2376: my ($target,$token) = @_;
2377: my $currentstring = '';
2378: if ($target eq 'web') {
2379: $currentstring = $token->[2];
2380: }
2381: return $currentstring;
2382: }
2383:
2384: #-- <bgsound> tag
2385: sub start_bgsound {
2386: my ($target,$token) = @_;
2387: my $currentstring = '';
2388: if ($target eq 'web') {
2389: $currentstring = $token->[4];
2390: }
2391: return $currentstring;
2392: }
2393:
2394: sub end_bgsound {
2395: my ($target,$token) = @_;
2396: my $currentstring = '';
2397: if ($target eq 'web') {
2398: $currentstring = $token->[2];
2399: }
2400: return $currentstring;
2401: }
2402:
2403: #-- <blink> tag
2404: sub start_blink {
2405: my ($target,$token) = @_;
2406: my $currentstring = '';
2407: if ($target eq 'web') {
2408: $currentstring = $token->[4];
2409: }
2410: return $currentstring;
2411: }
2412:
2413: sub end_blink {
2414: my ($target,$token) = @_;
2415: my $currentstring = '';
2416: if ($target eq 'web') {
2417: $currentstring = $token->[2];
2418: }
2419: return $currentstring;
2420: }
2421:
2422: #-- <blockquote> tag
2423: sub start_blockquote {
2424: my ($target,$token) = @_;
2425: my $currentstring = '';
2426: if ($target eq 'web') {
2427: $currentstring = $token->[4];
2428: }
2429: return $currentstring;
2430: }
2431:
2432: sub end_blockquote {
2433: my ($target,$token) = @_;
2434: my $currentstring = '';
2435: if ($target eq 'web') {
2436: $currentstring = $token->[2];
2437: }
2438: return $currentstring;
2439: }
2440:
2441: #-- <button> tag
2442: sub start_button {
2443: my ($target,$token) = @_;
2444: my $currentstring = '';
2445: if ($target eq 'web') {
2446: $currentstring = $token->[4];
2447: }
2448: return $currentstring;
2449: }
2450:
2451: sub end_button {
2452: my ($target,$token) = @_;
2453: my $currentstring = '';
2454: if ($target eq 'web') {
2455: $currentstring = $token->[2];
2456: }
2457: return $currentstring;
2458: }
2459:
2460: #-- <caption> tag
2461: sub start_caption {
2462: my ($target,$token) = @_;
2463: my $currentstring = '';
2464: if ($target eq 'web') {
2465: $currentstring = $token->[4];
2466: }
2467: return $currentstring;
2468: }
2469:
2470: sub end_caption {
2471: my ($target,$token) = @_;
2472: my $currentstring = '';
2473: if ($target eq 'web') {
2474: $currentstring = $token->[2];
2475: }
2476: return $currentstring;
2477: }
2478:
2479: #-- <col> tag
2480: sub start_col {
2481: my ($target,$token) = @_;
2482: my $currentstring = '';
2483: if ($target eq 'web') {
2484: $currentstring = $token->[4];
2485: }
2486: return $currentstring;
2487: }
2488:
2489: sub end_col {
2490: my ($target,$token) = @_;
2491: my $currentstring = '';
2492: if ($target eq 'web') {
2493: $currentstring = $token->[2];
2494: }
2495: return $currentstring;
2496: }
2497:
2498: #-- <colgroup> tag
2499: sub start_colgroup {
2500: my ($target,$token) = @_;
2501: my $currentstring = '';
2502: if ($target eq 'web') {
2503: $currentstring = $token->[4];
2504: }
2505: return $currentstring;
2506: }
2507:
2508: sub end_colgroup {
2509: my ($target,$token) = @_;
2510: my $currentstring = '';
2511: if ($target eq 'web') {
2512: $currentstring = $token->[2];
2513: }
2514: return $currentstring;
2515: }
2516:
2517: #-- <del> tag
2518: sub start_del {
2519: my ($target,$token) = @_;
2520: my $currentstring = '';
2521: if ($target eq 'web') {
2522: $currentstring = $token->[4];
2523: }
2524: return $currentstring;
2525: }
2526:
2527: sub end_del {
2528: my ($target,$token) = @_;
2529: my $currentstring = '';
2530: if ($target eq 'web') {
2531: $currentstring = $token->[2];
2532: }
2533: return $currentstring;
2534: }
2535:
2536: #-- <fieldset> tag
2537: sub start_fieldset {
2538: my ($target,$token) = @_;
2539: my $currentstring = '';
2540: if ($target eq 'web') {
2541: $currentstring = $token->[4];
2542: }
2543: return $currentstring;
2544: }
2545:
2546: sub end_fieldset {
2547: my ($target,$token) = @_;
2548: my $currentstring = '';
2549: if ($target eq 'web') {
2550: $currentstring = $token->[2];
2551: }
2552: return $currentstring;
2553: }
2554:
2555: #-- <frame> tag
2556: sub start_frame {
2557: my ($target,$token) = @_;
2558: my $currentstring = '';
2559: if ($target eq 'web') {
2560: $currentstring = $token->[4];
2561: }
2562: return $currentstring;
2563: }
2564:
2565: sub end_frame {
2566: my ($target,$token) = @_;
2567: my $currentstring = '';
2568: if ($target eq 'web') {
2569: $currentstring = $token->[2];
2570: }
2571: return $currentstring;
2572: }
2573:
2574: #-- <iframe> tag
2575: sub start_iframe {
2576: my ($target,$token) = @_;
2577: my $currentstring = '';
2578: if ($target eq 'web') {
2579: $currentstring = $token->[4];
2580: }
2581: return $currentstring;
2582: }
2583:
2584: sub end_iframe {
2585: my ($target,$token) = @_;
2586: my $currentstring = '';
2587: if ($target eq 'web') {
2588: $currentstring = $token->[2];
2589: }
2590: return $currentstring;
2591: }
2592:
2593: #-- <ins> tag
2594: sub start_ins {
2595: my ($target,$token) = @_;
2596: my $currentstring = '';
2597: if ($target eq 'web') {
2598: $currentstring = $token->[4];
2599: }
2600: return $currentstring;
2601: }
2602:
2603: sub end_ins {
2604: my ($target,$token) = @_;
2605: my $currentstring = '';
2606: if ($target eq 'web') {
2607: $currentstring = $token->[2];
2608: }
2609: return $currentstring;
2610: }
2611:
2612: #-- <isindex> tag
2613: sub start_isindex {
2614: my ($target,$token) = @_;
2615: my $currentstring = '';
2616: if ($target eq 'web') {
2617: $currentstring = $token->[4];
2618: }
2619: return $currentstring;
2620: }
2621:
2622: sub end_isindex {
2623: my ($target,$token) = @_;
2624: my $currentstring = '';
2625: if ($target eq 'web') {
2626: $currentstring = $token->[2];
2627: }
2628: return $currentstring;
2629: }
2630:
2631: #-- <keygen> tag
2632: sub start_keygen {
2633: my ($target,$token) = @_;
2634: my $currentstring = '';
2635: if ($target eq 'web') {
2636: $currentstring = $token->[4];
2637: }
2638: return $currentstring;
2639: }
2640:
2641: sub end_keygen {
2642: my ($target,$token) = @_;
2643: my $currentstring = '';
2644: if ($target eq 'web') {
2645: $currentstring = $token->[2];
2646: }
2647: return $currentstring;
2648: }
2649:
2650: #-- <label> tag
2651: sub start_label {
2652: my ($target,$token) = @_;
2653: my $currentstring = '';
2654: if ($target eq 'web') {
2655: $currentstring = $token->[4];
2656: }
2657: return $currentstring;
2658: }
2659:
2660: sub end_label {
2661: my ($target,$token) = @_;
2662: my $currentstring = '';
2663: if ($target eq 'web') {
2664: $currentstring = $token->[2];
2665: }
2666: return $currentstring;
2667: }
2668:
2669: #-- <layer> tag
2670: sub start_layer {
2671: my ($target,$token) = @_;
2672: my $currentstring = '';
2673: if ($target eq 'web') {
2674: $currentstring = $token->[4];
2675: }
2676: return $currentstring;
2677: }
2678:
2679: sub end_layer {
2680: my ($target,$token) = @_;
2681: my $currentstring = '';
2682: if ($target eq 'web') {
2683: $currentstring = $token->[2];
2684: }
2685: return $currentstring;
2686: }
2687:
2688: #-- <legend> tag
2689: sub start_legend {
2690: my ($target,$token) = @_;
2691: my $currentstring = '';
2692: if ($target eq 'web') {
2693: $currentstring = $token->[4];
2694: }
2695: return $currentstring;
2696: }
2697:
2698: sub end_legend {
2699: my ($target,$token) = @_;
2700: my $currentstring = '';
2701: if ($target eq 'web') {
2702: $currentstring = $token->[2];
2703: }
2704: return $currentstring;
2705: }
2706:
2707: #-- <link> tag
2708: sub start_link {
2709: my ($target,$token) = @_;
2710: my $currentstring = '';
2711: if ($target eq 'web') {
2712: $currentstring = $token->[4];
2713: }
2714: return $currentstring;
2715: }
2716:
2717: sub end_link {
2718: my ($target,$token) = @_;
2719: my $currentstring = '';
2720: if ($target eq 'web') {
2721: $currentstring = $token->[2];
2722: }
2723: return $currentstring;
2724: }
2725:
2726: #-- <marquee> tag
2727: sub start_marquee {
2728: my ($target,$token) = @_;
2729: my $currentstring = '';
2730: if ($target eq 'web') {
2731: $currentstring = $token->[4];
2732: }
2733: return $currentstring;
2734: }
2735:
2736: sub end_marquee {
2737: my ($target,$token) = @_;
2738: my $currentstring = '';
2739: if ($target eq 'web') {
2740: $currentstring = $token->[2];
2741: }
2742: return $currentstring;
2743: }
2744:
2745: #-- <malticol> tag
2746: sub start_malticol {
2747: my ($target,$token) = @_;
2748: my $currentstring = '';
2749: if ($target eq 'web') {
2750: $currentstring = $token->[4];
2751: }
2752: return $currentstring;
2753: }
2754:
2755: sub end_malticol {
2756: my ($target,$token) = @_;
2757: my $currentstring = '';
2758: if ($target eq 'web') {
2759: $currentstring = $token->[2];
2760: }
2761: return $currentstring;
2762: }
2763:
2764: #-- <nobr> tag
2765: sub start_nobr {
2766: my ($target,$token) = @_;
2767: my $currentstring = '';
2768: if ($target eq 'web') {
2769: $currentstring = $token->[4];
2770: }
2771: return $currentstring;
2772: }
2773:
2774: sub end_nobr {
2775: my ($target,$token) = @_;
2776: my $currentstring = '';
2777: if ($target eq 'web') {
2778: $currentstring = $token->[2];
2779: }
2780: return $currentstring;
2781: }
2782:
2783: #-- <noembed> tag
2784: sub start_noembed {
2785: my ($target,$token) = @_;
2786: my $currentstring = '';
2787: if ($target eq 'web') {
2788: $currentstring = $token->[4];
2789: }
2790: return $currentstring;
2791: }
2792:
2793: sub end_noembed {
2794: my ($target,$token) = @_;
2795: my $currentstring = '';
2796: if ($target eq 'web') {
2797: $currentstring = $token->[2];
2798: }
2799: return $currentstring;
2800: }
2801:
2802: #-- <noframes> tag
2803: sub start_noframes {
2804: my ($target,$token) = @_;
2805: my $currentstring = '';
2806: if ($target eq 'web') {
2807: $currentstring = $token->[4];
2808: }
2809: return $currentstring;
2810: }
2811:
2812: sub end_noframes {
2813: my ($target,$token) = @_;
2814: my $currentstring = '';
2815: if ($target eq 'web') {
2816: $currentstring = $token->[2];
2817: }
2818: return $currentstring;
2819: }
2820:
2821: #-- <nolayer> tag
2822: sub start_nolayer {
2823: my ($target,$token) = @_;
2824: my $currentstring = '';
2825: if ($target eq 'web') {
2826: $currentstring = $token->[4];
2827: }
2828: return $currentstring;
2829: }
2830:
2831: sub end_nolayer {
2832: my ($target,$token) = @_;
2833: my $currentstring = '';
2834: if ($target eq 'web') {
2835: $currentstring = $token->[2];
2836: }
2837: return $currentstring;
2838: }
2839:
2840: #-- <noscript> tag
2841: sub start_noscript {
2842: my ($target,$token) = @_;
2843: my $currentstring = '';
2844: if ($target eq 'web') {
2845: $currentstring = $token->[4];
2846: }
2847: return $currentstring;
2848: }
2849:
2850: sub end_noscript {
2851: my ($target,$token) = @_;
2852: my $currentstring = '';
2853: if ($target eq 'web') {
2854: $currentstring = $token->[2];
2855: }
2856: return $currentstring;
2857: }
2858:
2859: #-- <object> tag
2860: sub start_object {
2861: my ($target,$token) = @_;
2862: my $currentstring = '';
2863: if ($target eq 'web') {
2864: $currentstring = $token->[4];
2865: }
2866: return $currentstring;
2867: }
2868:
2869: sub end_object {
2870: my ($target,$token) = @_;
2871: my $currentstring = '';
2872: if ($target eq 'web') {
2873: $currentstring = $token->[2];
2874: }
2875: return $currentstring;
2876: }
2877:
2878: #-- <optgroup> tag
2879: sub start_optgroup {
2880: my ($target,$token) = @_;
2881: my $currentstring = '';
2882: if ($target eq 'web') {
2883: $currentstring = $token->[4];
2884: }
2885: return $currentstring;
2886: }
2887:
2888: sub end_optgroup {
2889: my ($target,$token) = @_;
2890: my $currentstring = '';
2891: if ($target eq 'web') {
2892: $currentstring = $token->[2];
2893: }
2894: return $currentstring;
2895: }
2896:
2897: #-- <samp> tag
2898: sub start_samp {
2899: my ($target,$token) = @_;
2900: my $currentstring = '';
2901: if ($target eq 'web') {
2902: $currentstring = $token->[4];
2903: }
2904: return $currentstring;
2905: }
2906:
2907: sub end_samp {
2908: my ($target,$token) = @_;
2909: my $currentstring = '';
2910: if ($target eq 'web') {
2911: $currentstring = $token->[2];
2912: }
2913: return $currentstring;
2914: }
2915:
2916: #-- <server> tag
2917: sub start_server {
2918: my ($target,$token) = @_;
2919: my $currentstring = '';
2920: if ($target eq 'web') {
2921: $currentstring = $token->[4];
2922: }
2923: return $currentstring;
2924: }
2925:
2926: sub end_server {
2927: my ($target,$token) = @_;
2928: my $currentstring = '';
2929: if ($target eq 'web') {
2930: $currentstring = $token->[2];
2931: }
2932: return $currentstring;
2933: }
2934:
2935: #-- <spacer> tag
2936: sub start_spacer {
2937: my ($target,$token) = @_;
2938: my $currentstring = '';
2939: if ($target eq 'web') {
2940: $currentstring = $token->[4];
2941: }
2942: return $currentstring;
2943: }
2944:
2945: sub end_spacer {
2946: my ($target,$token) = @_;
2947: my $currentstring = '';
2948: if ($target eq 'web') {
2949: $currentstring = $token->[2];
2950: }
2951: return $currentstring;
2952: }
2953:
2954: #-- <span> tag
2955: sub start_span {
2956: my ($target,$token) = @_;
2957: my $currentstring = '';
2958: if ($target eq 'web') {
2959: $currentstring = $token->[4];
2960: }
2961: return $currentstring;
2962: }
2963:
2964: sub end_span {
2965: my ($target,$token) = @_;
2966: my $currentstring = '';
2967: if ($target eq 'web') {
2968: $currentstring = $token->[2];
2969: }
2970: return $currentstring;
2971: }
2972:
2973: #-- <tbody> tag
2974: sub start_tbody {
2975: my ($target,$token) = @_;
2976: my $currentstring = '';
2977: if ($target eq 'web') {
2978: $currentstring = $token->[4];
2979: }
2980: return $currentstring;
2981: }
2982:
2983: sub end_tbody {
2984: my ($target,$token) = @_;
2985: my $currentstring = '';
2986: if ($target eq 'web') {
2987: $currentstring = $token->[2];
2988: }
2989: return $currentstring;
2990: }
2991:
2992: #-- <tfoot> tag
2993: sub start_tfoot {
2994: my ($target,$token) = @_;
2995: my $currentstring = '';
2996: if ($target eq 'web') {
2997: $currentstring = $token->[4];
2998: }
2999: return $currentstring;
3000: }
3001:
3002: sub end_tfoot {
3003: my ($target,$token) = @_;
3004: my $currentstring = '';
3005: if ($target eq 'web') {
3006: $currentstring = $token->[2];
3007: }
3008: return $currentstring;
3009: }
3010:
3011: #-- <thead> tag
3012: sub start_thead {
3013: my ($target,$token) = @_;
3014: my $currentstring = '';
3015: if ($target eq 'web') {
3016: $currentstring = $token->[4];
3017: }
3018: return $currentstring;
3019: }
1.10 www 3020:
1.122 albertel 3021: sub end_thead {
3022: my ($target,$token) = @_;
3023: my $currentstring = '';
3024: if ($target eq 'web') {
3025: $currentstring = $token->[2];
3026: }
3027: return $currentstring;
3028: }
1.119 www 3029:
1.122 albertel 3030: #-- <var> tag
3031: sub start_var {
1.44 sakharuk 3032: my ($target,$token) = @_;
3033: my $currentstring = '';
3034: if ($target eq 'web') {
1.122 albertel 3035: $currentstring = $token->[4];
1.44 sakharuk 3036: }
3037: return $currentstring;
3038: }
1.10 www 3039:
1.122 albertel 3040: sub end_var {
3041: my ($target,$token) = @_;
1.44 sakharuk 3042: my $currentstring = '';
3043: if ($target eq 'web') {
1.122 albertel 3044: $currentstring = $token->[2];
1.44 sakharuk 3045: }
3046: return $currentstring;
3047: }
1.119 www 3048:
1.122 albertel 3049: #-- <wbr> tag
3050: sub start_wbr {
3051: my ($target,$token) = @_;
3052: my $currentstring = '';
3053: if ($target eq 'web') {
3054: $currentstring = $token->[4];
3055: }
3056: return $currentstring;
1.98 albertel 3057: }
3058:
1.122 albertel 3059: sub end_wbr {
3060: my ($target,$token) = @_;
3061: my $currentstring = '';
3062: if ($target eq 'web') {
3063: $currentstring = $token->[2];
3064: }
3065: return $currentstring;
1.98 albertel 3066: }
1.134 sakharuk 3067:
3068:
3069: #-- <hideweboutput> tag
3070: sub start_hideweboutput {
3071: my ($target,$token) = @_;
3072: if ($target eq 'web') {
3073: &Apache::lonxml::startredirection();
3074: }
3075: return '';
3076: }
3077:
3078: sub end_hideweboutput {
3079: my ($target,$token) = @_;
3080: my $currentstring = '';
3081: if ($target eq 'web') {
3082: $currentstring = &Apache::lonxml::endredirection();
3083: }
3084: return '';
3085: }
3086:
1.94 sakharuk 3087:
3088: sub image_replication {
3089: my $src = shift;
1.118 www 3090: if (not -e $src) {
1.94 sakharuk 3091: #replicates image itself
1.118 www 3092: &Apache::lonnet::repcopy($src);
1.94 sakharuk 3093: #replicates eps or ps
3094: my $newsrc = $src;
1.118 www 3095: $newsrc =~ s/\.(gif|jpg|jpeg|png)$/.eps/i;
3096: if (not -e $newsrc) {
1.122 albertel 3097: if (&Apache::lonnet::repcopy($newsrc) ne 'OK') {
3098: $newsrc =~ s/\.eps$/\.ps/;
3099: &Apache::lonnet::repcopy($newsrc);
3100: }
1.94 sakharuk 3101: }
3102: }
3103: return '';
1.126 sakharuk 3104: }
3105:
3106: sub recalc {
3107: my $argument = shift;
3108: if (not $argument=~/(mm|cm|in|pc|pt)/) {return $argument.' mm';}
1.132 sakharuk 3109: $argument=~/\s*(\d+\.?\d*)\s*(mm|cm|in|pc|pt)/;
1.126 sakharuk 3110: my $value=$1;
3111: my $units=$2;
3112: if ($units eq 'cm') {
3113: $value*=10;
3114: } elsif ($units eq 'in') {
3115: $value*=25.4;
3116: } elsif ($units eq 'pc') {
3117: $value*=(25.4*12/72.27);
3118: } elsif ($units eq 'pt') {
3119: $value*=(25.4/72.27);
3120: }
3121: return $value.' mm';
1.94 sakharuk 3122: }
3123:
1.1 sakharuk 3124: 1;
3125: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>