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