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