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