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