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