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