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