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