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