Annotation of loncom/xml/londefdef.pm, revision 1.444
1.1 sakharuk 1: # The LearningOnline Network with CAPA
2: # Tags Default Definition Module
3: #
1.444 ! raeburn 4: # $Id: londefdef.pm,v 1.443 2013/05/05 00:10:16 raeburn 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: #
1.1 sakharuk 39:
1.2 albertel 40: package Apache::londefdef;
1.1 sakharuk 41:
1.267 albertel 42: use Apache::lonnet;
1.1 sakharuk 43: use strict;
1.124 sakharuk 44: use Apache::lonxml;
1.398 foxr 45: use Apache::lontable;
1.70 sakharuk 46: use Image::Magick;
1.118 www 47: use Apache::lonmenu();
48: use Apache::lonmeta();
1.389 www 49: use Apache::lonlocal;
1.427 raeburn 50: use Apache::loncommon();
1.187 albertel 51: use Apache::Constants qw(:common);
1.282 foxr 52: use File::Basename;
1.345 albertel 53: use LONCAPA();
1.302 foxr 54: # use Data::Dumper;
1.160 sakharuk 55:
1.38 harris41 56: BEGIN {
1.15 sakharuk 57:
1.438 droeschl 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','style','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:
1.398 foxr 62:
1.188 albertel 63: sub initialize_londefdef {
64: $Apache::londefdef::TD_redirection=0;
65: @Apache::londefdef::table = ();
66: $Apache::londefdef::select=0;
1.243 albertel 67: undef(@Apache::londefdef::description);
68: @Apache::londefdef::DD=(0);
69: @Apache::londefdef::DT=(0);
1.244 albertel 70: @Apache::londefdef::seenDT=(0);
1.238 albertel 71: $Apache::londefdef::list_index=0;
1.327 albertel 72: undef($Apache::londefdef::head);
73: undef($Apache::londefdef::title);
1.3 sakharuk 74: }
1.1 sakharuk 75:
1.35 sakharuk 76: #======================= TAG SUBROUTINES =====================
1.8 sakharuk 77: #-- <output>
1.21 albertel 78: sub start_output {
1.122 albertel 79: my ($target) = @_;
80: if ($target eq 'meta') { $Apache::lonxml::metamode--; }
81: return '';
1.21 albertel 82: }
83: sub end_output {
1.122 albertel 84: my ($target) = @_;
85: if ($target eq 'meta') { $Apache::lonxml::metamode++; }
86: return '';
1.21 albertel 87: }
1.4 sakharuk 88: #-- <m> tag
1.33 albertel 89: sub start_m {
1.190 albertel 90: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style) = @_;
1.122 albertel 91: my $currentstring = '';
1.193 albertel 92: my $inside = &Apache::lonxml::get_all_text_unbalanced("/m",$parser);
1.191 albertel 93: if ($target eq 'web' || $target eq 'analyze') {
1.122 albertel 94: &Apache::lonxml::debug("M is starting with:$inside:");
95: my $eval=&Apache::lonxml::get_param('eval',$parstack,$safeeval);
96: if ($eval eq 'on') {
97: $inside=&Apache::run::evaluate($inside,$safeeval,$$parstack[-1]);
1.392 bisitz 98: #&Apache::lonxml::debug("M is evaluated to:$inside:");
1.122 albertel 99: }
1.317 albertel 100: my $tex = $inside;
1.276 albertel 101: my $display=&Apache::lonxml::get_param('display',$parstack,$safeeval);
102: $currentstring = &Apache::lontexconvert::converted(\$inside,$display);
1.122 albertel 103: if ($Apache::lontexconvert::errorstring) {
1.392 bisitz 104: my $errormsg='<pre>'.&HTML::Entities::encode($Apache::lontexconvert::errorstring,'<>&"').'</pre> occurred while attempting to convert this TeX: <pre>';
1.317 albertel 105: $tex = &HTML::Entities::encode($tex,'<>&"');
106: my ($linenumber) =
107: ($Apache::lontexconvert::errorstring =~ /Line (\d+)/);
108: if (defined($linenumber)) {
109: my @tex=split("\n",$tex);
110: $tex[$linenumber]='<b><font color="red">'.
111: $tex[$linenumber].'</font></b>';
112: $tex=join("\n",@tex);
113: }
114: &Apache::lonxml::warning($errormsg.$tex.'</pre>');
1.122 albertel 115: $Apache::lontexconvert::errorstring='';
116: }
117: #&Apache::lonxml::debug("M is ends with:$currentstring:");
1.178 albertel 118: $Apache::lonxml::post_evaluate=0;
1.122 albertel 119: } elsif ($target eq 'tex') {
1.360 foxr 120:
1.190 albertel 121: $currentstring = $inside;
1.178 albertel 122: my $eval=&Apache::lonxml::get_param('eval',$parstack,$safeeval);
123: if ($eval eq 'on') {
124: $currentstring=&Apache::run::evaluate($currentstring,$safeeval,$$parstack[-1]);
125: }
1.122 albertel 126: if ($currentstring=~/^(\s*\\\\\s*)*$/) {$currentstring = ' \vskip 0 mm ';}
1.257 albertel 127: # detect simple math mode entry exits, and convert them
1.360 foxr 128: # to use \ensuremath ... unless there's a \verb inside.
129: if (! ($currentstring=~/\\verb/)) {
1.395 raeburn 130: if ($currentstring=~/^\s*\$[^\$].*\$\s*$/) {
1.360 foxr 131: $currentstring=~s/^(\s*)\$/$1/;
132: $currentstring=~s/\$(\s*)$/$1/;
133: $currentstring='\ensuremath{'.$currentstring.'}';
134: }
1.257 albertel 135: }
1.178 albertel 136: $Apache::lonxml::post_evaluate=0;
1.122 albertel 137: }
138: return $currentstring;
1.33 albertel 139: }
1.122 albertel 140:
1.33 albertel 141: sub end_m {
1.122 albertel 142: my ($target,$token) = @_;
143: my $currentstring = '';
1.204 albertel 144: if ($target eq 'tex') {
1.122 albertel 145: $currentstring = "";
146: }
147: return $currentstring;
1.33 albertel 148: }
1.110 albertel 149:
150: sub start_tthoption {
1.299 albertel 151: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style) = @_;
1.122 albertel 152: my $result;
1.325 albertel 153: if ($target eq 'web' || $target eq 'webgrade') {
1.299 albertel 154: my $inside = &Apache::lonxml::get_all_text("/tthoption",$parser,
155: $style);
1.122 albertel 156: $inside=~s/^\s*//;
1.267 albertel 157: if ($env{'browser.mathml'}) {
1.122 albertel 158: &tth::ttmoptions($inside);
159: } else {
160: &tth::tthoptions($inside);
161: }
162: }
163: return $result;
1.110 albertel 164: }
165:
166: sub end_tthoption {
1.122 albertel 167: my ($target,$token) = @_;
168: my $result;
169: return $result;
1.110 albertel 170: }
171:
1.181 sakharuk 172: #-- <html> tag (end tag optional)
1.100 albertel 173: sub start_html {
174: my ($target,$token) = @_;
175: my $currentstring = '';
1.269 albertel 176: if ($target eq 'web' || $target eq 'edit' || $target eq 'webgrade' ) {
1.327 albertel 177: # start_body() takes care of emitting the <html>
1.100 albertel 178: } elsif ($target eq 'tex') {
1.391 onken 179:
1.399 foxr 180: $currentstring .= &latex_header();
1.100 albertel 181: }
182: return $currentstring;
183: }
1.122 albertel 184:
185: sub end_html {
1.232 sakharuk 186: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1.122 albertel 187: my $currentstring = '';
1.324 albertel 188: if ($target eq 'web' || $target eq 'webgrade') {
1.327 albertel 189: # end_body takes care of the </html>
1.122 albertel 190: }
191: return $currentstring;
192: }
193:
1.181 sakharuk 194: #-- <head> tag (end tag optional)
1.122 albertel 195: sub start_head {
196: my ($target,$token) = @_;
197: my $currentstring = '';
1.324 albertel 198: if ($target eq 'web' || $target eq 'webgrade') {
1.327 albertel 199: &Apache::lonxml::startredirection();
1.122 albertel 200: }
201: return $currentstring;
202: }
203:
204: sub end_head {
205: my ($target,$token) = @_;
206: my $currentstring = '';
1.324 albertel 207: if (($target eq 'web' && $env{'request.state'} eq 'published') ||
208: ($target eq 'webgrade' && $env{'request.state'} eq 'published')) {
1.327 albertel 209: # in case there is a </head> but no <head>
210: if ($Apache::lonxml::redirection) {
211: $Apache::londefdef::head = &Apache::lonxml::endredirection();
212: }
1.122 albertel 213: }
214: return $currentstring;
215: }
216:
1.181 sakharuk 217: #-- <map> tag (end tag required)
1.122 albertel 218: sub start_map {
219: my ($target,$token) = @_;
220: my $currentstring = '';
1.325 albertel 221: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 222: $currentstring = $token->[4];
223: }
224: return $currentstring;
225: }
226:
227: sub end_map {
228: my ($target,$token) = @_;
229: my $currentstring = '';
1.325 albertel 230: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 231: $currentstring = $token->[2];
232: }
233: return $currentstring;
234: }
235:
1.181 sakharuk 236: #-- <select> tag (end tag required)
1.122 albertel 237: sub start_select {
238: my ($target,$token) = @_;
239: my $currentstring = '';
1.325 albertel 240: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 241: $currentstring = $token->[4];
1.181 sakharuk 242: } elsif ($target eq 'tex') {
243: $Apache::londefdef::select=0;
244: }
1.122 albertel 245: return $currentstring;
246: }
247:
248: sub end_select {
249: my ($target,$token) = @_;
250: my $currentstring = '';
1.325 albertel 251: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 252: $currentstring = $token->[2];
253: }
254: return $currentstring;
255: }
256:
1.181 sakharuk 257: #-- <option> tag (end tag optional)
1.122 albertel 258: sub start_option {
1.181 sakharuk 259: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1.122 albertel 260: my $currentstring = '';
1.325 albertel 261: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 262: $currentstring = $token->[4];
1.181 sakharuk 263: } elsif ($target eq 'tex') {
264: $Apache::londefdef::select++;
265: if ($Apache::londefdef::select == 1) {
266: $currentstring='\noindent\fbox{'.&Apache::lonxml::get_param('value',$parstack,$safeeval).'}\keephidden{';
267: } else {
268: $currentstring='\keephidden{';
269: }
270: }
1.122 albertel 271: return $currentstring;
272: }
273:
274: sub end_option {
275: my ($target,$token) = @_;
276: my $currentstring = '';
1.325 albertel 277: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 278: $currentstring = $token->[2];
1.181 sakharuk 279: } elsif ($target eq 'tex') {
280: $currentstring='}';
281: }
1.122 albertel 282: return $currentstring;
283: }
284:
1.181 sakharuk 285: #-- <input> tag (end tag forbidden)
1.122 albertel 286: sub start_input {
287: my ($target,$token) = @_;
288: my $currentstring = '';
1.325 albertel 289: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 290: $currentstring = $token->[4];
291: }
292: return $currentstring;
293: }
294:
295: sub end_input {
296: my ($target,$token) = @_;
297: my $currentstring = '';
1.325 albertel 298: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 299: $currentstring = $token->[2];
300: }
301: return $currentstring;
302: }
303:
1.181 sakharuk 304: #-- <textarea> tag (end tag required)
1.122 albertel 305: sub start_textarea {
306: my ($target,$token) = @_;
307: my $currentstring = '';
1.325 albertel 308: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 309: $currentstring = $token->[4];
310: }
311: return $currentstring;
312: }
313:
314: sub end_textarea {
315: my ($target,$token) = @_;
316: my $currentstring = '';
1.325 albertel 317: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 318: $currentstring = $token->[2];
319: }
320: return $currentstring;
321: }
322:
1.181 sakharuk 323: #-- <form> tag (end tag required)
1.122 albertel 324: sub start_form {
325: my ($target,$token) = @_;
326: my $currentstring = '';
1.325 albertel 327: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 328: $currentstring = $token->[4];
329: }
330: return $currentstring;
331: }
332:
333: sub end_form {
334: my ($target,$token) = @_;
335: my $currentstring = '';
1.325 albertel 336: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 337: $currentstring = $token->[2];
338: }
339: return $currentstring;
340: }
341:
1.181 sakharuk 342: #-- <title> tag (end tag required)
1.122 albertel 343: sub start_title {
1.327 albertel 344: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style) = @_;
1.122 albertel 345: my $currentstring = '';
1.324 albertel 346: if ($target eq 'web' || $target eq 'webgrade') {
1.327 albertel 347: $Apache::londefdef::title =
348: &Apache::lonxml::get_all_text('/title',$parser,$style);
1.122 albertel 349: } elsif ($target eq 'tex') {
1.166 sakharuk 350: $currentstring .= '\keephidden{Title of the document: '
1.122 albertel 351: }
352: if ($target eq 'meta') {
353: $currentstring='<title>';
1.185 albertel 354: &start_output($target);
1.122 albertel 355: }
356: return $currentstring;
357: }
358:
359: sub end_title {
360: my ($target,$token) = @_;
361: my $currentstring = '';
1.324 albertel 362: if ($target eq 'web' || $target eq 'webgrade') {
1.327 albertel 363: # start_title takes care of swallowing the title
1.122 albertel 364: } elsif ($target eq 'tex') {
365: $currentstring .= '}';
366: }
367: if ($target eq 'meta') {
1.185 albertel 368: &end_output($target);
1.122 albertel 369: $currentstring='</title>';
370: }
371: return $currentstring;
372: }
373:
1.181 sakharuk 374: #-- <meta> tag (end tag forbidden)
1.122 albertel 375: sub start_meta {
1.299 albertel 376: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style) = @_;
1.122 albertel 377: my $currentstring = '';
1.325 albertel 378: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 379: my $args='';
380: if ( $#$parstack > -1 ) { $args=$$parstack[$#$parstack]; }
381: if ($args eq '') {
1.299 albertel 382: &Apache::lonxml::get_all_text("/meta",$parser,$style);
1.122 albertel 383: } else {
384: $currentstring = $token->[4];
1.1 sakharuk 385: }
1.431 raeburn 386: if ($env{'form.grade_imsexport'}) {
387: $currentstring = '';
388: }
1.135 sakharuk 389: } elsif ($target eq 'meta') {
1.122 albertel 390: unless (&Apache::lonxml::get_param
391: ('http-equiv',$parstack,$safeeval,undef,1)) {
392: my $name=$token->[2]->{'name'};
393: $name=~tr/A-Z/a-z/;
394: $name=~s/\s/\_/gs;
395: $name=~s/\W//gs;
396: if ($name) {
1.154 www 397: $currentstring='<'.$name;
398: my $display=&Apache::lonxml::get_param
399: ('display',$parstack,$safeeval,undef,1);
400: if ($display) {
401: $display=~s/\"/\'/g;
402: $currentstring.=' display="'.$display.'"';
403: }
404: $currentstring.='>'.
1.122 albertel 405: &Apache::lonxml::get_param
406: ('content',$parstack,$safeeval,undef,1).
1.135 sakharuk 407: '</'.$name.'>';
1.1 sakharuk 408: }
1.154 www 409: my $display=&Apache::lonxml::get_param
410: ('display',$parstack,$safeeval,undef,1);
411: if ($display) {
1.204 albertel 412: $display=&HTML::Entities::encode($display,'<>&"');
1.154 www 413: $currentstring.='<'.$name.'.display>'.$display.
414: '</'.$name.'.display>';
415: }
1.1 sakharuk 416: }
1.135 sakharuk 417: } elsif ($target eq 'tex') {
1.151 sakharuk 418: my $content=&Apache::lonxml::get_param('content',$parstack,$safeeval);
419: my $name=&Apache::lonxml::get_param('name',$parstack,$safeeval);
420: if ((not defined $content) && (not defined $name)) {
421: &Apache::lonxml::startredirection();
422: }
1.374 albertel 423: } elsif ($target eq 'edit') {
424: $currentstring .= &Apache::edit::tag_start($target,$token);
425: $currentstring .= &Apache::edit::text_arg('Name:','name',$token,30);
426: $currentstring .= &Apache::edit::text_arg('Content:','content',$token,70);
427: $currentstring .= &Apache::edit::end_row();
428: } elsif ($target eq 'modified') {
429: my $constructtag =
430: &Apache::edit::get_new_args($token,$parstack,$safeeval,
431: 'name','content');
432: if ($constructtag) { $currentstring = &Apache::edit::rebuild_tag($token); }
1.122 albertel 433: }
434: return $currentstring;
435: }
436:
437: sub end_meta {
1.165 albertel 438: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1.122 albertel 439: my $currentstring = '';
1.325 albertel 440: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 441: my $args='';
442: if ( $#$parstack > -1 ) { $args=$$parstack[$#$parstack]; }
443: if ($args ne '') {
1.121 www 444: $currentstring = $token->[4];
1.122 albertel 445: }
1.135 sakharuk 446: } elsif ($target eq 'tex') {
1.165 albertel 447: my $content=&Apache::lonxml::get_param('content',$parstack,$safeeval);
448: my $name=&Apache::lonxml::get_param('name',$parstack,$safeeval);
1.164 albertel 449: if ((not defined $content) && (not defined $name)) {
1.169 albertel 450: &Apache::lonxml::endredirection();
1.164 albertel 451: }
1.135 sakharuk 452: }
1.122 albertel 453: return $currentstring;
454: }
455:
1.374 albertel 456: sub insert_meta {
457: return '
458: <meta />';
459: }
460:
1.438 droeschl 461: #-- <start> tag
462: sub start_style {
463: my ($target, $token, $tagstack, $parstack, $parser, $safeeval, $style) = @_;
464: my $currentstring = '';
465:
466: if ($target eq 'tex') {
467: Apache::lonxml::startredirection();
468: } else {
469: $currentstring = $token->[4];
470: }
471:
472: return $currentstring;
473: }
474:
475: sub end_style {
476: my ($target, $token, $tagstack, $parstack, $parser, $safeeval) = @_;
477: my $currentstring = '';
478:
479: if ($target eq 'tex') {
480: Apache::lonxml::endredirection();
481: } else {
482: $currentstring = $token->[2];
483: }
484: return $currentstring;
485: }
486:
1.121 www 487: # accessrule
1.122 albertel 488: sub start_accessrule {
1.299 albertel 489: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style) = @_;
1.122 albertel 490: my $currentstring = '';
1.373 albertel 491: my $eff =&Apache::lonxml::get_param('effect',$parstack,$safeeval,undef,1);
492: my $realm=&Apache::lonxml::get_param('realm', $parstack,$safeeval,undef,1);
493: my $role =&Apache::lonxml::get_param('role', $parstack,$safeeval,undef,1);
494: my $type =&Apache::lonxml::get_param('type', $parstack,$safeeval,undef,1);
495:
496: my ($dom,$crs,$sec,$separator);
1.369 albertel 497: if ($type eq 'user') {
1.373 albertel 498: ($dom,$crs,$sec)=split(m{/},$realm);
1.369 albertel 499: $crs = &LONCAPA::clean_username($crs);
1.373 albertel 500: $separator = '/';
1.369 albertel 501: } else {
1.373 albertel 502: ($dom,$crs,$sec)=split(/\_/,$realm);
1.369 albertel 503: $crs = &LONCAPA::clean_courseid($crs);
1.373 albertel 504: $separator = '_';
1.369 albertel 505: }
1.373 albertel 506: $dom = &LONCAPA::clean_domain($dom);
507:
1.369 albertel 508: $sec =~s/\W//;
509: $realm = $dom;
1.373 albertel 510: if ($crs =~ /\S/) { $realm .= $separator.$crs; }
511: if ($sec =~ /\S/) { $realm .= $separator.$sec; }
1.369 albertel 512: $role=~s/\W//g;
513:
1.122 albertel 514: if ($target eq 'web') {
515: my $args='';
516: if ( $#$parstack > -1 ) { $args=$$parstack[$#$parstack]; }
517: if ($args eq '') {
1.299 albertel 518: &Apache::lonxml::get_all_text("/accessrule",$parser,$style);
1.122 albertel 519: } else {
520: $currentstring = $token->[4];
521: }
522: }
523: if ($target eq 'meta') {
1.369 albertel 524: $currentstring='<rule>'.$eff.':'.$realm.':'.$role.':'.$type.'</rule>';
1.122 albertel 525: }
526: return $currentstring;
527: }
528:
529: sub end_accessrule {
530: my ($target,$token,$tagstack,$parstack,$parser) = @_;
531: my $currentstring = '';
532: if ($target eq 'web') {
533: my $args='';
534: if ( $#$parstack > -1 ) { $args=$$parstack[$#$parstack]; }
535: if ($args ne '') {
536: $currentstring = $token->[4];
537: }
538: }
539: return $currentstring;
540: }
541:
1.366 albertel 542: sub generate_css_links {
543: my $links;
544: my $css_href = &Apache::lonnet::EXT('resource.0.cssfile');
545: if ($css_href =~ /\S/) {
546: &Apache::lonxml::extlink($css_href);
547: $links .=
548: '<link rel="stylesheet" type="text/css" href="'.$css_href.'" />';
549: }
550: return $links;
551: }
552:
1.181 sakharuk 553: #-- <body> tag (end tag required)
1.122 albertel 554: sub start_body {
555: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
556: my $currentstring = '';
1.244 albertel 557:
1.324 albertel 558: if ($target eq 'web' || $target eq 'webgrade') {
1.170 albertel 559: if ($Apache::lonhomework::parsing_a_problem) {
560: &Apache::lonxml::warning("<body> tag found inside of <problem> tag this can cause problems.");
561: return '';
562: }
1.122 albertel 563:
1.327 albertel 564: if (&is_inside_of($tagstack, "head")) {
565: &end_head(@_);
1.122 albertel 566: }
1.366 albertel 567:
568: my $extra_head = &generate_css_links();
569:
1.406 bisitz 570: # Breadcrumbs
571: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.410 bisitz 572: if ($env{'request.state'} eq 'construct') {
1.436 raeburn 573: my $url=&Apache::lonnet::hreflocation('',$env{'request.filename'});
1.410 bisitz 574: &Apache::lonhtmlcommon::add_breadcrumb({
1.444 ! raeburn 575: 'text' => 'Authoring Space',
1.436 raeburn 576: 'href' => &Apache::loncommon::authorspace($url),
1.410 bisitz 577: });
578: &Apache::lonhtmlcommon::add_breadcrumb({
579: 'text' => 'HTML Editor',
580: 'href' => '',
581: });
1.413 droeschl 582: # breadcrumbs (and tools) will be created
583: # in start_page->bodytag->innerregister
1.410 bisitz 584: } else {
585: # FIXME Where are we?
586: }
1.406 bisitz 587:
1.327 albertel 588: $currentstring =
589: &Apache::loncommon::start_page($Apache::londefdef::title,
1.366 albertel 590: $Apache::londefdef::head
591: .$extra_head,
1.327 albertel 592: {'add_entries' => $token->[2],
1.404 bisitz 593: # 'no_title' => 1,
1.327 albertel 594: 'force_register' => 1});
595:
1.407 bisitz 596: my $header = '';
1.411 bisitz 597: if ($env{'request.state'} ne 'published' &&
598: $env{'request.state'} ne 'construct') {
599: $header=&Apache::lonmenu::constspaceform();
600: }
1.407 bisitz 601: if ($env{'request.state'} ne 'published') {
1.441 raeburn 602: $header.=&edit_controls();
1.407 bisitz 603: }
1.410 bisitz 604: if ($env{'request.state'} eq 'construct') {
605: $currentstring.=&Apache::loncommon::head_subbox(
606: &Apache::loncommon::CSTR_pageheader()
607: .$header);
1.412 raeburn 608: } elsif ($env{'request.state'} eq 'edit') {
609: $currentstring.=&Apache::loncommon::head_subbox($header);
1.410 bisitz 610: }
1.407 bisitz 611: $currentstring.=&Apache::lonxml::message_location();
1.122 albertel 612: } elsif ($target eq 'tex') {
1.407 bisitz 613: $currentstring = ''; # '\begin{document}' is in header.
614: }
615:
1.122 albertel 616: return $currentstring;
617: }
618:
1.376 albertel 619: sub edit_controls {
1.401 raeburn 620: my ($nochgview) = @_;
1.389 www 621: my $result .= '
1.427 raeburn 622: <form method="post" action="">
1.401 raeburn 623: <div class="LC_edit_problem_header">';
624: unless ($nochgview) {
625: $result .= '
1.389 www 626: <div class="LC_edit_problem_header_row1">'.
627: &Apache::lonxml::renderingoptions().'
628: <input type="submit" name="changeproblemmode" value="'.&mt('Change View').'" />
1.401 raeburn 629: </div>';
630: }
631: $result .= '
1.412 raeburn 632: <div><input type="submit" name="editmode" accesskey="e" value="'.&mt('Edit').'" />';
633: if (($env{'request.course.id'}) && ($env{'form.forceedit'})) {
1.439 raeburn 634: my $url=&Apache::lonnet::hreflocation('',$env{'request.filename'});
635: if ($url =~ /\.html?$/i) {
1.443 raeburn 636: my ($cdom,$cnum);
1.441 raeburn 637: if ($env{'request.course.id'}) {
1.443 raeburn 638: $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
639: $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
1.441 raeburn 640: if ($env{'request.filename'} =~ m{/userfiles/supplemental/default|\d+/}) {
641: if (&Apache::lonnet::is_course_upload($env{'request.filename'},
1.443 raeburn 642: $cnum,$cdom)) {
1.441 raeburn 643: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
644: ['folderpath','title']);
645: }
646: }
647: }
1.443 raeburn 648: my ($symb,$itemtitle,$displayfile,$caller);
649: if ($url =~ m{^/uploaded/$cdom/$cnum/portfolio/syllabus/}) {
650: $itemtitle = &mt('Syllabus');
651: $caller = "/public/$cdom/$cnum/syllabus";
652: } else {
653: $caller = $url;
654: ($symb,$itemtitle,$displayfile) =
655: &Apache::lonxml::get_courseupload_hierarchy($url,
656: $env{'form.folderpath'},
657: $env{'form.title'});
658: }
659: if (($symb ne '') || ($env{'httpref.'.$url} ne '') ||
660: ($url =~ m{^/uploaded/$cdom/$cnum/portfolio/syllabus/})) {
1.439 raeburn 661: $result .= (' ' x 3).
662: &Apache::lonhtmlcommon::dependencies_button()."\n".
1.441 raeburn 663: &Apache::lonhtmlcommon::dependencycheck_js($symb,
1.443 raeburn 664: $itemtitle,$url,$env{'form.folderpath'},$caller)."\n";
1.439 raeburn 665: }
666: }
1.412 raeburn 667: }
668: $result .= '</div>
1.408 bisitz 669: </div>
1.376 albertel 670: </form>
1.408 bisitz 671: ';
1.376 albertel 672: return $result;
673: }
674:
1.122 albertel 675: sub end_body {
1.259 albertel 676: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1.279 foxr 677: my $currentstring = &end_p(); # Close off unclosed <p>
1.324 albertel 678: if ($target eq 'web' || $target eq 'webgrade') {
1.327 albertel 679: $currentstring .= &Apache::loncommon::end_page({'discussion' => 1});
1.122 albertel 680: } elsif ($target eq 'tex') {
1.277 foxr 681: $currentstring .= '\strut\newline\noindent\makebox[\textwidth/$number_of_columns][b]{\hrulefill}\newline\noindent \end{document}';
1.122 albertel 682: }
683: return $currentstring;
684: }
685:
1.309 albertel 686: # \begin{center} causes a new paragprah spacing that looks odd inside
1.337 foxr 687: # of a table cell. Same at the end of a \center but with a slightly
688: # larger space .. hence center_correction and center_end_correction.
689: #
690: sub center_correction { return '\vspace*{-6 mm}'; }
691: sub center_end_correction { return '\vspace*{-7 mm}'; }
692:
1.181 sakharuk 693: #-- <center> tag (end tag required)
1.122 albertel 694: sub start_center {
1.309 albertel 695: my ($target,$token,$tagstack) = @_;
1.279 foxr 696: my $currentstring = &end_p(); # Close off any prior para.
1.325 albertel 697: if ($target eq 'web' || $target eq 'webgrade') {
1.277 foxr 698: $currentstring .= $token->[4];
1.122 albertel 699: } elsif ($target eq 'tex') {
1.309 albertel 700: if (&is_inside_of($tagstack, "table")) {
701: $currentstring .= ¢er_correction();
702: }
1.277 foxr 703: $currentstring .= '\begin{center}';
1.144 sakharuk 704: }
1.122 albertel 705: return $currentstring;
706: }
707:
708: sub end_center {
1.309 albertel 709: my ($target,$token,$tagstack) = @_;
1.122 albertel 710: my $currentstring = '';
1.325 albertel 711: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 712: $currentstring = $token->[2];
713: } elsif ($target eq 'tex') {
714: $currentstring = '\end{center}';
1.337 foxr 715: if (&is_inside_of($tagstack, "table")) {
716: $currentstring .= ¢er_end_correction();
717: }
1.144 sakharuk 718: }
1.122 albertel 719: return $currentstring;
720: }
721:
1.181 sakharuk 722: #-- <b> tag (end tag required)
1.279 foxr 723: # NOTE: In TeX mode disables internal <p>
1.122 albertel 724: sub start_b {
725: my ($target,$token) = @_;
726: my $currentstring = '';
1.325 albertel 727: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 728: $currentstring = $token->[4];
729: } elsif ($target eq 'tex') {
1.279 foxr 730: &disable_para();
731: $currentstring .= '\textbf{';
1.122 albertel 732: }
733: return $currentstring;
734: }
735:
736: sub end_b {
737: my ($target,$token) = @_;
738: my $currentstring = '';
1.325 albertel 739: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 740: $currentstring = $token->[2];
741: } elsif ($target eq 'tex') {
1.279 foxr 742: &enable_para();
743: $currentstring = '}';
1.122 albertel 744: }
745: return $currentstring;
746: }
1.35 sakharuk 747:
1.181 sakharuk 748: #-- <strong> tag (end tag required)
1.279 foxr 749: # NOTE: in TeX mode disables internal <p>
1.122 albertel 750: sub start_strong {
751: my ($target,$token) = @_;
752: my $currentstring = '';
1.325 albertel 753: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 754: $currentstring = $token->[4];
755: } elsif ($target eq 'tex') {
1.279 foxr 756: &disable_para();
1.122 albertel 757: $currentstring = '\textbf{';
758: }
759: return $currentstring;
760: }
761:
762: sub end_strong {
763: my ($target,$token) = @_;
764: my $currentstring = '';
1.325 albertel 765: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 766: $currentstring = $token->[2];
767: } elsif ($target eq 'tex') {
1.279 foxr 768: &enable_para();
1.122 albertel 769: $currentstring = '}';
1.144 sakharuk 770: }
1.122 albertel 771: return $currentstring;
772: }
773:
1.181 sakharuk 774: #-- <h1> tag (end tag required)
1.122 albertel 775: sub start_h1 {
1.125 sakharuk 776: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1.279 foxr 777: my $currentstring = &end_p(); # Close off any prior para.
1.325 albertel 778: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 779: $currentstring .= $token->[4];
780: } elsif ($target eq 'tex') {
1.125 sakharuk 781: my $pre;
1.199 albertel 782: my $align=lc(&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1));
1.212 sakharuk 783: if ($align eq 'center') {
1.125 sakharuk 784: $pre='\begin{center}';
785: } elsif ($align eq 'left') {
786: $pre='\rlap{';
787: } elsif ($align eq 'right') {
788: $pre=' \hfill \llap{';
789: }
790: my $TeXsize=&Apache::lonxml::get_param('TeXsize',$parstack,$safeeval,undef,0);
791: if (not defined $TeXsize) {$TeXsize="large";}
1.275 foxr 792: $currentstring .= '\strut\newline '.$pre.'{\\'.$TeXsize.' \textbf{';
1.122 albertel 793: } elsif ($target eq 'meta') {
1.277 foxr 794: $currentstring.='<subject>';
1.185 albertel 795: &start_output($target);
1.122 albertel 796: }
797: return $currentstring;
798: }
799:
800: sub end_h1 {
1.125 sakharuk 801: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1.122 albertel 802: my $currentstring = '';
1.325 albertel 803: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 804: $currentstring .= $token->[2];
805: } elsif ($target eq 'tex') {
1.212 sakharuk 806: my $post='\vskip 0 mm ';
1.125 sakharuk 807: my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1);
1.212 sakharuk 808: if ($align eq 'center') {
1.125 sakharuk 809: $post='\end{center}';
810: } elsif ($align eq 'left') {
811: $post='} \hfill'.'\vskip 0 mm ';
812: } elsif ($align eq 'right') {
813: $post='}'.'\vskip 0 mm ';
814: }
815: $currentstring .= '}}'.$post;
1.122 albertel 816: } elsif ($target eq 'meta') {
1.185 albertel 817: &end_output($target);
1.122 albertel 818: $currentstring='</subject>';
819: }
820: return $currentstring;
821: }
822:
1.35 sakharuk 823: #-- <h2> tag
1.122 albertel 824: sub start_h2 {
1.125 sakharuk 825: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1.279 foxr 826: my $currentstring = &end_p(); # Close off any prior para.
1.325 albertel 827: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 828: $currentstring .= $token->[4];
829: } elsif ($target eq 'tex') {
1.125 sakharuk 830: my $pre;
831: my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1);
1.212 sakharuk 832: if ($align eq 'center') {
1.125 sakharuk 833: $pre='\begin{center}';
834: } elsif ($align eq 'left') {
835: $pre='\rlap{';
836: } elsif ($align eq 'right') {
837: $pre=' \hfill \llap{';
838: }
839: my $TeXsize=&Apache::lonxml::get_param('TeXsize',$parstack,$safeeval,undef,0);
840: if (not defined $TeXsize) {$TeXsize="large";}
1.275 foxr 841: $currentstring .= '\strut\newline '.$pre.'{\\'.$TeXsize.' \textbf{';
1.122 albertel 842: }
843: return $currentstring;
844: }
845:
846: sub end_h2 {
1.125 sakharuk 847: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1.122 albertel 848: my $currentstring = '';
1.325 albertel 849: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 850: $currentstring .= $token->[2];
851: } elsif ($target eq 'tex') {
1.212 sakharuk 852: my $post='\vskip 0 mm ';
1.125 sakharuk 853: my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1);
1.212 sakharuk 854: if ($align eq 'center') {
1.125 sakharuk 855: $post='\end{center}';
856: } elsif ($align eq 'left') {
857: $post='} \hfill'.'\vskip 0 mm ';
858: } elsif ($align eq 'right') {
859: $post='}'.'\vskip 0 mm ';
860: }
861: $currentstring .= '}}'.$post;
1.122 albertel 862: }
863: return $currentstring;
864: }
865:
1.35 sakharuk 866: #-- <h3> tag
1.122 albertel 867: sub start_h3 {
1.125 sakharuk 868: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1.279 foxr 869: my $currentstring = &end_p(); # Close off any prior para.
1.325 albertel 870: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 871: $currentstring .= $token->[4];
872: } elsif ($target eq 'tex') {
1.125 sakharuk 873: my $pre;
874: my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1);
1.212 sakharuk 875: if ($align eq 'center') {
1.125 sakharuk 876: $pre='\begin{center}';
877: } elsif ($align eq 'left') {
878: $pre='\rlap{';
879: } elsif ($align eq 'right') {
880: $pre=' \hfill \llap{';
881: }
882: my $TeXsize=&Apache::lonxml::get_param('TeXsize',$parstack,$safeeval,undef,0);
883: if (not defined $TeXsize) {$TeXsize="large";}
1.275 foxr 884: $currentstring .= '\strut\newline '.$pre.'{\\'.$TeXsize.' \textbf{';
1.122 albertel 885: }
886: return $currentstring;
887: }
888:
889: sub end_h3 {
1.125 sakharuk 890: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1.122 albertel 891: my $currentstring = '';
1.325 albertel 892: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 893: $currentstring .= $token->[2];
894: } elsif ($target eq 'tex') {
1.212 sakharuk 895: my $post='\vskip 0 mm ';
1.125 sakharuk 896: my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1);
1.212 sakharuk 897: if ($align eq 'center') {
1.125 sakharuk 898: $post='\end{center}';
899: } elsif ($align eq 'left') {
900: $post='} \hfill'.'\vskip 0 mm ';
901: } elsif ($align eq 'right') {
902: $post='}'.'\vskip 0 mm ';
903: }
904: $currentstring .= '}}'.$post;
1.122 albertel 905: }
906: return $currentstring;
907: }
908:
1.35 sakharuk 909: #-- <h4> tag
1.122 albertel 910: sub start_h4 {
1.125 sakharuk 911: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1.279 foxr 912: my $currentstring = &end_p(); # Close off any prior para.
1.325 albertel 913: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 914: $currentstring .= $token->[4];
915: } elsif ($target eq 'tex') {
1.125 sakharuk 916: my $pre;
917: my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1);
1.212 sakharuk 918: if ($align eq 'center') {
1.125 sakharuk 919: $pre='\begin{center}';
920: } elsif ($align eq 'left') {
921: $pre='\rlap{';
922: } elsif ($align eq 'right') {
923: $pre=' \hfill \llap{';
924: }
925: my $TeXsize=&Apache::lonxml::get_param('TeXsize',$parstack,$safeeval,undef,0);
926: if (not defined $TeXsize) {$TeXsize="large";}
1.275 foxr 927: $currentstring .= '\strut\newline '.$pre.'{\\'.$TeXsize.' \textbf{';
1.122 albertel 928: }
929: return $currentstring;
930: }
931:
932: sub end_h4 {
1.125 sakharuk 933: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1.122 albertel 934: my $currentstring = '';
1.325 albertel 935: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 936: $currentstring .= $token->[2];
937: } elsif ($target eq 'tex') {
1.212 sakharuk 938: my $post='\vskip 0 mm ';
1.125 sakharuk 939: my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1);
1.212 sakharuk 940: if ($align eq 'center') {
1.125 sakharuk 941: $post='\end{center}';
942: } elsif ($align eq 'left') {
943: $post='} \hfill'.'\vskip 0 mm ';
944: } elsif ($align eq 'right') {
945: $post='}'.'\vskip 0 mm ';
946: }
947: $currentstring .= '}}'.$post;
1.122 albertel 948: }
949: return $currentstring;
950: }
951:
1.35 sakharuk 952: #-- <h5> tag
1.122 albertel 953: sub start_h5 {
1.125 sakharuk 954: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1.279 foxr 955: my $currentstring = &end_p(); # Close off any prior paras.
1.325 albertel 956: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 957: $currentstring .= $token->[4];
958: } elsif ($target eq 'tex') {
1.125 sakharuk 959: my $pre;
960: my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1);
1.212 sakharuk 961: if ($align eq 'center') {
1.125 sakharuk 962: $pre='\begin{center}';
963: } elsif ($align eq 'left') {
964: $pre='\rlap{';
965: } elsif ($align eq 'right') {
966: $pre=' \hfill \llap{';
967: }
968: my $TeXsize=&Apache::lonxml::get_param('TeXsize',$parstack,$safeeval,undef,0);
969: if (not defined $TeXsize) {$TeXsize="large";}
1.275 foxr 970: $currentstring .= '\strut\newline '.$pre.'{\\'.$TeXsize.' \textbf{';
1.122 albertel 971: }
972: return $currentstring;
973: }
974:
975: sub end_h5 {
1.125 sakharuk 976: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1.122 albertel 977: my $currentstring = '';
1.325 albertel 978: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 979: $currentstring .= $token->[2];
980: } elsif ($target eq 'tex') {
1.212 sakharuk 981: my $post='\vskip 0 mm ';
1.125 sakharuk 982: my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1);
1.212 sakharuk 983: if ($align eq 'center') {
1.125 sakharuk 984: $post='\end{center}';
985: } elsif ($align eq 'left') {
986: $post='} \hfill'.'\vskip 0 mm ';
987: } elsif ($align eq 'right') {
988: $post='}'.'\vskip 0 mm ';
989: }
990: $currentstring .= '}}'.$post;
1.122 albertel 991: }
992: return $currentstring;
993: }
994:
1.35 sakharuk 995: #-- <h6> tag
1.122 albertel 996: sub start_h6 {
1.125 sakharuk 997: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1.279 foxr 998: my $currentstring = &end_p(); # Close off any prior paras.
1.325 albertel 999: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 1000: $currentstring .= $token->[4];
1001: } elsif ($target eq 'tex') {
1.125 sakharuk 1002: my $pre;
1003: my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1);
1.212 sakharuk 1004: if ($align eq 'center') {
1.125 sakharuk 1005: $pre='\begin{center}';
1006: } elsif ($align eq 'left') {
1007: $pre='\rlap{';
1008: } elsif ($align eq 'right') {
1009: $pre=' \hfill \llap{';
1010: }
1011: my $TeXsize=&Apache::lonxml::get_param('TeXsize',$parstack,$safeeval,undef,0);
1012: if (not defined $TeXsize) {$TeXsize="large";}
1.275 foxr 1013: $currentstring .= '\strut\newline '.$pre.'{\\'.$TeXsize.' \textbf{';
1.122 albertel 1014: }
1015: return $currentstring;
1016: }
1017:
1018: sub end_h6 {
1.125 sakharuk 1019: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1.122 albertel 1020: my $currentstring = '';
1.325 albertel 1021: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 1022: $currentstring .= $token->[2];
1023: } elsif ($target eq 'tex') {
1.212 sakharuk 1024: my $post='\vskip 0 mm ';
1.125 sakharuk 1025: my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1);
1.212 sakharuk 1026: if ($align eq 'center') {
1.125 sakharuk 1027: $post='\end{center}';
1028: } elsif ($align eq 'left') {
1029: $post='} \hfill'.'\vskip 0 mm ';
1030: } elsif ($align eq 'right') {
1031: $post='}'.'\vskip 0 mm ';
1032: }
1033: $currentstring .= '}}'.$post;
1.122 albertel 1034: }
1035: return $currentstring;
1036: }
1037:
1.181 sakharuk 1038: #--- <cite> tag (end tag required)
1.122 albertel 1039: sub start_cite {
1040: my ($target,$token) = @_;
1041: my $currentstring = '';
1.325 albertel 1042: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 1043: $currentstring .= $token->[4];
1044: } elsif ($target eq 'tex') {
1.179 sakharuk 1045: $currentstring .= '\textit{';
1.144 sakharuk 1046: }
1.122 albertel 1047: return $currentstring;
1048: }
1049:
1050: sub end_cite {
1051: my ($target,$token) = @_;
1052: my $currentstring = '';
1.325 albertel 1053: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 1054: $currentstring .= $token->[2];
1055: } elsif ($target eq 'tex') {
1.179 sakharuk 1056: $currentstring .= '}';
1.144 sakharuk 1057: }
1.122 albertel 1058: return $currentstring;
1059: }
1060:
1.181 sakharuk 1061: #-- <i> tag (end tag required)
1.122 albertel 1062: sub start_i {
1063: my ($target,$token) = @_;
1064: my $currentstring = '';
1.325 albertel 1065: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 1066: $currentstring .= $token->[4];
1067: } elsif ($target eq 'tex') {
1068: $currentstring .= '\textit{';
1.144 sakharuk 1069: }
1.122 albertel 1070: return $currentstring;
1071: }
1072:
1073: sub end_i {
1074: my ($target,$token) = @_;
1075: my $currentstring = '';
1.325 albertel 1076: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 1077: $currentstring .= $token->[2];
1078: } elsif ($target eq 'tex') {
1079: $currentstring .= '}';
1080: }
1081: return $currentstring;
1082: }
1083:
1.181 sakharuk 1084: #-- <address> tag (end tag required)
1.122 albertel 1085: sub start_address {
1086: my ($target,$token) = @_;
1087: my $currentstring = '';
1.325 albertel 1088: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 1089: $currentstring .= $token->[4];
1090: } elsif ($target eq 'tex') {
1.179 sakharuk 1091: $currentstring .= '\textit{';
1.144 sakharuk 1092: }
1.122 albertel 1093: return $currentstring;
1094: }
1095:
1096: sub end_address {
1097: my ($target,$token) = @_;
1098: my $currentstring = '';
1.325 albertel 1099: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 1100: $currentstring .= $token->[2];
1101: } elsif ($target eq 'tex') {
1.179 sakharuk 1102: $currentstring .= '}';
1.122 albertel 1103: }
1104: return $currentstring;
1105: }
1106:
1.181 sakharuk 1107: #-- <dfn> tag (end tag required)
1.122 albertel 1108: sub start_dfn {
1109: my ($target,$token) = @_;
1110: my $currentstring = '';
1.325 albertel 1111: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 1112: $currentstring .= $token->[4];
1113: } elsif ($target eq 'tex') {
1.179 sakharuk 1114: $currentstring .= '\textit{';
1.122 albertel 1115: }
1116: return $currentstring;
1117: }
1118:
1119: sub end_dfn {
1120: my ($target,$token) = @_;
1121: my $currentstring = '';
1.325 albertel 1122: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 1123: $currentstring .= $token->[2];
1124: } elsif ($target eq 'tex') {
1.179 sakharuk 1125: $currentstring .= '}';
1.144 sakharuk 1126: }
1.122 albertel 1127: return $currentstring;
1128: }
1129:
1.181 sakharuk 1130: #-- <tt> tag (end tag required)
1.122 albertel 1131: sub start_tt {
1132: my ($target,$token) = @_;
1133: my $currentstring = '';
1.325 albertel 1134: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 1135: $currentstring .= $token->[4];
1136: } elsif ($target eq 'tex') {
1137: $currentstring .= '\texttt{';
1.144 sakharuk 1138: }
1.122 albertel 1139: return $currentstring;
1140: }
1141:
1142: sub end_tt {
1143: my ($target,$token) = @_;
1144: my $currentstring = '';
1.325 albertel 1145: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 1146: $currentstring .= $token->[2];
1147: } elsif ($target eq 'tex') {
1148: $currentstring .= '}';
1149: }
1150: return $currentstring;
1151: }
1152:
1.181 sakharuk 1153: #-- <kbd> tag (end tag required)
1.122 albertel 1154: sub start_kbd {
1155: my ($target,$token) = @_;
1156: my $currentstring = '';
1.325 albertel 1157: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 1158: $currentstring .= $token->[4];
1159: } elsif ($target eq 'tex') {
1.179 sakharuk 1160: $currentstring .= '\texttt{';
1.144 sakharuk 1161: }
1.122 albertel 1162: return $currentstring;
1163: }
1164:
1165: sub end_kbd {
1166: my ($target,$token) = @_;
1167: my $currentstring = '';
1.325 albertel 1168: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 1169: $currentstring .= $token->[2];
1170: } elsif ($target eq 'tex') {
1.179 sakharuk 1171: $currentstring .= '}';
1.144 sakharuk 1172: }
1.122 albertel 1173: return $currentstring;
1174: }
1175:
1.181 sakharuk 1176: #-- <code> tag (end tag required)
1.122 albertel 1177: sub start_code {
1178: my ($target,$token) = @_;
1179: my $currentstring = '';
1.325 albertel 1180: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 1181: $currentstring .= $token->[4];
1182: } elsif ($target eq 'tex') {
1183: $currentstring .= '\texttt{';
1184: }
1185: return $currentstring;
1186: }
1187:
1188: sub end_code {
1189: my ($target,$token) = @_;
1190: my $currentstring = '';
1.325 albertel 1191: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 1192: $currentstring .= $token->[2];
1193: } elsif ($target eq 'tex') {
1194: $currentstring .= '}';
1195: }
1196: return $currentstring;
1197: }
1198:
1.181 sakharuk 1199: #-- <em> tag (end tag required)
1.122 albertel 1200: sub start_em {
1201: my ($target,$token) = @_;
1202: my $currentstring = '';
1.325 albertel 1203: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 1204: $currentstring .= $token->[4];
1205: } elsif ($target eq 'tex') {
1206: $currentstring .= '\emph{';
1.144 sakharuk 1207: }
1.122 albertel 1208: return $currentstring;
1209: }
1210:
1211: sub end_em {
1212: my ($target,$token) = @_;
1213: my $currentstring = '';
1.325 albertel 1214: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 1215: $currentstring .= $token->[2];
1216: } elsif ($target eq 'tex') {
1217: $currentstring .= '}';
1.144 sakharuk 1218: }
1.122 albertel 1219: return $currentstring;
1220: }
1221:
1.181 sakharuk 1222: #-- <q> tag (end tag required)
1.122 albertel 1223: sub start_q {
1224: my ($target,$token) = @_;
1225: my $currentstring = '';
1.325 albertel 1226: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 1227: $currentstring .= $token->[4];
1228: } elsif ($target eq 'tex') {
1.179 sakharuk 1229: $currentstring .= '\emph{';
1.122 albertel 1230: }
1231: return $currentstring;
1232: }
1233:
1234: sub end_q {
1235: my ($target,$token) = @_;
1236: my $currentstring = '';
1.325 albertel 1237: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 1238: $currentstring .= $token->[2];
1239: } elsif ($target eq 'tex') {
1.179 sakharuk 1240: $currentstring .= '}';
1.144 sakharuk 1241: }
1.122 albertel 1242: return $currentstring;
1243: }
1244:
1.277 foxr 1245: # <p> is a bit strange since it does not require a closing </p>
1246: # However in latex, we must often output closing stuff to end
1247: # environments and {}'s etc. Therefore we do all the work
1248: # of figuring out the ending strings in the start tag processing,
1249: # and provide a mechanism to output the stop text external
1250: # to tag processing.
1251: #
1252: {
1253:
1254: my $closing_string = ''; # String required to close <p>
1255:
1.279 foxr 1256: # Some tags are <p> fragile meaning that <p> inside of them
1257: # does not work within TeX mode. This is managed via the
1258: # counter below:
1259: #
1260:
1261: my $para_disabled = 0;
1262:
1263: sub disable_para {
1264: $para_disabled++;
1265: }
1266: sub enable_para {
1267: $para_disabled--;
1268: }
1269:
1270:
1.181 sakharuk 1271: #-- <p> tag (end tag optional)
1.198 sakharuk 1272: #optional attribute - align="center|left|right"
1.122 albertel 1273: sub start_p {
1.157 sakharuk 1274: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1.279 foxr 1275: my $currentstring = '';
1.325 albertel 1276: if ($target eq 'web' || $target eq 'webgrade') {
1.279 foxr 1277: $currentstring .= &end_p(); # close off prior para if in progress.
1.122 albertel 1278: $currentstring .= $token->[4];
1.279 foxr 1279: if (! ($currentstring =~ /\//)) {
1280: $closing_string = '</p>'; # Deal correctly with <p /> e.g.
1281: }
1282: } elsif ($target eq 'tex' && !$para_disabled) {
1.313 foxr 1283:
1.279 foxr 1284: $currentstring .= &end_p(); # close off prior para if in progress.
1.198 sakharuk 1285: my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1);
1286: if ($align eq 'center') {
1.333 albertel 1287: $currentstring .='\begin{center}\par ';
1.277 foxr 1288: $closing_string = '\end{center}';
1.309 albertel 1289: if (&is_inside_of($tagstack, "table")) {
1290: $currentstring = ¢er_correction().$currentstring;
1291: }
1.198 sakharuk 1292: } elsif ($align eq 'right') {
1.323 foxr 1293: $currentstring.="\n".'{\flushright ';
1294: # $currentstring.='\makebox['.$env{'form.textwidth'}.']{\hfill\llap{';
1295: $closing_string= "}\n";
1.198 sakharuk 1296: } elsif ($align eq 'left') {
1.323 foxr 1297: $currentstring.= "\n".'{\flushleft ';
1298: # $currentstring.='\noindent\makebox['.$env{'form.textwidth'}.']{{';
1299: $closing_string = "}\n";
1.216 matthew 1300: } else {
1.277 foxr 1301: $currentstring.='\par ';
1.313 foxr 1302: if (&is_inside_of($tagstack, 'table')) {
1.315 foxr 1303: $closing_string = '\vskip 0pt'; # Seems to be consistent with <p> in tables.
1.313 foxr 1304: } else {
1305: $closing_string = '\strut\\\\\strut ';
1306: }
1.216 matthew 1307: }
1.277 foxr 1308:
1.144 sakharuk 1309: }
1.122 albertel 1310: return $currentstring;
1311: }
1.277 foxr 1312: #
1313: # End paragraph processing just requires that we output the
1314: # closing string that was saved and blank it.
1315: sub end_p {
1.279 foxr 1316: # Note only 'tex' mode uses disable_para and enable_para
1317: # so we don't need to know the target in the check below:
1318:
1319: if (!$para_disabled) {
1320: my $current_string = $closing_string;
1321: $closing_string = ''; # Not in a para anymore.
1322: return $current_string;
1323: } else {
1324: return '';
1325: }
1.122 albertel 1326:
1327: }
1.277 foxr 1328: }
1.181 sakharuk 1329: #-- <br> tag (end tag forbidden)
1.122 albertel 1330: sub start_br {
1331: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1332: my $currentstring = '';
1.325 albertel 1333: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 1334: $currentstring .= $token->[4];
1335: } elsif ($target eq 'tex') {
1.227 sakharuk 1336: my @tempo=@$tagstack;
1.229 sakharuk 1337: my $signal=0;
1.287 foxr 1338: # Not going to factor this to is_inside_of since that would require
1339: # multiple stack traversals.
1340: #
1.227 sakharuk 1341: for (my $i=$#tempo;$i>=0;$i--) {
1342: if (($tempo[$i] eq 'b') || ($tempo[$i] eq 'strong') ||
1.334 albertel 1343: ($tempo[$i] eq 'ol') || ($tempo[$i] eq 'ul')) {
1.229 sakharuk 1344: $signal=1;
1.334 albertel 1345: }
1346: if (($tempo[$i] eq 'td') || ($tempo[$i] eq 'th')) {
1.336 foxr 1347: $signal = 1;
1.227 sakharuk 1348: }
1349: }
1.375 foxr 1350: if ($signal != 1) {
1.219 sakharuk 1351: $currentstring .= '\strut \\\\ \strut ';
1.1 sakharuk 1352: }
1.355 foxr 1353:
1.144 sakharuk 1354: }
1.122 albertel 1355: return $currentstring;
1356: }
1357:
1358: sub end_br {
1359: my ($target,$token) = @_;
1360: my $currentstring = '';
1.325 albertel 1361: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 1362: $currentstring .= $token->[2];
1363: }
1364: return $currentstring;
1365: }
1366:
1.181 sakharuk 1367: #-- <big> tag (end tag required)
1.122 albertel 1368: sub start_big {
1369: my ($target,$token) = @_;
1370: my $currentstring = '';
1.325 albertel 1371: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 1372: $currentstring .= $token->[4];
1373: } elsif ($target eq 'tex') {
1.137 sakharuk 1374: $currentstring .= '{\large ';
1.144 sakharuk 1375: }
1.122 albertel 1376: return $currentstring;
1377: }
1378:
1379: sub end_big {
1380: my ($target,$token) = @_;
1381: my $currentstring = '';
1.325 albertel 1382: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 1383: $currentstring .= $token->[2];
1384: } elsif ($target eq 'tex') {
1385: $currentstring .= '}';
1386: }
1387: return $currentstring;
1388: }
1389:
1.181 sakharuk 1390: #-- <small> tag (end tag required)
1.122 albertel 1391: sub start_small {
1392: my ($target,$token) = @_;
1393: my $currentstring = '';
1.325 albertel 1394: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 1395: $currentstring .= $token->[4];
1396: } elsif ($target eq 'tex') {
1397: $currentstring .= '{\footnotesize ';
1.144 sakharuk 1398: }
1.122 albertel 1399: return $currentstring;
1400: }
1401:
1402: sub end_small {
1403: my ($target,$token) = @_;
1404: my $currentstring = '';
1.325 albertel 1405: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 1406: $currentstring .= $token->[2];
1407: } elsif ($target eq 'tex') {
1408: $currentstring .= '}';
1409: }
1410: return $currentstring;
1411: }
1412:
1.181 sakharuk 1413: #-- <basefont> tag (end tag forbidden)
1.122 albertel 1414: sub start_basefont {
1.126 sakharuk 1415: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1.122 albertel 1416: my $currentstring = '';
1.325 albertel 1417: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 1418: $currentstring = $token->[4];
1.126 sakharuk 1419: } elsif ($target eq 'tex') {
1420: my $basesize=&Apache::lonxml::get_param('TeXsize',$parstack,$safeeval);
1421: if (defined $basesize) {
1422: $currentstring = '{\\'.$basesize.' ';
1423: }
1424: }
1.122 albertel 1425: return $currentstring;
1426: }
1427:
1428: sub end_basefont {
1.126 sakharuk 1429: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1.122 albertel 1430: my $currentstring = '';
1.325 albertel 1431: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 1432: $currentstring = $token->[4];
1.126 sakharuk 1433: } elsif ($target eq 'tex') {
1434: my $basesize=&Apache::lonxml::get_param('TeXsize',$parstack,$safeeval);
1435: if (defined $basesize) {
1436: $currentstring = '}';
1437: }
1438: }
1.122 albertel 1439: return $currentstring;
1440: }
1441:
1.181 sakharuk 1442: #-- <font> tag (end tag required)
1.122 albertel 1443: sub start_font {
1444: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1445: my $currentstring = '';
1.325 albertel 1446: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 1447: my $face=&Apache::lonxml::get_param('face',$parstack,$safeeval);
1448: $currentstring = $token->[4];
1.126 sakharuk 1449: } elsif ($target eq 'tex') {
1450: my $fontsize=&Apache::lonxml::get_param('TeXsize',$parstack,$safeeval);
1451: if (defined $fontsize) {
1452: $currentstring = '{\\'.$fontsize.' ';
1453: }
1454: }
1.122 albertel 1455: return $currentstring;
1456: }
1457:
1458: sub end_font {
1459: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1460: my $currentstring = '';
1.325 albertel 1461: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 1462: $currentstring = $token->[2];
1.126 sakharuk 1463: } elsif ($target eq 'tex') {
1464: my $fontsize=&Apache::lonxml::get_param('TeXsize',$parstack,$safeeval);
1465: if (defined $fontsize) {
1466: $currentstring = '}';
1467: }
1468: }
1.122 albertel 1469: return $currentstring;
1470: }
1471:
1.181 sakharuk 1472: #-- <strike> tag (end tag required)
1.122 albertel 1473: sub start_strike {
1474: my ($target,$token) = @_;
1475: my $currentstring = '';
1.325 albertel 1476: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 1477: $currentstring .= $token->[4];
1478: } elsif ($target eq 'tex') {
1479: &Apache::lonxml::startredirection();
1480: }
1481: return $currentstring;
1482: }
1483:
1484: sub end_strike {
1485: my ($target,$token) = @_;
1486: my $currentstring = '';
1.325 albertel 1487: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 1488: $currentstring .= $token->[2];
1489: } elsif ($target eq 'tex') {
1490: $currentstring=&Apache::lonxml::endredirection();
1491: $currentstring=~s/(\S)(\s+)(\S)/$1\}$2\\underline\{$3/g;
1492: $currentstring=~s/^\s*(\S)/\\underline\{$1/;
1493: $currentstring=~s/(\S)\s*$/$1\}/;
1494: }
1495: return $currentstring;
1496: }
1497:
1.181 sakharuk 1498: #-- <s> tag (end tag required)
1.122 albertel 1499: sub start_s {
1500: my ($target,$token) = @_;
1501: my $currentstring = '';
1.325 albertel 1502: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 1503: $currentstring .= $token->[4];
1504: } elsif ($target eq 'tex') {
1505: &Apache::lonxml::startredirection();
1506: }
1507: return $currentstring;
1508: }
1509:
1510: sub end_s {
1511: my ($target,$token) = @_;
1512: my $currentstring = '';
1.325 albertel 1513: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 1514: $currentstring .= $token->[2];
1515: } elsif ($target eq 'tex') {
1516: $currentstring=&Apache::lonxml::endredirection();
1517: $currentstring=~s/(\S)(\s+)(\S)/$1\}$2\\underline\{$3/g;
1518: $currentstring=~s/^\s*(\S)/\\underline\{$1/;
1519: $currentstring=~s/(\S)\s*$/$1\}/;
1520: }
1521: return $currentstring;
1522: }
1523:
1.181 sakharuk 1524: #-- <sub> tag (end tag required)
1.122 albertel 1525: sub start_sub {
1526: my ($target,$token) = @_;
1527: my $currentstring = '';
1.325 albertel 1528: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 1529: $currentstring .= $token->[4];
1530: } elsif ($target eq 'tex') {
1.355 foxr 1531: $currentstring .= '\raisebox{-\smallskipamount}{\scriptsize{';
1.122 albertel 1532: }
1533: return $currentstring;
1534: }
1535:
1536: sub end_sub {
1537: my ($target,$token) = @_;
1538: my $currentstring = '';
1.325 albertel 1539: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 1540: $currentstring .= $token->[2];
1541: } elsif ($target eq 'tex') {
1.202 sakharuk 1542: $currentstring .= '}}';
1.122 albertel 1543: }
1544: return $currentstring;
1545: }
1546:
1.181 sakharuk 1547: #-- <sup> tag (end tag required)
1.122 albertel 1548: sub start_sup {
1549: my ($target,$token) = @_;
1550: my $currentstring = '';
1.325 albertel 1551: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 1552: $currentstring .= $token->[4];
1553: } elsif ($target eq 'tex') {
1.355 foxr 1554: $currentstring .= '\raisebox{\smallskipamount}{\scriptsize{';
1.122 albertel 1555: }
1556: return $currentstring;
1557: }
1558:
1559: sub end_sup {
1560: my ($target,$token) = @_;
1561: my $currentstring = '';
1.325 albertel 1562: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 1563: $currentstring .= $token->[2];
1564: } elsif ($target eq 'tex') {
1.202 sakharuk 1565: $currentstring .= '}}';
1.122 albertel 1566: }
1567: return $currentstring;
1568: }
1569:
1.181 sakharuk 1570: #-- <hr> tag (end tag forbidden)
1.122 albertel 1571: sub start_hr {
1.124 sakharuk 1572: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1.279 foxr 1573: my $currentstring = &end_p(); # End enclosing para.
1.325 albertel 1574: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 1575: $currentstring .= $token->[4];
1576: } elsif ($target eq 'tex') {
1.361 foxr 1577:
1578: # <hr /> can't be inside of <sup><sub> thank you LaTeX.
1579: #
1580: my $restart_sub = 0;
1581: my $restart_sup = 0;
1582:
1583: # Since <sub> and <sup> are simple tags it's ok to turn off/on
1584: # using the start_ stop_ functions.. those tags only care about
1585: # $target.
1586:
1587: if (&is_inside_of($tagstack, "sub")) {
1588: $restart_sub = 1;
1589: $currentstring .= &end_sub($target, $token, $tagstack,
1590: $parstack, $parser, $safeeval);
1591: }
1592: if (&is_inside_of($tagstack, "sup")) {
1593: $restart_sup = 1;
1594: $currentstring .= &end_sup($target, $token, $tagstack,
1595: $parstack, $parser, $safeeval);
1596: }
1597:
1.149 sakharuk 1598: my $LaTeXwidth = &Apache::lonxml::get_param('TeXwidth',$parstack,$safeeval,undef,0);
1.124 sakharuk 1599: if (defined $LaTeXwidth) {
1600: if ($LaTeXwidth=~/^%/) {
1601: substr($LaTeXwidth,0,1)='';
1602: $LaTeXwidth=($LaTeXwidth/100).'\textwidth';
1603: }
1604: } else {
1.148 sakharuk 1605: $LaTeXwidth ='0.9\textwidth';
1.124 sakharuk 1606: }
1607: my ($pre,$post);
1608: my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1);
1609: if (($align eq 'center') || (not defined $align)) {
1610: $pre=''; $post='';
1611: } elsif ($align eq 'left') {
1612: $pre='\rlap{'; $post='} \hfill';
1613: } elsif ($align eq 'right') {
1614: $pre=' \hfill \llap{'; $post='}';
1615: }
1.148 sakharuk 1616: $currentstring .= ' \vskip 0 mm \noindent\makebox['.$LaTeXwidth.']{'.$pre.'\makebox['.
1.124 sakharuk 1617: $LaTeXwidth.'][b]{\hrulefill}'.$post.'}\vskip 0 mm ';
1.361 foxr 1618: # Turn stuff back on that we can't be inside of.
1619:
1620: if ($restart_sub) {
1621: $currentstring .= &start_sub($target, $token, $tagstack,
1622: $parstack, $parser, $safeeval);
1623: }
1624: if ($restart_sup) {
1625: $currentstring .= &start_sup($target, $token, $tagstack,
1626: $parstack, $parser, $safeeval);
1627: }
1.122 albertel 1628: }
1629: return $currentstring;
1630: }
1631:
1632: sub end_hr {
1633: my ($target,$token) = @_;
1634: my $currentstring = '';
1.325 albertel 1635: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 1636: $currentstring .= $token->[2];
1.148 sakharuk 1637: }
1.122 albertel 1638: return $currentstring;
1639: }
1640:
1.181 sakharuk 1641: #-- <div> tag (end tag required)
1.280 foxr 1642: {
1643:
1644: # Since div can be nested, the stack below is used
1645: # in 'tex' mode to store the ending strings
1646: # for the div stack.
1647:
1648: my @div_end_stack;
1649:
1.122 albertel 1650: sub start_div {
1.280 foxr 1651: my ($target,$token, $tagstack, $parstack, $parser, $safeeval) = @_;
1.279 foxr 1652: my $currentstring = &end_p(); # Close enclosing para.
1.325 albertel 1653: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 1654: $currentstring .= $token->[4];
1655: }
1.280 foxr 1656: if ($target eq 'tex') {
1657: # 4 possible alignments: left, right, center, and -missing-.
1.380 foxr 1658: # If inside a table row, we must let the table logic
1659: # do the alignment, however.
1660: #
1.280 foxr 1661:
1662: my $endstring = '';
1663:
1664: my $align = lc(&Apache::lonxml::get_param('align', $parstack,
1665: $safeeval, undef, 1));
1666: if ($align eq 'center') {
1667: $currentstring .= '\begin{center}';
1668: $endstring = '\end{center}';
1.309 albertel 1669: if (&is_inside_of($tagstack, "table")) {
1670: $currentstring = ¢er_correction().$currentstring;
1.380 foxr 1671: $endstring .= ¢er_end_correction();
1.309 albertel 1672: }
1.280 foxr 1673: }
1674: elsif ($align eq 'right') {
1675: $currentstring .= '\begin{flushright}';
1676: $endstring .= '\end{flushright}';
1677: } elsif ($align eq 'left') {
1678: $currentstring .= '\begin{flushleft}';
1679: $endstring = '\end{flushleft}';
1680: } else {
1681:
1682: }
1683: $currentstring .= "\n"; # For human readability.
1684: $endstring = "\n$endstring\n"; # For human readability
1685: push(@div_end_stack, $endstring);
1686: }
1.122 albertel 1687: return $currentstring;
1688: }
1689:
1690: sub end_div {
1691: my ($target,$token) = @_;
1692: my $currentstring = '';
1.325 albertel 1693: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 1694: $currentstring .= $token->[2];
1.280 foxr 1695: }
1696: if ($target eq 'tex') {
1697: my $endstring = pop @div_end_stack;
1698: $currentstring .= $endstring;
1699: }
1.122 albertel 1700: return $currentstring;
1701: }
1.280 foxr 1702: }
1.122 albertel 1703:
1.181 sakharuk 1704: #-- <a> tag (end tag required)
1.122 albertel 1705: sub start_a {
1.149 sakharuk 1706: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1.122 albertel 1707: my $currentstring = '';
1.325 albertel 1708: if ($target eq 'web' || $target eq 'webgrade') {
1.250 albertel 1709: my $href=&Apache::lonxml::get_param('href',$parstack,$safeeval,
1710: undef,1);
1711: $currentstring=&Apache::lonenc::encrypt_ref($token,{'href'=>$href});
1.400 raeburn 1712: if ($href =~ /\S/) {
1713: if ($href !~ m{^https?://}) {
1714: my $url=&Apache::lonnet::hreflocation('',$env{'request.filename'});
1715: my $linkurl;
1716: if ($href =~ m{^/uploaded/}) {
1717: $linkurl = $href;
1718: } elsif ($href =~ m{^[^/]}) {
1719: my $path = $url;
1720: $path =~ s{[^/]*$}{};
1721: $linkurl = $path.$href;
1722: }
1723: if ($linkurl =~ m{^/uploaded/}) {
1724: if (!&Apache::lonnet::allowed('bre',$linkurl)) {
1725: if (&Apache::lonnet::is_on_map($url)) {
1726: &Apache::lonxml::extlink($linkurl);
1727: }
1728: }
1729: }
1730: }
1731: }
1.122 albertel 1732: }
1733: return $currentstring;
1734: }
1735:
1736: sub end_a {
1.168 albertel 1737: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1.122 albertel 1738: my $currentstring = '';
1.325 albertel 1739: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 1740: $currentstring .= $token->[2];
1741: }
1.351 foxr 1742: if ($target eq 'tex') {
1.352 albertel 1743: my $href =
1744: &Apache::lonxml::get_param('href',$parstack,$safeeval,undef,1);
1745: my $name =
1746: &Apache::lonxml::get_param('name',$parstack,$safeeval,undef,1);
1.382 www 1747: my $uriprint =
1748: &Apache::lonxml::get_param('uriprint',$parstack,$safeeval,undef,1);
1749: my $anchorprint =
1750: &Apache::lonxml::get_param('anchorprint',$parstack,$safeeval,undef,1);
1751: if (($href =~ /\S/) && ($uriprint=~/^on|uriprint|yes|1$/i)) {
1.352 albertel 1752: $href =~ s/([^\\])%/$1\\\%/g;
1.365 foxr 1753: # Substitute special symbols... and allow line breaks at each /
1754: #
1755: $href = &Apache::lonxml::latex_special_symbols($href);
1756: $href =~ s/\//\/\\-/g; # Map / to /\- to allow hyphenation.
1757: $currentstring .= ' ({\tt URI:'.$href.'})';
1.382 www 1758: } elsif (($name =~ /\S/) && ($anchorprint=~/^on|anchorprint|yes|1$/i)) {
1.352 albertel 1759: $currentstring .= ' ({\tt Anchor:'.&Apache::lonxml::latex_special_symbols($name).'})';
1.351 foxr 1760: } else {
1761: $currentstring.='';
1762: }
1763: }
1.122 albertel 1764: return $currentstring;
1765: }
1766:
1.181 sakharuk 1767: #-- <li> tag (end tag optional)
1.122 albertel 1768: sub start_li {
1.168 albertel 1769: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1.122 albertel 1770: my $currentstring = '';
1.325 albertel 1771: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 1772: $currentstring = $token->[4];
1773: } elsif ($target eq 'tex') {
1.237 sakharuk 1774: my $type=&Apache::lonxml::get_param('type',$parstack,$safeeval,undef,0);
1775: my $value=&Apache::lonxml::get_param('value',$parstack,$safeeval,undef,0);
1.238 albertel 1776: #FIXME need to support types i and I
1777: if ($type=~/disc/) {
1778: $currentstring .= ' \item[$\bullet$] ';
1779: } elsif ($type=~/circle/) {
1780: $currentstring .= ' \item[$\circ$] ';
1.146 sakharuk 1781: } elsif ($type=~/square/) {
1.238 albertel 1782: $currentstring .= ' \item[$\diamond$] ';
1783: } elsif ($type eq '1') {
1784: $currentstring .= ' \item['.($Apache::londefdef::list_index+1).'.]';
1.237 sakharuk 1785: } elsif ($type eq 'A') {
1.238 albertel 1786: $currentstring .= ' \item['.('A'..'Z')[$Apache::londefdef::list_index].'.]';
1.237 sakharuk 1787: } elsif ($type eq 'a') {
1.238 albertel 1788: $currentstring .= ' \item['.('a'..'z')[$Apache::londefdef::list_index].'.]';
1.237 sakharuk 1789: } elsif ($value ne '') {
1790: $currentstring .= ' \item['.$value.'] ';
1.122 albertel 1791: } else {
1.146 sakharuk 1792: $currentstring .= ' \item ';
1.122 albertel 1793: }
1.238 albertel 1794: $Apache::londefdef::list_index++;
1795: }
1.122 albertel 1796: return $currentstring;
1797: }
1798:
1799: sub end_li {
1800: my ($target,$token) = @_;
1.279 foxr 1801: my $currentstring = &end_p(); # In case there's a <p> in the <li>
1.325 albertel 1802: if ($target eq 'web' || $target eq 'webgrade') {
1.277 foxr 1803: $currentstring .= $token->[2];
1.122 albertel 1804: }
1805: return $currentstring;
1806: }
1807:
1.181 sakharuk 1808: #-- <u> tag (end tag required)
1.122 albertel 1809: sub start_u {
1810: my ($target,$token) = @_;
1811: my $currentstring = '';
1.325 albertel 1812: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 1813: $currentstring .= $token->[4];
1814: } elsif ($target eq 'tex') {
1815: &Apache::lonxml::startredirection();
1816: }
1817: return $currentstring;
1818: }
1819:
1820: sub end_u {
1821: my ($target,$token) = @_;
1822: my $currentstring = '';
1.325 albertel 1823: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 1824: $currentstring .= $token->[2];
1825: } elsif ($target eq 'tex') {
1826: $currentstring=&Apache::lonxml::endredirection();
1827: $currentstring=~s/(\S)(\s+)(\S)/$1\}$2\\underline\{$3/g;
1828: $currentstring=~s/^\s*(\S)/\\underline\{$1/;
1829: $currentstring=~s/(\S)\s*$/$1\}/;
1830: }
1831: return $currentstring;
1832: }
1833:
1.181 sakharuk 1834: #-- <ul> tag (end tag required)
1.122 albertel 1835: sub start_ul {
1.125 sakharuk 1836: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1.279 foxr 1837: my $currentstring = &end_p(); # Close off enclosing list.
1.325 albertel 1838: if ($target eq 'web' || $target eq 'webgrade') {
1.277 foxr 1839: $currentstring .= $token->[4];
1.122 albertel 1840: } elsif ($target eq 'tex') {
1.125 sakharuk 1841: my $TeXtype=&Apache::lonxml::get_param('type',$parstack,$safeeval,undef,0);
1.238 albertel 1842: $Apache::londefdef::list_index=0;
1.125 sakharuk 1843: if ($TeXtype eq 'disc') {
1.222 sakharuk 1844: $currentstring .= '\renewcommand{\labelitemi}{$\bullet$}'.
1845: '\renewcommand{\labelitemii}{$\bullet$}'.
1846: '\renewcommand{\labelitemiii}{$\bullet$}'.
1847: '\renewcommand{\labelitemiv}{$\bullet$}';
1.125 sakharuk 1848: } elsif ($TeXtype eq 'circle') {
1.222 sakharuk 1849: $currentstring .= '\renewcommand{\labelitemi}{$\circ$}'.
1850: '\renewcommand{\labelitemii}{$\circ$}'.
1851: '\renewcommand{\labelitemiii}{$\circ$}'.
1852: '\renewcommand{\labelitemiv}{$\circ$}';
1.125 sakharuk 1853: } elsif ($TeXtype eq 'square') {
1.222 sakharuk 1854: $currentstring .= '\renewcommand{\labelitemi}{$\diamond$}'.
1855: '\renewcommand{\labelitemii}{$\diamond$}'.
1856: '\renewcommand{\labelitemiii}{$\diamond$}'.
1857: '\renewcommand{\labelitemiv}{$\diamond$}';
1.125 sakharuk 1858: }
1.222 sakharuk 1859: $currentstring .= '\strut \begin{itemize}';
1.122 albertel 1860: }
1861: return $currentstring;
1862: }
1863:
1864: sub end_ul {
1865: my ($target,$token) = @_;
1866: my $currentstring = '';
1.325 albertel 1867: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 1868: $currentstring = $token->[2];
1869: } elsif ($target eq 'tex') {
1.222 sakharuk 1870: $currentstring = '\end{itemize} \renewcommand{\labelitemi}{$\bullet$}'.
1871: '\renewcommand{\labelitemii}{$\bullet$}'.
1872: '\renewcommand{\labelitemiii}{$\bullet$}'.
1873: '\renewcommand{\labelitemiv}{$\bullet$}\strut ';
1.122 albertel 1874: }
1875: return $currentstring;
1876: }
1877:
1.181 sakharuk 1878: #-- <menu> tag (end tag required)
1.122 albertel 1879: sub start_menu {
1880: my ($target,$token) = @_;
1881: my $currentstring = '';
1.325 albertel 1882: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 1883: $currentstring = $token->[4];
1884: } elsif ($target eq 'tex') {
1885: $currentstring = " \\begin{itemize} ";
1886: }
1887: return $currentstring;
1888: }
1889:
1890: sub end_menu {
1891: my ($target,$token) = @_;
1892: my $currentstring = '';
1.325 albertel 1893: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 1894: $currentstring = $token->[2];
1895: } elsif ($target eq 'tex') {
1896: $currentstring = " \\end{itemize}";
1897: }
1898: return $currentstring;
1899: }
1900:
1.181 sakharuk 1901: #-- <dir> tag (end tag required)
1.122 albertel 1902: sub start_dir {
1903: my ($target,$token) = @_;
1.279 foxr 1904: my $currentstring = &end_p(); # In case there's a <p> prior to the list.
1.325 albertel 1905: if ($target eq 'web' || $target eq 'webgrade') {
1.277 foxr 1906: $currentstring .= $token->[4];
1.122 albertel 1907: } elsif ($target eq 'tex') {
1.277 foxr 1908: $currentstring .= " \\begin{itemize} ";
1.122 albertel 1909: }
1910: return $currentstring;
1911: }
1912:
1913: sub end_dir {
1914: my ($target,$token) = @_;
1915: my $currentstring = '';
1.325 albertel 1916: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 1917: $currentstring = $token->[2];
1918: } elsif ($target eq 'tex') {
1919: $currentstring = " \\end{itemize}";
1920: }
1921: return $currentstring;
1922: }
1923:
1.181 sakharuk 1924: #-- <ol> tag (end tag required)
1.122 albertel 1925: sub start_ol {
1.125 sakharuk 1926: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1.279 foxr 1927: my $currentstring = &end_p(); # In case there's a <p> prior to the list.
1.325 albertel 1928: if ($target eq 'web' || $target eq 'webgrade') {
1.277 foxr 1929: $currentstring .= $token->[4];
1.122 albertel 1930: } elsif ($target eq 'tex') {
1.238 albertel 1931: $Apache::londefdef::list_index=0;
1.125 sakharuk 1932: my $type=&Apache::lonxml::get_param('type',$parstack,$safeeval,undef,0);
1933: if ($type eq '1') {
1.222 sakharuk 1934: $currentstring .= '\renewcommand{\labelenumi}{\arabic{enumi}.}'.
1935: '\renewcommand{\labelenumii}{\arabic{enumii}.}'.
1936: '\renewcommand{\labelenumiii}{\arabic{enumiii}.}'.
1937: '\renewcommand{\labelenumiv}{\arabic{enumiv}.}';
1.125 sakharuk 1938: } elsif ($type eq 'A') {
1.222 sakharuk 1939: $currentstring .= '\renewcommand{\labelenumi}{\Alph{enumi}.}'.
1940: '\renewcommand{\labelenumii}{\Alph{enumii}.}'.
1941: '\renewcommand{\labelenumiii}{\Alph{enumiii}.}'.
1942: '\renewcommand{\labelenumiv}{\Alph{enumiv}.}';
1.125 sakharuk 1943: } elsif ($type eq 'a') {
1.222 sakharuk 1944: $currentstring .= '\renewcommand{\labelenumi}{\alph{enumi}.}'.
1945: '\renewcommand{\labelenumii}{\alph{enumii}.}'.
1946: '\renewcommand{\labelenumiii}{\alph{enumiii}.}'.
1947: '\renewcommand{\labelenumiv}{\alph{enumiv}.}';
1.125 sakharuk 1948: } elsif ($type eq 'i') {
1.222 sakharuk 1949: $currentstring .= '\renewcommand{\labelenumi}{\roman{enumi}.}'.
1950: '\renewcommand{\labelenumii}{\roman{enumii}.}'.
1951: '\renewcommand{\labelenumiii}{\roman{enumiii}.}'.
1952: '\renewcommand{\labelenumiv}{\roman{enumiv}.}';
1.125 sakharuk 1953: } elsif ($type eq 'I') {
1.222 sakharuk 1954: $currentstring .= '\renewcommand{\labelenumi}{\Roman{enumi}.}'.
1955: '\renewcommand{\labelenumii}{\Roman{enumii}.}'.
1956: '\renewcommand{\labelenumiii}{\Roman{enumiii}.}'.
1957: '\renewcommand{\labelenumiv}{\Roman{enumiv}.}';
1.125 sakharuk 1958: }
1.222 sakharuk 1959: $currentstring .= '\strut \begin{enumerate}';
1.122 albertel 1960: }
1961: return $currentstring;
1962: }
1963:
1964: sub end_ol {
1965: my ($target,$token) = @_;
1966: my $currentstring = '';
1.325 albertel 1967: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 1968: $currentstring = $token->[2];
1969: } elsif ($target eq 'tex') {
1.222 sakharuk 1970: $currentstring = '\end{enumerate}\renewcommand{\labelenumi}{\arabic{enumi}.}'.
1971: '\renewcommand{\labelenumii}{\arabic{enumii}.}'.
1972: '\renewcommand{\labelenumiii}{\arabic{enumiii}.}'.
1973: '\renewcommand{\labelenumiv}{\arabic{enumiv}.}\strut ';
1.122 albertel 1974: }
1975: return $currentstring;
1976: }
1977:
1.181 sakharuk 1978: #-- <dl> tag (end tag required)
1.122 albertel 1979: sub start_dl {
1980: my ($target,$token) = @_;
1.279 foxr 1981: my $currentstring = &end_p(); # In case there's a <p> unclosed prior to the list.
1.325 albertel 1982: if ($target eq 'web' || $target eq 'webgrade') {
1.277 foxr 1983: $currentstring .= $token->[4];
1.122 albertel 1984: } elsif ($target eq 'tex') {
1.277 foxr 1985: $currentstring .= '\begin{description}';
1.243 albertel 1986: $Apache::londefdef::DL++;
1987: push(@Apache::londefdef::description,[]);
1988: $Apache::londefdef::DD[$Apache::londefdef::DL]=0;
1989: $Apache::londefdef::DT[$Apache::londefdef::DL]=0;
1.244 albertel 1990: $Apache::londefdef::seenDT[$Apache::londefdef::DL]=0;
1.122 albertel 1991: }
1992: return $currentstring;
1993: }
1994:
1995: sub end_dl {
1.174 sakharuk 1996: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1.122 albertel 1997: my $currentstring = '';
1.325 albertel 1998: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 1999: $currentstring = $token->[2];
2000: } elsif ($target eq 'tex') {
1.243 albertel 2001: if ($Apache::londefdef::DT[-1]) { &end_dt(@_); }
2002: if ($Apache::londefdef::DD[-1]) { &end_dd(@_); }
2003: foreach my $element (@{$Apache::londefdef::description[-1]}) {
1.174 sakharuk 2004: $currentstring.=' '.$element.' ';
2005: }
1.243 albertel 2006: pop(@Apache::londefdef::description);
1.174 sakharuk 2007: $currentstring.='\end{description}';
1.243 albertel 2008: delete($Apache::londefdef::DD[$Apache::londefdef::DL]);
2009: delete($Apache::londefdef::DT[$Apache::londefdef::DL]);
1.244 albertel 2010: delete($Apache::londefdef::seenDT[$Apache::londefdef::DL]);
1.243 albertel 2011: $Apache::londefdef::DL--;
1.122 albertel 2012: }
2013: return $currentstring;
2014: }
2015:
1.172 sakharuk 2016: #-- <dt> tag (end tag optional)
1.122 albertel 2017: sub start_dt {
1.172 sakharuk 2018: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
2019: my $currentstring='';
1.325 albertel 2020: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 2021: $currentstring = $token->[4];
2022: } elsif ($target eq 'tex') {
1.243 albertel 2023: if ($Apache::londefdef::DT[-1]) { &end_dt(@_); }
2024: if ($Apache::londefdef::DD[-1]) { &end_dd(@_); }
1.174 sakharuk 2025: &Apache::lonxml::startredirection();
1.243 albertel 2026: $Apache::londefdef::DT[-1]++;
1.244 albertel 2027: $Apache::londefdef::seenDT[-1]=1;
1.122 albertel 2028: }
2029: return $currentstring;
2030: }
2031:
2032: sub end_dt {
1.172 sakharuk 2033: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1.122 albertel 2034: my $currentstring = '';
1.325 albertel 2035: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 2036: $currentstring = $token->[2];
2037: } elsif ($target eq 'tex') {
1.243 albertel 2038: if ($Apache::londefdef::DT[-1]) {
2039: my $data=&item_cleanup();
1.244 albertel 2040: push(@{$Apache::londefdef::description[-1]},'\item['.$data.'] \strut \vskip 0mm');
1.243 albertel 2041: $Apache::londefdef::DT[-1]--;
2042: }
1.122 albertel 2043: }
2044: return $currentstring;
2045: }
2046:
1.173 sakharuk 2047: sub item_cleanup {
1.174 sakharuk 2048: my $item=&Apache::lonxml::endredirection();
1.173 sakharuk 2049: $item=~s/\\begin{center}//g;
2050: $item=~s/\\end{center}//g;
2051: return $item;
2052: }
2053:
1.181 sakharuk 2054: #-- <dd> tag (end tag optional)
1.122 albertel 2055: sub start_dd {
1.147 sakharuk 2056: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1.122 albertel 2057: my $currentstring = '';
1.325 albertel 2058: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 2059: $currentstring = $token->[4];
1.147 sakharuk 2060: } elsif ($target eq 'tex') {
1.243 albertel 2061: if ($Apache::londefdef::DT[-1]) { &end_dt(@_); }
2062: if ($Apache::londefdef::DD[-1]) { &end_dd(@_);}
1.244 albertel 2063: if (!$Apache::londefdef::seenDT[-1]) {
2064: push(@{$Apache::londefdef::description[-1]},'\item[\strut] \strut \vskip 0mm ');
2065: }
1.243 albertel 2066: push(@{$Apache::londefdef::description[-1]},'');
2067: $Apache::londefdef::description[-1]->[-1].=' \strut ';
2068: $Apache::londefdef::DD[-1]++;
1.174 sakharuk 2069: &Apache::lonxml::startredirection();
1.122 albertel 2070: }
2071: return $currentstring;
2072: }
2073:
2074: sub end_dd {
1.174 sakharuk 2075: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1.122 albertel 2076: my $currentstring = '';
1.325 albertel 2077: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 2078: $currentstring = $token->[2];
1.174 sakharuk 2079: } elsif ($target eq 'tex') {
1.243 albertel 2080: $Apache::londefdef::description[-1]->[-1].=
2081: &Apache::lonxml::endredirection().' \vskip 0mm ';
2082: $Apache::londefdef::DD[-1]--;
1.174 sakharuk 2083: }
1.122 albertel 2084: return $currentstring;
2085: }
2086:
1.181 sakharuk 2087: #-- <table> tag (end tag required)
1.277 foxr 2088: # <table> also ends any prior <p> that is not closed.
2089: # but, unless I allow <p>'s to nest, that's the
2090: # only way I could think of to allow <p> in
2091: # <tr> <th> bodies
2092: #
1.398 foxr 2093: #list of supported attributes: border,width,TeXwidth,TeXtheme
2094: # align
1.91 sakharuk 2095: sub start_table {
2096: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1.277 foxr 2097: my $textwidth = '';
1.279 foxr 2098: my $currentstring = &end_p();
1.325 albertel 2099: if ($target eq 'web' || $target eq 'webgrade') {
1.277 foxr 2100: $currentstring .= $token->[4];
1.91 sakharuk 2101: } elsif ($target eq 'tex') {
1.396 foxr 2102: &disable_para(); # Can't have paras in a table.
1.398 foxr 2103:
2104: # Get the parameters that we can do something about:
2105:
2106: my $border = &Apache::lonxml::get_param('border', $parstack, $safeeval, undef, 0);
2107: my $width = &Apache::lonxml::get_param('TeXwidth', $parstack, $safeeval, undef, 0);
2108: my $theme = &Apache::lonxml::get_param('TeXtheme', $parstack, $safeeval, undef, 0);
2109: my $align = &Apache::lonxml::get_param('align', $parstack, $safeeval, undef, 0);
1.420 foxr 2110: my $cell_border = &Apache::lonxml::get_param('rules', $parstack, $safeeval, undef, 0);
1.398 foxr 2111:
2112: # The only thing that needs any figuring out is the width.. and then only if it is
2113: # a percent. If not it's assumed to be some valid TeX measurement unit e.g. 3.0cm
2114: #
2115:
2116: my $table = new Apache::lontable();
1.420 foxr 2117: if ((defined $border) && ($border > 0)) {
1.421 raeburn 2118: # &Apache::lonnet::logthis("Turning on table borders: $border");
1.398 foxr 2119: $table->table_border(1);
1.428 foxr 2120: if (!defined $cell_border) {
2121: $table->cell_border(1); # Default for rules is all if rules not defined.
1.420 foxr 2122: }
2123: }
2124:
1.428 foxr 2125: if ((defined $cell_border)) {
2126: if ($cell_border eq 'all') {
2127: $table->cell_border(1);
2128: } elsif ($cell_border eq 'rows') {
2129: $table->cell_border(2);
2130: } elsif ($cell_border eq 'cols') {
2131: $table->cell_border(3);
1.430 foxr 2132: } elsif($cell_border eq 'groups') {
2133: $table->cell_border(4);
1.428 foxr 2134: } else {
2135: $table->cell_border(0);
2136: }
1.398 foxr 2137: }
1.420 foxr 2138: if (defined $theme) {
1.398 foxr 2139: $table->theme($theme);
2140: }
1.420 foxr 2141: if (defined $align) {
1.398 foxr 2142: $table->alignment($align);
2143: }
2144:
2145: # Missing width is most of page width
2146:
1.420 foxr 2147: if (!(defined $width)) {
1.398 foxr 2148: $width = '70%';
2149: }
1.420 foxr 2150:
1.398 foxr 2151: # If a percentage, need to calculate what this means in terms of
2152: # page width:
2153:
2154: if ($width =~ /%$/) {
2155: my $textwidth = &recalc($env{'form.textwidth'}); # Page width in mm.
2156: $width =~ s/%//;
2157: $width = $width * $textwidth / 100.0;
2158: $width .= " mm";
2159: $table->width($width);
2160: }
2161:
2162: push(@Apache::londefdef::table, $table);
2163: $currentstring.=' \keephidden{NEW TABLE ENTRY}';
2164:
1.294 foxr 2165: }
1.91 sakharuk 2166: return $currentstring;
2167: }
1.122 albertel 2168:
2169: sub end_table {
2170: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
2171: my $currentstring = '';
1.325 albertel 2172: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 2173: $currentstring = $token->[2];
2174: } elsif ($target eq 'tex') {
1.425 foxr 2175:
2176:
1.398 foxr 2177: my $table = pop(@Apache::londefdef::table);
2178: my $t = $table->generate();
1.423 raeburn 2179: # &Apache::lonnet::logthis("Generating string");
1.398 foxr 2180: $currentstring = $t->generate_string();
1.423 raeburn 2181: # &Apache::lonnet::logthis("Generated: $currentstring");
1.398 foxr 2182: &enable_para();
1.425 foxr 2183:
1.398 foxr 2184: }
1.122 albertel 2185: return $currentstring;
2186: }
2187:
1.166 sakharuk 2188: #-- <tr> tag (end tag optional)
1.122 albertel 2189: sub start_tr {
2190: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
2191: my $currentstring = '';
1.325 albertel 2192: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 2193: $currentstring = $token->[4];
2194: } elsif ($target eq 'tex') {
1.398 foxr 2195:
2196: my $align = &Apache::lonxml::get_param('align', $parstack, $safeeval, undef, 1);
2197: $Apache::londefdef::table[-1]->start_row();
2198:
2199: if ($align ne '') {
2200: $Apache::londefdef::table[-1]->configure_row({default_halign => $align});
2201: }
2202:
2203: #---------------------------------------------------------------
2204: # Old table code.
2205: #---------------------------------------------------------------
2206:
2207: if (0) {
1.122 albertel 2208: $Apache::londefdef::table[-1]{'row_number'}++;
1.206 sakharuk 2209: my $alignchar=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1);
1.122 albertel 2210: if ($alignchar ne '') {
1.206 sakharuk 2211: push @ {$Apache::londefdef::table[-1]{'rows'} },substr($alignchar,0,1);
1.122 albertel 2212: } else {
2213: push @ {$Apache::londefdef::table[-1]{'rows'} }, 'l';
2214: }
2215: push ( @{ $Apache::londefdef::table[-1]{'rowdata'} }, $Apache::londefdef::table[-1]{'hinc'});
1.300 foxr 2216: #
2217: # Need to save the number of table columns to preserve the max # columns.
2218: #
2219: $Apache::londefdef::table[-1]{'prior_columns'} = $Apache::londefdef::table[-1]{'counter_columns'};
1.122 albertel 2220: $Apache::londefdef::table[-1]{'counter_columns'} = -1;
1.206 sakharuk 2221: push @ {$Apache::londefdef::table[-1]{'TeXlen'}}, [];
2222: push @ {$Apache::londefdef::table[-1]{'objectlen'}}, [];
2223: push @ {$Apache::londefdef::table[-1]{'minlen'}}, [];
2224: push @ {$Apache::londefdef::table[-1]{'maxlen'}}, [];
2225: push @ {$Apache::londefdef::table[-1]{'content'}}, [];
1.398 foxr 2226: }
1.122 albertel 2227: }
2228: return $currentstring;
2229: }
2230:
2231: sub end_tr {
1.160 sakharuk 2232: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1.279 foxr 2233: my $currentstring = &end_p(); # Close any pending <p> in the row.
1.325 albertel 2234: if ($target eq 'web' || $target eq 'webgrade') {
1.277 foxr 2235: $currentstring .= $token->[2];
1.122 albertel 2236: } elsif ($target eq 'tex') {
1.398 foxr 2237:
2238: # In case the user is missing a </td> or </th> tag:
2239:
2240: if ($Apache::londefdef::TD_redirection) {
2241: &end_td_tex($parstack,$parser,$safeeval);
2242: }
2243: $Apache::londefdef::table[-1]->end_row();
2244:
2245: #-----------------------------------------------
2246: # Old table code
2247: #-----------------------------------------------
2248:
2249: if (0) {
1.160 sakharuk 2250: if ($Apache::londefdef::TD_redirection) {
2251: &end_td_tex($parstack,$parser,$safeeval);
2252: }
1.300 foxr 2253: # Counter columns must be the maximum number of columns seen
2254: # in the table so far so:
2255: if ($Apache::londefdef::table[-1]{'prior_columns'} > $Apache::londefdef::table[-1]{'counter_columns'}) {
2256: $Apache::londefdef::table[-1]{'counter_columns'} = $Apache::londefdef::table[-1]{'prior_columns'};
2257: }
1.398 foxr 2258: }
1.295 foxr 2259:
1.294 foxr 2260:
1.122 albertel 2261: }
2262: return $currentstring;
2263: }
2264:
1.166 sakharuk 2265: #-- <td> tag (end tag optional)
1.122 albertel 2266: sub start_td {
2267: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
2268: my $currentstring = '';
1.325 albertel 2269: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 2270: $currentstring = $token->[4];
2271: } elsif ($target eq 'tex') {
1.160 sakharuk 2272: $Apache::londefdef::TD_redirection = 1;
1.159 sakharuk 2273: &tag_check('tr','td',$tagstack,$parstack,$parser,$safeeval);
1.122 albertel 2274: }
2275: return $currentstring;
2276: }
1.159 sakharuk 2277:
2278: sub tag_check {
2279: my ($good_tag,$bad_tag,$tagstack,$parstack,$parser,$safeeval) = @_;
1.160 sakharuk 2280: my @ar=@$parstack;
2281: for (my $i=$#ar-1;$i>=0;$i--) {
2282: if (lc($$tagstack[$i]) eq $good_tag) {
2283: &start_td_tex($parstack,$parser,$safeeval);
2284: last;
2285: } elsif (lc($$tagstack[$i]) eq $bad_tag) {
2286: splice @ar, $i+1;
2287: &end_td_tex(\@ar,$parser,$safeeval);
2288: &start_td_tex($parstack,$parser,$safeeval);
2289: last;
1.159 sakharuk 2290: }
1.160 sakharuk 2291: }
1.159 sakharuk 2292: return '';
2293: }
1.398 foxr 2294:
2295: #
2296: # Factor out cell configuration hash generation:
2297: #
2298:
2299: sub cell_config_hash {
1.425 foxr 2300: my ($align, $rowspan, $colspan, $width) = @_;
1.426 raeburn 2301: if ($rowspan ne '') {
2302: $rowspan =~ s/^\s+|\s+$//g;
2303: }
2304: if ($colspan ne '') {
2305: $colspan =~ s/^\s+|\s+$//g;
2306: }
1.398 foxr 2307: my %config;
2308: if ($align ne '') {
2309: $config{'halign'} = $align;
2310: }
1.426 raeburn 2311: if (($colspan =~ /^\d+$/) && ($colspan > 0)) {
1.398 foxr 2312: $config{'colspan'} = $colspan;
2313: }
1.426 raeburn 2314: if (($rowspan =~ /^\d+$/) && ($rowspan > 0)) {
1.398 foxr 2315: $config{'rowspan'} = $rowspan;
2316: }
1.425 foxr 2317: if ($width ne '') {
2318: $config{'width'} = $width;
2319: }
1.398 foxr 2320: return \%config;
2321: }
1.159 sakharuk 2322:
2323: sub start_td_tex {
2324: my ($parstack,$parser,$safeeval) = @_;
1.398 foxr 2325:
2326: # At this stage, an empty cell is created with the
2327: # appropriate rowspan/colspan and alignment
2328: # attributes, but empty of text. end_td_tex will
2329: # fetch the contents from the recursive parse and
2330: # fill the cell with them:
1.425 foxr 2331: my $align = &Apache::lonxml::get_param('align', $parstack, $safeeval);
2332: my $rowspan = &Apache::lonxml::get_param('rowspan', $parstack, $safeeval);
2333: my $colspan = &Apache::lonxml::get_param('colspan', $parstack, $safeeval);
2334: my $width = &Apache::lonxml::get_param('TeXwidth', $parstack, $safeeval);
2335: my $config = &cell_config_hash($align, $rowspan, $colspan, $width);
1.398 foxr 2336:
2337: my $table = $Apache::londefdef::table[-1];
2338: $table->add_cell('', $config);
2339:
2340:
2341: #------------------------------------------------
2342: # Old table code.
2343: #------------------------------------------------
2344:
2345: if (0) {
2346:
1.206 sakharuk 2347: my $alignchar = substr(&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1),0,1);
2348: if ($alignchar eq '') {
2349: $alignchar = $Apache::londefdef::table[-1]{'rows'}[-1];
1.159 sakharuk 2350: }
1.206 sakharuk 2351: push @{ $Apache::londefdef::table[-1]{'align'}[$Apache::londefdef::table[-1]{'row_number'}] }, $alignchar;
1.159 sakharuk 2352: $Apache::londefdef::table[-1]{'counter_columns'}++;
1.206 sakharuk 2353: my $TeXwidth=&Apache::lonxml::get_param('TeXwidth',$parstack,$safeeval,undef,0);
2354: if (defined $TeXwidth) {
2355: my $current_length=&recalc($TeXwidth);
2356: $current_length=~/(\d+\.?\d*)/;
2357: push @ {$Apache::londefdef::table[-1]{'TeXlen'}[$Apache::londefdef::table[-1]{'row_number'}] },$1;
2358: }
1.398 foxr 2359: }
1.159 sakharuk 2360: &Apache::lonxml::startredirection();
2361: return '';
2362: }
2363:
2364: sub end_td_tex {
1.398 foxr 2365:
2366: my $text = &Apache::lonxml::endredirection();
2367: my $table = $Apache::londefdef::table[-1];
2368: $table->append_cell_text($text);
2369:
2370: #-------------------------------------------------
2371: # Old table code
2372: #-------------------------------------------------
2373:
2374: if (0) {
1.159 sakharuk 2375: my ($parstack,$parser,$safeeval) = @_;
1.304 foxr 2376: my $current_row = $Apache::londefdef::table[-1]{'row_number'};
2377: my $current_column = $Apache::londefdef::table[-1]{'counter_columns'};
1.303 foxr 2378: my $data = &Apache::lonxml::endredirection();
2379:
1.305 foxr 2380: # The rowspan array of the table indicates which cells are part of a span.
2381: # n indicates the start of a span set of n rows.
2382: # ^ indicates a cell that continues a span set.
1.306 foxr 2383: # _ indicates the cell is at the bottom of a span set.
1.305 foxr 2384: # If this and subsequent cells are part of a rowspan, we must
2385: # push along the row until we find one that is not.
2386:
2387: while ((defined $Apache::londefdef::table[-1]{'rowspan'}[$current_row] [$current_column])
1.306 foxr 2388: && ($Apache::londefdef::table[-1]{'rowspan'}[$current_row][$current_column] =~ /[\^\_]/)) {
1.305 foxr 2389: # Part of a span.
2390: push @ {$Apache::londefdef::table[-1]{'content'}[-1]}, '';
2391: $current_column++;
2392: }
2393: $Apache::londefdef::table[-1]{'counter_columns'} = $current_column;
2394:
2395:
1.320 foxr 2396: # Get the column and row spans.
2397: # Colspan can be done via \multicolumn if I can figure out the data structs.
2398:
2399: my $colspan = &Apache::lonxml::get_param('colspan', $parstack, $safeeval, undef, 0);
2400: if (!$colspan) {
2401: $colspan = 1;
2402: }
1.305 foxr 2403:
2404: my $rowspan = &Apache::lonxml::get_param('rowspan', $parstack, $safeeval, undef, 0);
2405: if (!$rowspan) {
2406: $rowspan = 1;
2407: }
2408:
1.303 foxr 2409:
1.305 foxr 2410:
1.320 foxr 2411: for (my $c = 0; $c < $colspan; $c++) {
2412: $Apache::londefdef::table[-1]{'rowspan'}[$current_row][$current_column+$c] = $rowspan;
2413: for (my $i = 1; $i < $rowspan; $i++) {
2414: $Apache::londefdef::table[-1]{'rowspan'}[$current_row+$i][$current_column+$c] = '^';
2415: if ($i == ($rowspan-1)) {
2416: $Apache::londefdef::table[-1]{'rowspan'}[$current_row+$i][$current_column+$c] = '_';
2417: }
1.306 foxr 2418: }
1.305 foxr 2419: }
1.304 foxr 2420:
1.159 sakharuk 2421: my $TeXwidth=&Apache::lonxml::get_param('TeXwidth',$parstack,$safeeval,undef,0);
2422: if (defined $TeXwidth) {
1.357 foxr 2423: for (my $c = 0; $c < $colspan; $c++) {
2424: push @ {$Apache::londefdef::table[-1]{'objectlen'}[$Apache::londefdef::table[-1]{'row_number'}] },'0';
2425: push @ {$Apache::londefdef::table[-1]{'minlen'}[$Apache::londefdef::table[-1]{'row_number'}] },'0';
2426: push @ {$Apache::londefdef::table[-1]{'maxlen'}[$Apache::londefdef::table[-1]{'row_number'}] },'0';
2427: }
1.159 sakharuk 2428: } else {
1.206 sakharuk 2429: if (($data=~m/width\s*=\s*(\d+\.?\d*\s*(mm|cm|in|pc|pt)*)/) or ($data=~m/\[(\d+\.?\d*)\s*mm\]/)) {
2430: my $garbage_data=$data;
2431: my $fwidth=0;
2432: while ($garbage_data=~m/width\s*=\s*(\d+\.?\d*\s*(mm|cm|in|pc|pt)*)/) {
2433: my $current_length=&recalc($1);
2434: $current_length=~/(\d+\.?\d*)/;
2435: if ($fwidth<$1) {$fwidth=$1;}
2436: $garbage_data=~s/width\s*=\s*(\d+\.?\d*\s*(mm|cm|in|pc|pt)*)//;
2437: }
2438: while ($garbage_data=~m/\[(\d+\.?\d*)\s*mm\]/) {
2439: my $current_length=$1;
2440: if ($fwidth<$current_length) {$fwidth=$current_length;}
2441: $garbage_data=~s/\[(\d+\.?\d*)\s*mm\]//;
2442: }
1.357 foxr 2443: for (my $c = 0; $c < $colspan; $c++) {
2444: push @ {$Apache::londefdef::table[-1]{'TeXlen'}[$Apache::londefdef::table[-1]{'row_number'}] },'0';
2445: push @ {$Apache::londefdef::table[-1]{'objectlen'}[$Apache::londefdef::table[-1]{'row_number'}] },$fwidth;
2446: push @ {$Apache::londefdef::table[-1]{'minlen'}[$Apache::londefdef::table[-1]{'row_number'}] },'0';
2447: push @ {$Apache::londefdef::table[-1]{'maxlen'}[$Apache::londefdef::table[-1]{'row_number'}] },'0';
2448: }
1.231 sakharuk 2449: } elsif ($data=~/\\parbox\{\s*\d+\.?\d*\s*(mm|cm|in|pc|pt)*\s*\}/ or $data=~/\\epsfxsize\s*=\s*\d+\.?\d*\s*(mm|cm|in|pc|pt)*/) {
2450: my $garbage_data=$data;
2451: my $fwidth=0;
2452: while ($garbage_data=~/\\parbox\{\s*(\d+\.?\d*\s*(mm|cm|in|pc|pt)*)\s*\}/) {
2453: my $current_length=&recalc($1);
2454: $current_length=~/(\d+\.?\d*)/;
2455: if ($fwidth<$1) {$fwidth=$1;}
2456: $garbage_data=~s/\\parbox\{\s*(\d+\.?\d*\s*(mm|cm|in|pc|pt)*)//;
2457: }
2458: while ($garbage_data=~/\\epsfxsize\s*=\s*(\d+\.?\d*\s*(mm|cm|in|pc|pt)*)/) {
2459: my $current_length=&recalc($1);
2460: $current_length=~/(\d+\.?\d*)/;
2461: if ($fwidth<$1) {$fwidth=$1;}
2462: $garbage_data=~s/\\epsfxsize\s*=\s*(\d+\.?\d*\s*(mm|cm|in|pc|pt)*)//;
2463: }
1.357 foxr 2464: for (my $c = 0; $c < $colspan; $c++) {
2465: push @ {$Apache::londefdef::table[-1]{'TeXlen'}[$Apache::londefdef::table[-1]{'row_number'}] },'0';
2466: push @ {$Apache::londefdef::table[-1]{'objectlen'}[$Apache::londefdef::table[-1]{'row_number'}] },$fwidth;
2467: push @ {$Apache::londefdef::table[-1]{'minlen'}[$Apache::londefdef::table[-1]{'row_number'}] },'0';
2468: push @ {$Apache::londefdef::table[-1]{'maxlen'}[$Apache::londefdef::table[-1]{'row_number'}] },'0';
2469: }
1.231 sakharuk 2470: $data=~s/\\\\\s*$//;
1.159 sakharuk 2471: } else {
1.166 sakharuk 2472: $data=~s/^\s+(\S.*)/$1/;
1.159 sakharuk 2473: $data=~s/(.*\S)\s+$/$1/;
1.166 sakharuk 2474: $data=~s/(\s)+/$1/;
1.206 sakharuk 2475: my ($current_length,$min_length)=(0,0);
1.166 sakharuk 2476: if ($data=~/\\vskip/) {
2477: my $newdata=$data;
2478: $newdata=~s/\\vskip \d*\.?\d*\s*mm/THISISJUSTTEMPORARYSEPARATOR/g;
2479: my @newdata=split(/THISISJUSTTEMPORARYSEPARATOR/,$newdata);
2480: foreach my $elementdata (@newdata) {
1.206 sakharuk 2481: my $lengthnewdata=2.5*&LATEX_length($elementdata);
1.166 sakharuk 2482: if ($lengthnewdata>$current_length) {$current_length=$lengthnewdata;}
1.206 sakharuk 2483: my @words=split(/ /,$elementdata);
2484: foreach my $word (@words) {
2485: my $lengthword=2.5*&LATEX_length($word);
2486: if ($min_length<$lengthword) {$min_length=$lengthword;}
2487: }
1.166 sakharuk 2488: }
2489: } else {
1.206 sakharuk 2490: $current_length=2.5*&LATEX_length($data);
2491: my @words=split(/ /,$data);
2492: foreach my $word (@words) {
1.228 sakharuk 2493: my $lengthword=2*&LATEX_length($word);
1.206 sakharuk 2494: if ($min_length<$lengthword) {$min_length=$lengthword;}
2495: }
1.166 sakharuk 2496: }
1.357 foxr 2497: for (my $c = 0; $c < $colspan; $c++) {
2498: push @ {$Apache::londefdef::table[-1]{'TeXlen'}[$Apache::londefdef::table[-1]{'row_number'}] },'0';
2499: push @ {$Apache::londefdef::table[-1]{'objectlen'}[$Apache::londefdef::table[-1]{'row_number'}] },'0';
2500: push @ {$Apache::londefdef::table[-1]{'maxlen'}[$Apache::londefdef::table[-1]{'row_number'}] },$current_length;
2501: push @ {$Apache::londefdef::table[-1]{'minlen'}[$Apache::londefdef::table[-1]{'row_number'}] },$min_length;
2502: }
1.159 sakharuk 2503: }
2504: }
1.302 foxr 2505: # Substitute all of the tables nested in this cell in their appropriate places.
2506:
2507:
2508: my $nested_count = $#{$Apache::londefdef::table[-1]{'include'}}; # This one is constant...
2509: for (my $in=0; $in<=$nested_count; $in++) {
1.301 foxr 2510: my $nested = shift @{$Apache::londefdef::table[-1]{'include'}};
2511: $nested =~ s/\\end\{tabular\}\\strut\\\\/\\end\{tabular\}/;
2512: # $data=~s/\\keephidden\{NEW TABLE ENTRY\}/$Apache::londefdef::table[-1]{'include'}[$in]/;
2513: $data =~ s/\\keephidden\{NEW TABLE ENTRY\}/$nested/;
2514:
2515: }
2516: # Should be be killing off the 'include' elements as they're used up?
1.305 foxr 2517:
1.206 sakharuk 2518: push @ {$Apache::londefdef::table[-1]{'content'}[-1] },$data;
1.305 foxr 2519:
1.304 foxr 2520:
2521:
2522:
2523: # the colspan array will indicate how many columns will be spanned by this
2524: # cell..this requires that counter_columns also be adjusted accordingly
2525: # so that the next bunch of text goes in the right cell. Note that since
2526: # counter_columns is incremented in the start_td_tex, we adjust by colspan-1.
2527: #
2528:
2529: $Apache::londefdef::table[-1]{'counter_columns'} += $colspan -1;
2530: for (my $i = 0; $i < ($colspan -1); $i++) {
2531: push @ {$Apache::londefdef::table[-1]{'content'}[-1] },'';
2532: }
1.320 foxr 2533: for (my $r = 0; $r < $rowspan; $r++) {
2534: $Apache::londefdef::table[-1]{'colspan'}[$current_row+$r][$current_column] = $colspan;
2535: # Put empty text in spanned cols.
2536:
2537: }
2538:
1.398 foxr 2539: }
1.304 foxr 2540:
1.301 foxr 2541: return '';
1.159 sakharuk 2542: }
2543:
1.122 albertel 2544: sub end_td {
1.126 sakharuk 2545: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1.122 albertel 2546: my $currentstring = '';
1.325 albertel 2547: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 2548: $currentstring = $token->[2];
2549: } elsif ($target eq 'tex') {
1.160 sakharuk 2550: $Apache::londefdef::TD_redirection =0;
1.159 sakharuk 2551: &end_td_tex($parstack,$parser,$safeeval);
1.122 albertel 2552: }
2553: return $currentstring;
2554: }
2555:
1.166 sakharuk 2556: #-- <th> tag (end tag optional)
1.122 albertel 2557: sub start_th {
2558: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
2559: my $currentstring = '';
1.325 albertel 2560: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 2561: $currentstring = $token->[4];
2562: } elsif ($target eq 'tex') {
1.230 sakharuk 2563: $Apache::londefdef::TD_redirection = 1;
2564: &tagg_check('tr','th',$tagstack,$parstack,$parser,$safeeval);
1.122 albertel 2565: }
2566: return $currentstring;
1.130 sakharuk 2567: }
1.230 sakharuk 2568:
2569: sub tagg_check {
2570: my ($good_tag,$bad_tag,$tagstack,$parstack,$parser,$safeeval) = @_;
2571: my @ar=@$parstack;
2572: for (my $i=$#ar-1;$i>=0;$i--) {
2573: if (lc($$tagstack[$i]) eq $good_tag) {
2574: &start_th_tex($parstack,$parser,$safeeval);
2575: last;
2576: } elsif (lc($$tagstack[$i]) eq $bad_tag) {
2577: splice @ar, $i+1;
2578: &end_th_tex(\@ar,$parser,$safeeval);
2579: &start_th_tex($parstack,$parser,$safeeval);
2580: last;
2581: }
2582: }
2583: return '';
2584: }
2585:
2586: sub start_th_tex {
2587: my ($parstack,$parser,$safeeval) = @_;
1.398 foxr 2588:
2589: my $alignment = &Apache::lonxml::get_param('align', $parstack, $safeeval, undef,1);
2590: my $rowspan = &Apache::lonxml::get_param('rowspan', $parstack, $safeeval, undef, 1);
2591: my $colspan = &Apache::lonxml::get_param('colspan', $parstack, $safeeval, undef, 1);
2592:
2593: my $config = cell_config_hash($alignment, $rowspan, $colspan);
2594: my $table = $Apache::londefdef::table[-1];
2595: $table->add_cell('\textbf{', $config);
2596:
2597: #-------------------------------------------------------------------------------------
2598: #
2599: # Old table code.
2600: #
2601: #--------------------------------------------------------------------------------------
2602:
2603: if (0) {
2604:
2605:
1.230 sakharuk 2606: my $alignchar = substr(&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1),0,1);
2607: if ($alignchar eq '') {
2608: $alignchar = $Apache::londefdef::table[-1]{'rows'}[-1];
2609: }
2610: push @{ $Apache::londefdef::table[-1]{'align'}[$Apache::londefdef::table[-1]{'row_number'}] }, $alignchar;
2611: $Apache::londefdef::table[-1]{'counter_columns'}++;
2612: my $TeXwidth=&Apache::lonxml::get_param('TeXwidth',$parstack,$safeeval,undef,0);
2613: if (defined $TeXwidth) {
2614: my $current_length=&recalc($TeXwidth);
2615: $current_length=~/(\d+\.?\d*)/;
2616: push @ {$Apache::londefdef::table[-1]{'TeXlen'}[$Apache::londefdef::table[-1]{'row_number'}] },$1;
2617: }
1.398 foxr 2618: }
2619:
2620: # Accept xml until the </th> tag.
2621:
1.230 sakharuk 2622: &Apache::lonxml::startredirection();
2623: return '';
2624: }
2625:
2626: sub end_th_tex {
2627: my ($parstack,$parser,$safeeval) = @_;
1.398 foxr 2628:
2629: my $table = $Apache::londefdef::table[-1];
2630: my $text = &Apache::lonxml::endredirection();
2631: $table->append_cell_text($text.'}');
2632:
2633: #-----------------------------------------------------------------------------
2634: # Old table code:
2635: #-----------------------------------------------------------------------------
2636:
2637: if (0) {
1.230 sakharuk 2638: my $current_row = $Apache::londefdef::table[-1]{'row_number'};
2639: my $data=&Apache::lonxml::endredirection();
2640: my $TeXwidth=&Apache::lonxml::get_param('TeXwidth',$parstack,$safeeval,undef,0);
2641: if (defined $TeXwidth) {
2642: push @ {$Apache::londefdef::table[-1]{'objectlen'}[$Apache::londefdef::table[-1]{'row_number'}] },'0';
2643: push @ {$Apache::londefdef::table[-1]{'minlen'}[$Apache::londefdef::table[-1]{'row_number'}] },'0';
2644: push @ {$Apache::londefdef::table[-1]{'maxlen'}[$Apache::londefdef::table[-1]{'row_number'}] },'0';
2645: } else {
2646: if (($data=~m/width\s*=\s*(\d+\.?\d*\s*(mm|cm|in|pc|pt)*)/) or ($data=~m/\[(\d+\.?\d*)\s*mm\]/)) {
2647: my $garbage_data=$data;
2648: my $fwidth=0;
2649: while ($garbage_data=~m/width\s*=\s*(\d+\.?\d*\s*(mm|cm|in|pc|pt)*)/) {
2650: my $current_length=&recalc($1);
2651: $current_length=~/(\d+\.?\d*)/;
2652: if ($fwidth<$1) {$fwidth=$1;}
2653: $garbage_data=~s/width\s*=\s*(\d+\.?\d*\s*(mm|cm|in|pc|pt)*)//;
2654: }
2655: while ($garbage_data=~m/\[(\d+\.?\d*)\s*mm\]/) {
2656: my $current_length=$1;
2657: if ($fwidth<$current_length) {$fwidth=$current_length;}
2658: $garbage_data=~s/\[(\d+\.?\d*)\s*mm\]//;
2659: }
2660: push @ {$Apache::londefdef::table[-1]{'TeXlen'}[$Apache::londefdef::table[-1]{'row_number'}] },'0';
2661: push @ {$Apache::londefdef::table[-1]{'objectlen'}[$Apache::londefdef::table[-1]{'row_number'}] },$fwidth;
2662: push @ {$Apache::londefdef::table[-1]{'minlen'}[$Apache::londefdef::table[-1]{'row_number'}] },'0';
2663: push @ {$Apache::londefdef::table[-1]{'maxlen'}[$Apache::londefdef::table[-1]{'row_number'}] },'0';
2664: } else {
2665: $data=~s/^\s+(\S.*)/$1/;
2666: $data=~s/(.*\S)\s+$/$1/;
2667: $data=~s/(\s)+/$1/;
2668: my ($current_length,$min_length)=(0,0);
2669: if ($data=~/\\vskip/) {
2670: my $newdata=$data;
2671: $newdata=~s/\\vskip \d*\.?\d*\s*mm/THISISJUSTTEMPORARYSEPARATOR/g;
2672: my @newdata=split(/THISISJUSTTEMPORARYSEPARATOR/,$newdata);
2673: foreach my $elementdata (@newdata) {
2674: my $lengthnewdata=2.5*&LATEX_length($elementdata);
2675: if ($lengthnewdata>$current_length) {$current_length=$lengthnewdata;}
2676: my @words=split(/ /,$elementdata);
2677: foreach my $word (@words) {
2678: my $lengthword=2.5*&LATEX_length($word);
2679: if ($min_length<$lengthword) {$min_length=$lengthword;}
2680: }
2681: }
2682: } else {
2683: $current_length=2.5*&LATEX_length($data);
2684: my @words=split(/ /,$data);
2685: foreach my $word (@words) {
2686: my $lengthword=2*&LATEX_length($word);
2687: if ($min_length<$lengthword) {$min_length=$lengthword;}
2688: }
2689: }
2690: push @ {$Apache::londefdef::table[-1]{'TeXlen'}[$Apache::londefdef::table[-1]{'row_number'}] },'0';
2691: push @ {$Apache::londefdef::table[-1]{'objectlen'}[$Apache::londefdef::table[-1]{'row_number'}] },'0';
2692: push @ {$Apache::londefdef::table[-1]{'maxlen'}[$Apache::londefdef::table[-1]{'row_number'}] },$current_length;
2693: push @ {$Apache::londefdef::table[-1]{'minlen'}[$Apache::londefdef::table[-1]{'row_number'}] },$min_length;
2694: }
2695: }
2696: for (my $in=0; $in<=$#{$Apache::londefdef::table[-1]{'include'}};$in++) {
2697: $data=~s/\\keephidden\{NEW TABLE ENTRY\}/$Apache::londefdef::table[-1]{'include'}[$in]/;
2698: }
2699: #make data bold
2700: $data='\textbf{'.$data.'}';
2701: push @ {$Apache::londefdef::table[-1]{'content'}[-1] },$data;
1.398 foxr 2702: }
1.230 sakharuk 2703: return'';
2704: }
2705:
1.122 albertel 2706: sub end_th {
1.130 sakharuk 2707: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1.279 foxr 2708: my $currentstring = &end_p(); # Close any open <p> in the row.
1.325 albertel 2709: if ($target eq 'web' || $target eq 'webgrade') {
1.277 foxr 2710: $currentstring .= $token->[2];
1.122 albertel 2711: } elsif ($target eq 'tex') {
1.230 sakharuk 2712: $Apache::londefdef::TD_redirection =0;
2713: &end_th_tex($parstack,$parser,$safeeval);
1.122 albertel 2714: }
2715: return $currentstring;
2716: }
1.230 sakharuk 2717:
1.181 sakharuk 2718: #-- <img> tag (end tag forbidden)
1.249 foxr 2719: #
2720: # Render the <IMG> tag.
2721: # <IMG> has the following attributes (in addition to the
2722: # standard HTML ones:
2723: # TeXwrap - Governs how the tex target will try to wrap text around
2724: # horizontally aligned images.
2725: # TeXwidth - The width of the image when rendered for print (mm).
2726: # TeXheight - The height of the image when rendered for print (mm)
2727: # (Note there seems to also be support for this as a % of page size)
2728: #
1.122 albertel 2729: sub start_img {
1.299 albertel 2730: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style) = @_;
1.122 albertel 2731: my $src = &Apache::lonxml::get_param('src',$parstack,$safeeval,
2732: undef,1);
1.325 albertel 2733: if (! $src &&
2734: ($target eq 'web' || $target eq 'webgrade' || $target eq 'tex')
2735: ) {
1.299 albertel 2736: my $inside = &Apache::lonxml::get_all_text("/img",$parser,$style);
1.189 albertel 2737: return '';
2738: }
1.290 albertel 2739: &Apache::lonxml::extlink($src);
1.122 albertel 2740: my $currentstring = '';
2741: my $scaling = .3;
1.249 foxr 2742:
2743: # Render unto browsers that which are the browser's...
2744:
1.325 albertel 2745: if ($target eq 'web' || $target eq 'webgrade') {
1.417 bisitz 2746: my $enc = ('yes' eq
2747: lc(&Apache::lonxml::get_param('encrypturl',$parstack,
2748: $safeeval)));
2749: $currentstring.=&Apache::lonenc::encrypt_ref($token,{'src'=>$src},
2750: $enc);
1.249 foxr 2751:
1.417 bisitz 2752: # and render unto TeX that which is LaTeX
1.122 albertel 2753: } elsif ($target eq 'tex') {
1.248 foxr 2754: #
2755: # The alignment will require some superstructure to be put around
2756: # the \includegraphics stuff. At present we can only partially
2757: # simulate the alignments offered by html.
2758: #
2759: #
2760: my $align = lc(&Apache::lonxml::get_param('align',
2761: $parstack,
2762: $safeeval,
2763: undef,1));
2764: if(!$align) {
1.287 foxr 2765: $align = "bottom"; # This is html's default so it's ours too.
1.248 foxr 2766: }
2767: #
2768: &Apache::lonxml::debug("Alignemnt = $align");
2769: # LaTeX's image/text wrapping is really bad since it wants to
2770: # make figures float.
2771: # The user has the optional parameter (applicable only to l/r
2772: # alignment to use the picins/parpic directive to get wrapped text
2773: # this is also imperfect.. that's why we give them a choice...
2774: # so they can't yell at us for our choice.
2775: #
2776: my $latex_rendering = &Apache::lonxml::get_param('TeXwrap',
2777: $parstack,
2778: $safeeval,
2779: undef,0);
1.312 foxr 2780: # &Apache::lonxml::debug("LaTeX rendering = $latex_rendering");
1.248 foxr 2781: if(!$latex_rendering) {
1.312 foxr 2782: $latex_rendering = "texwrap";
2783: }
2784: # using texwrap inside a table does not work. So, if after all of this,
2785: # texwrap is on, we turn it off if we detect we're in a table:
2786: #
2787: if (($latex_rendering eq 'texwrap') && &is_inside_of($tagstack, "table")) {
2788: $latex_rendering = 'parpic';
1.248 foxr 2789: }
1.323 foxr 2790:
1.312 foxr 2791: # &Apache::lonxml::debug("LaTeX rendering = $latex_rendering image file: $src");
1.248 foxr 2792:
1.390 foxr 2793: #if original bmp/gif/jpg/png file exist do following:
1.266 albertel 2794: my $origsrc=$src;
1.256 albertel 2795: my ($path,$file) = &get_eps_image($src);
1.341 foxr 2796: # &Apache::lonnet::logthis("Image source: $src result: $path $file");
1.122 albertel 2797: $src=&Apache::lonnet::filelocation($Apache::lonxml::pwd[-1],$src);
1.261 foxr 2798: &Apache::lonxml::debug("path = $path file = $file src = $src");
1.192 sakharuk 2799: if (-e $src) {
1.261 foxr 2800: &Apache::lonxml::debug("$src exists");
1.256 albertel 2801: my ($height_param,$width_param)=
1.266 albertel 2802: &image_size($origsrc,0.3,$parstack,$safeeval);
2803: my $size;
2804: if ($width_param) { $size.='width='.$width_param.' mm,'; }
2805: if ($height_param) { $size.='height='.$height_param.' mm]'; }
1.341 foxr 2806: # Default size if not able to extract that (e.g. eps image).
2807:
2808: # &Apache::lonnet::logthis("Size = $size");
2809:
1.266 albertel 2810: $size='['.$size;
2811: $size=~s/,$/]/;
1.344 albertel 2812: $currentstring .= '\graphicspath{{'.$path.'}}'
2813: .'\includegraphics'.$size.'{'.$file.'} ';
1.354 foxr 2814: my $closure;
2815: ($currentstring, $closure) = &align_latex_image($align,
2816: $latex_rendering,
2817: $currentstring,
2818: $width_param,
2819: $height_param);
2820: $currentstring .= $closure;
1.353 foxr 2821:
1.122 albertel 2822: } else {
1.261 foxr 2823: &Apache::lonxml::debug("$src does not exist");
1.122 albertel 2824: #original image file doesn't exist so check the alt attribute
2825: my $alt =
2826: &Apache::lonxml::get_param('alt',$parstack,$safeeval,undef,1);
2827: unless ($alt) {
2828: $alt=&Apache::lonmeta::alttag($Apache::lonxml::pwd[-1],$src);
2829: }
2830:
1.256 albertel 2831: if ($alt) { $currentstring .= ' '.$alt.' '; }
1.59 sakharuk 2832: }
1.249 foxr 2833:
2834: # And here's where the semi-quote breaks down: allow the user
2835: # to edit the beast as well by rendering the problem for edit:
1.186 albertel 2836: } elsif ($target eq 'edit') {
1.368 banghart 2837: my $only = join(',',&Apache::loncommon::filecategorytypes('Pictures'));
1.186 albertel 2838: $currentstring .=&Apache::edit::tag_start($target,$token);
2839: $currentstring .=&Apache::edit::text_arg('Image Url:','src',$token,70).
1.368 banghart 2840: &Apache::edit::browse('src',undef,'alt',$only).' '.
1.186 albertel 2841: &Apache::edit::search('src',undef,'alt').'<br />';
2842: $currentstring .=&Apache::edit::text_arg('Description:','alt',$token,70).'<br />';
2843: $currentstring .=&Apache::edit::text_arg('width (pixel):','width',$token,5);
2844: $currentstring .=&Apache::edit::text_arg('height (pixel):','height',$token,5).'<br />';
2845: $currentstring .=&Apache::edit::text_arg('TeXwidth (mm):','TeXwidth',$token,5);
2846: $currentstring .=&Apache::edit::text_arg('TeXheight (mm):','TeXheight',$token,5);
1.234 albertel 2847: $currentstring .=&Apache::edit::select_arg('Alignment:','align',
2848: ['','bottom','middle','top','left','right'],$token,5);
1.249 foxr 2849: $currentstring .=&Apache::edit::select_arg('TeXwrap:', 'TeXwrap',
1.348 albertel 2850: ['', 'none','parbox', 'parpic', 'wrapfigure'], $token, 2);
1.418 www 2851: my $alt= &Apache::lonxml::get_param('alt',$parstack,$safeeval);
2852: my $enc= &Apache::lonxml::get_param('encrypturl',$parstack,$safeeval);
2853:
1.332 www 2854: $currentstring .=&Apache::edit::select_arg('Encrypt URL:','encrypturl',
1.322 albertel 2855: ['no','yes'], $token, 2);
1.418 www 2856: if (($alt=~/\S/) && (lc($enc) eq 'yes')) {
2857: $currentstring.='<br /><span class="LC_warning">'.&mt('Warning: the description "[_1]" will be available, even for encrypted URL',$alt).'</span><br />';
2858: }
1.186 albertel 2859: $currentstring .=&Apache::edit::end_row().&Apache::edit::start_spanning_row();
1.249 foxr 2860: my $src= &Apache::lonxml::get_param('src',$parstack,$safeeval);
2861: my $width= &Apache::lonxml::get_param('width',$parstack,$safeeval);
2862: my $height= &Apache::lonxml::get_param('height',$parstack,$safeeval);
2863:
1.381 www 2864: if ($token->[2]{'src'}=~/\$/) {
1.418 www 2865: $currentstring.=&mt('Variable image source');
2866: } elsif ($token->[2]{'src'}=~/\S/) {
1.381 www 2867: $currentstring .= '<img src="'.$src.'" alt="'.$alt.'" ';
2868: if ($width) { $currentstring.=' width="'.$width.'" '; }
2869: if ($height) { $currentstring.=' height="'.$height.'" '; }
2870: $currentstring .= ' />';
1.418 www 2871: } else {
2872: $currentstring.=&mt("No image source specified");
1.381 www 2873: }
1.186 albertel 2874: } elsif ($target eq 'modified') {
1.210 albertel 2875: my ($osrc,$owidth,$oheight)=
2876: ($token->[2]{'src'},$token->[2]{'width'},$token->[2]{'height'});
2877: my $ctag=&Apache::edit::get_new_args($token,$parstack,
1.234 albertel 2878: $safeeval,'src','alt','align',
1.249 foxr 2879: 'TeXwidth','TeXheight', 'TeXwrap',
1.322 albertel 2880: 'width','height','encrypturl');
1.210 albertel 2881: my ($nsrc,$nwidth,$nheight)=
2882: ($token->[2]{'src'},$token->[2]{'width'},$token->[2]{'height'});
2883: my $loc=&Apache::lonnet::filelocation($Apache::lonxml::pwd[-1],$nsrc);
2884: &image_replication($loc);
2885: my ($iwidth,$iheight);
2886: if (-e $loc) {
2887: my $image = Image::Magick->new;
2888: $image->Read($loc);
2889: ($iwidth, $iheight) = ($image->Get('width'),
2890: $image->Get('height'));
2891: }
2892: if ($osrc ne $nsrc || (!$nwidth && !$nheight)) {
2893: # changed image or no size specified,
2894: # if they didn't explicitly change the
2895: # width or height use the ones from the image
2896: if ($iwidth && $iheight) {
2897: if ($owidth == $nwidth || (!$nwidth && !$nheight)) {
2898: $token->[2]{'width'} = $iwidth;$ctag=1;
2899: }
2900: if ($oheight == $nheight || (!$nwidth && !$nheight)) {
2901: $token->[2]{'height'}=$iheight;$ctag=1;
1.186 albertel 2902: }
2903: }
2904: }
1.210 albertel 2905: my ($cwidth,$cheight)=($token->[2]{'width'},$token->[2]{'height'});
2906: # if we don't have a width or height
2907: if ($iwidth && $cwidth && !$cheight) {
2908: $token->[2]{'height'}=int(($cwidth/$iwidth)*$iheight);$ctag=1;
2909: }
2910: if ($iheight && $cheight && !$cwidth) {
2911: $token->[2]{'width'}=int(($cheight/$iheight)*$iwidth);$ctag=1;
2912: }
2913: if ($ctag) {$currentstring=&Apache::edit::rebuild_tag($token);}
1.122 albertel 2914: }
1.261 foxr 2915:
1.122 albertel 2916: return $currentstring;
2917: }
2918:
2919: sub end_img {
2920: my ($target,$token) = @_;
2921: my $currentstring = '';
1.325 albertel 2922: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 2923: $currentstring = $token->[2];
2924: } elsif ($target eq 'tex') {
2925: $currentstring = '';
2926: }
2927: return $currentstring;
2928: }
2929:
1.181 sakharuk 2930: #-- <applet> tag (end tag required)
1.122 albertel 2931: sub start_applet {
2932: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
2933:
2934: my $code=&Apache::lonxml::get_param('code',$parstack,$safeeval,undef,1);
1.290 albertel 2935: &Apache::lonxml::extlink($code);
1.122 albertel 2936: my $archive=&Apache::lonxml::get_param('archive',$parstack,$safeeval,
2937: undef,1);
1.290 albertel 2938: &Apache::lonxml::extlink($archive);
1.122 albertel 2939: my $currentstring = '';
1.325 albertel 2940: if ($target eq 'web' || $target eq 'webgrade') {
1.434 raeburn 2941: $currentstring = $token->[4];
1.122 albertel 2942: } elsif ($target eq 'tex') {
1.417 bisitz 2943: # Turn off some stuff we can't be inside thank you LaTeX
1.361 foxr 2944:
2945: my $restart_sub = 0;
2946: my $restart_sup = 0;
2947:
2948: # Since <sub> and <sup> are simple tags it's ok to turn off/on
2949: # using the start_ stop_ functions.. those tags only care about
2950: # $target.
2951:
2952: if (&is_inside_of($tagstack, "sub")) {
2953: $restart_sub = 1;
2954: $currentstring .= &end_sub($target, $token, $tagstack,
2955: $parstack, $parser, $safeeval);
2956: }
2957: if (&is_inside_of($tagstack, "sup")) {
2958: $restart_sup = 1;
2959: $currentstring .= &end_sup($target, $token, $tagstack,
2960: $parstack, $parser, $safeeval);
2961: }
2962:
2963: # Now process the applet; just replace it with its alt attribute.
2964:
1.177 albertel 2965: my $alttag= &Apache::lonxml::get_param('alt',$parstack,
2966: $safeeval,undef,1);
2967: unless ($alttag) {
2968: my $code=&Apache::lonxml::get_param('code',$parstack,$safeeval,
2969: undef,1);
2970: $alttag=&Apache::lonmeta::alttag($Apache::lonxml::pwd[-1],
2971: $code);
1.175 sakharuk 2972: }
1.177 albertel 2973: $currentstring.='\begin{center} \fbox{Java Applet: '.$alttag.
2974: '.}\end{center}';
1.361 foxr 2975:
2976: # Turn stuff back on that we can't be inside of.
2977:
2978: if ($restart_sub) {
2979: $currentstring .= &start_sub($target, $token, $tagstack,
2980: $parstack, $parser, $safeeval);
2981: }
2982: if ($restart_sup) {
2983: $currentstring .= &start_sup($target, $token, $tagstack,
2984: $parstack, $parser, $safeeval);
2985: }
1.122 albertel 2986: }
2987: return $currentstring;
2988: }
2989:
2990: sub end_applet {
2991: my ($target,$token) = @_;
2992: my $currentstring = '';
1.325 albertel 2993: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 2994: $currentstring = $token->[2];
2995: } elsif ($target eq 'tex') {
2996: }
2997: return $currentstring;
2998: }
2999:
1.181 sakharuk 3000: #-- <embed> tag (end tag optional/required)
1.122 albertel 3001: sub start_embed {
3002: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
3003: my $src=&Apache::lonxml::get_param('src',$parstack,$safeeval,undef,1);
1.290 albertel 3004: &Apache::lonxml::extlink($src);
1.122 albertel 3005: my $currentstring = '';
1.325 albertel 3006: if ($target eq 'web' || $target eq 'webgrade') {
1.417 bisitz 3007: $currentstring=&Apache::lonenc::encrypt_ref($token,{'src'=>$src});
1.122 albertel 3008: } elsif ($target eq 'tex') {
3009: }
3010: return $currentstring;
3011: }
3012:
3013: sub end_embed {
3014: my ($target,$token) = @_;
3015: my $currentstring = '';
1.325 albertel 3016: if ($target eq 'web' || $target eq 'webgrade') {
1.417 bisitz 3017: $currentstring = $token->[2];
3018: } elsif ($target eq 'tex') {
3019: # ./.
3020: }
1.122 albertel 3021: return $currentstring;
3022: }
3023:
1.181 sakharuk 3024: #-- <param> tag (end tag forbidden)
1.122 albertel 3025: sub start_param {
3026: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1.437 raeburn 3027: my $name = &Apache::lonxml::get_param('name',$parstack,$safeeval,
3028: undef,1);
3029: if ($name =~/^cabbase$/i) {
1.290 albertel 3030: my $value=&Apache::lonxml::get_param('value',$parstack,
3031: $safeeval,undef,1);
3032: &Apache::lonxml::extlink($value);
1.437 raeburn 3033: } elsif ($name eq 'flashvars') {
3034: if (lc(&Apache::lonxml::get_param('type',$parstack,$safeeval,-2,1))
3035: eq 'application/x-shockwave-flash') {
3036: my $launcher =
3037: &Apache::lonxml::get_param('data',$parstack,$safeeval,-2,1);
3038: if ($launcher) {
3039: &Apache::lonxml::extlink($launcher);
3040: }
3041: my $flashvars=&Apache::lonxml::get_param('value',$parstack,
3042: $safeeval,undef,1);
3043: if ($flashvars ne '') {
3044: foreach my $item (split(/\&/,$flashvars)) {
3045: my ($key,$value)=split(/=/,$item,2);
3046: if ($key eq 'content') {
3047: if ($value ne '') {
3048: my ($dir) = ($launcher =~ m{(.+/)[^/]+$});
3049: &Apache::lonxml::extlink($dir.$value);
3050: }
3051: } elsif ($key eq 'thumb') {
3052: if ($value ne '') {
3053: &Apache::lonxml::extlink($value);
3054: }
3055: }
3056: }
3057: }
3058: }
3059: }
1.290 albertel 3060: my $src = &Apache::lonxml::get_param('src',$parstack,$safeeval,undef,1);
1.437 raeburn 3061: if ($src ne '') {
3062: &Apache::lonxml::extlink($src);
3063: }
1.122 albertel 3064: my $currentstring = '';
1.325 albertel 3065: if ($target eq 'web' || $target eq 'webgrade') {
1.250 albertel 3066: my %toconvert;
3067: if ($src) { $toconvert{'src'}= $src; }
1.251 albertel 3068: if ($name=~/^cabbase$/i) {
3069: $toconvert{'value'}=&Apache::lonxml::get_param('value',$parstack,
3070: $safeeval,undef,1);
3071: }
1.250 albertel 3072: $currentstring = &Apache::lonenc::encrypt_ref($token,\%toconvert);
1.122 albertel 3073: } elsif ($target eq 'tex') {
3074: }
3075: return $currentstring;
3076: }
3077:
3078: sub end_param {
3079: my ($target,$token) = @_;
3080: my $currentstring = '';
1.325 albertel 3081: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 3082: $currentstring = $token->[2];
3083: } elsif ($target eq 'tex') {
3084: }
3085: return $currentstring;
3086: }
3087:
3088: #-- <allow> tag
3089: sub start_allow {
3090: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
3091: my $src = &Apache::lonxml::get_param('src',$parstack,$safeeval,undef,1);
1.290 albertel 3092: &Apache::lonxml::extlink($src);
3093:
1.241 albertel 3094: if ($target eq 'tex') { &image_replication($src); }
1.122 albertel 3095: my $result;
3096: if ($target eq 'edit') {
3097: $result .=&Apache::edit::tag_start($target,$token);
3098: $result .=&Apache::edit::text_arg('File Spec:','src',$token,70);
3099: $result .=&Apache::edit::end_row();#.&Apache::edit::start_spanning_row();
3100: } elsif ($target eq 'modified') {
3101: my $constructtag=&Apache::edit::get_new_args($token,$parstack,
3102: $safeeval,'src');
3103: if ($constructtag) { $result = &Apache::edit::rebuild_tag($token); }
3104: }
3105: return $result;
3106: }
3107:
3108: sub end_allow {
3109: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
3110: if ( $target eq 'edit') { return (&Apache::edit::end_table()); }
3111: return '';
3112: }
1.119 www 3113:
1.181 sakharuk 3114: #-- Frames (end tag required)
3115: #-- <frameset>
1.122 albertel 3116: sub start_frameset {
3117: my ($target,$token) = @_;
1.277 foxr 3118: my $currentstring = ''; # Close any pending para.
1.325 albertel 3119: if ($target eq 'web' || $target eq 'webgrade') {
1.328 albertel 3120: $currentstring =
3121: &Apache::loncommon::start_page($Apache::londefdef::title,
3122: $Apache::londefdef::head,
3123: {'add_entries' => $token->[2],
1.404 bisitz 3124: # 'no_title' => 1,
1.328 albertel 3125: 'force_register' => 1,
3126: 'frameset' => 1,});
3127:
1.122 albertel 3128: }
3129: return $currentstring;
3130: }
3131:
3132: sub end_frameset {
3133: my ($target,$token) = @_;
3134: my $currentstring = '';
1.325 albertel 3135: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 3136: $currentstring = $token->[2];
3137: }
3138: return $currentstring;
3139: }
1.162 sakharuk 3140:
1.181 sakharuk 3141: #-- <xmp> (end tag required)
1.162 sakharuk 3142: sub start_xmp {
3143: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
3144: my $currentstring = '';
1.325 albertel 3145: if ($target eq 'web' || $target eq 'webgrade') {
1.162 sakharuk 3146: $currentstring .= $token->[4];
3147: } elsif ($target eq 'tex') {
3148: $currentstring .= '\begin{verbatim}';
3149: }
3150: return $currentstring;
3151: }
3152:
3153: sub end_xmp {
3154: my ($target,$token) = @_;
3155: my $currentstring = '';
1.325 albertel 3156: if ($target eq 'web' || $target eq 'webgrade') {
1.162 sakharuk 3157: $currentstring .= $token->[2];
3158: } elsif ($target eq 'tex') {
3159: $currentstring .= '\end{verbatim}';
3160: }
3161: return $currentstring;
3162: }
3163:
1.181 sakharuk 3164: #-- <pre> (end tag required)
1.122 albertel 3165: sub start_pre {
1.126 sakharuk 3166: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1.279 foxr 3167: my $currentstring = &end_p(); # close off pending <p>
1.325 albertel 3168: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 3169: $currentstring .= $token->[4];
3170: } elsif ($target eq 'tex') {
1.136 sakharuk 3171: $currentstring .= '\begin{verbatim}';
1.319 albertel 3172: &Apache::lonxml::disable_LaTeX_substitutions();
1.122 albertel 3173: }
3174: return $currentstring;
3175: }
3176:
3177: sub end_pre {
3178: my ($target,$token) = @_;
3179: my $currentstring = '';
1.325 albertel 3180: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 3181: $currentstring .= $token->[2];
3182: } elsif ($target eq 'tex') {
1.136 sakharuk 3183: $currentstring .= '\end{verbatim}';
1.319 albertel 3184: &Apache::lonxml::enable_LaTeX_substitutions();
1.122 albertel 3185: }
3186: return $currentstring;
3187: }
3188:
3189: #-- <insert>
3190: sub start_insert {
3191: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
3192: my $currentstring = '';
1.325 albertel 3193: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 3194: my $display = &Apache::lonxml::get_param('display',$parstack,$safeeval,undef,1);
3195: $currentstring .= '<b>'.$display.'</b>';;
3196: }
3197: return $currentstring;
3198: }
3199:
3200: sub end_insert {
3201: my ($target,$token) = @_;
3202: my $currentstring = '';
1.325 albertel 3203: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 3204: $currentstring .= '';
3205: }
3206: return $currentstring;
3207: }
3208:
3209: #-- <externallink>
3210: sub start_externallink {
3211: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
3212: my $currentstring = '';
1.325 albertel 3213: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 3214: my $display = &Apache::lonxml::get_param('display',$parstack,$safeeval,undef,1);
3215: $currentstring .= '<b>'.$display.'</b>';;
3216: }
3217: return $currentstring;
3218: }
3219:
3220: sub end_externallink {
3221: my ($target,$token) = @_;
3222: my $currentstring = '';
1.325 albertel 3223: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 3224: $currentstring .= '';
3225: }
3226: return $currentstring;
3227: }
3228:
3229: #-- <blankspace heigth="">
3230: sub start_blankspace {
3231: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1.279 foxr 3232: my $currentstring = &end_p(); # closes off any unclosed <p>
1.122 albertel 3233: if ($target eq 'tex') {
3234: my $howmuch = &Apache::lonxml::get_param('heigth',$parstack,$safeeval,undef,1);
3235: $currentstring .= '\vskip '.$howmuch.' ';
3236: }
3237: return $currentstring;
3238: }
3239:
3240: sub end_blankspace {
3241: my ($target,$token) = @_;
3242: my $currentstring = '';
3243: if ($target eq 'tex') {
3244: $currentstring .= '';
3245: }
3246: return $currentstring;
3247: }
3248:
1.181 sakharuk 3249: #-- <abbr> tag (end tag required)
1.122 albertel 3250: sub start_abbr {
3251: my ($target,$token) = @_;
3252: my $currentstring = '';
1.325 albertel 3253: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 3254: $currentstring = $token->[4];
3255: }
3256: return $currentstring;
3257: }
3258:
3259: sub end_abbr {
3260: my ($target,$token) = @_;
3261: my $currentstring = '';
1.325 albertel 3262: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 3263: $currentstring = $token->[2];
3264: }
3265: return $currentstring;
3266: }
3267:
1.181 sakharuk 3268: #-- <acronym> tag (end tag required)
1.122 albertel 3269: sub start_acronym {
3270: my ($target,$token) = @_;
3271: my $currentstring = '';
1.325 albertel 3272: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 3273: $currentstring = $token->[4];
3274: }
3275: return $currentstring;
3276: }
3277:
3278: sub end_acronym {
3279: my ($target,$token) = @_;
3280: my $currentstring = '';
1.325 albertel 3281: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 3282: $currentstring = $token->[2];
3283: }
3284: return $currentstring;
3285: }
3286:
1.181 sakharuk 3287: #-- <area> tag (end tag forbidden)
1.122 albertel 3288: sub start_area {
3289: my ($target,$token) = @_;
3290: my $currentstring = '';
1.325 albertel 3291: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 3292: $currentstring = $token->[4];
3293: }
3294: return $currentstring;
3295: }
3296:
3297: sub end_area {
3298: my ($target,$token) = @_;
3299: my $currentstring = '';
1.325 albertel 3300: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 3301: $currentstring = $token->[2];
3302: }
3303: return $currentstring;
3304: }
3305:
1.181 sakharuk 3306: #-- <base> tag (end tag forbidden)
1.122 albertel 3307: sub start_base {
3308: my ($target,$token) = @_;
3309: my $currentstring = '';
1.325 albertel 3310: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 3311: $currentstring = $token->[4];
1.161 sakharuk 3312: }
1.122 albertel 3313: return $currentstring;
3314: }
3315:
3316: sub end_base {
3317: my ($target,$token) = @_;
3318: my $currentstring = '';
1.325 albertel 3319: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 3320: $currentstring = $token->[2];
3321: }
3322: return $currentstring;
3323: }
3324:
1.181 sakharuk 3325: #-- <bdo> tag (end tag required)
1.122 albertel 3326: sub start_bdo {
3327: my ($target,$token) = @_;
3328: my $currentstring = '';
1.325 albertel 3329: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 3330: $currentstring = $token->[4];
3331: }
3332: return $currentstring;
3333: }
3334:
3335: sub end_bdo {
3336: my ($target,$token) = @_;
3337: my $currentstring = '';
1.325 albertel 3338: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 3339: $currentstring = $token->[2];
3340: }
3341: return $currentstring;
3342: }
3343:
1.181 sakharuk 3344: #-- <bgsound> tag (end tag optional)
1.122 albertel 3345: sub start_bgsound {
3346: my ($target,$token) = @_;
3347: my $currentstring = '';
1.325 albertel 3348: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 3349: $currentstring = $token->[4];
3350: }
3351: return $currentstring;
3352: }
3353:
3354: sub end_bgsound {
3355: my ($target,$token) = @_;
3356: my $currentstring = '';
1.325 albertel 3357: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 3358: $currentstring = $token->[2];
3359: }
3360: return $currentstring;
3361: }
3362:
1.181 sakharuk 3363: #-- <blink> tag (end tag required)
1.122 albertel 3364: sub start_blink {
3365: my ($target,$token) = @_;
3366: my $currentstring = '';
1.325 albertel 3367: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 3368: $currentstring = $token->[4];
3369: }
3370: return $currentstring;
3371: }
3372:
3373: sub end_blink {
3374: my ($target,$token) = @_;
3375: my $currentstring = '';
1.325 albertel 3376: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 3377: $currentstring = $token->[2];
3378: }
3379: return $currentstring;
3380: }
3381:
1.181 sakharuk 3382: #-- <blockquote> tag (end tag required)
1.122 albertel 3383: sub start_blockquote {
3384: my ($target,$token) = @_;
1.279 foxr 3385: my $currentstring = &end_p(); # Close any unclosed <p>
1.325 albertel 3386: if ($target eq 'web' || $target eq 'webgrade') {
1.277 foxr 3387: $currentstring .= $token->[4];
1.122 albertel 3388: }
1.339 foxr 3389: if ($target eq 'tex') {
3390: $currentstring .= '\begin{quote}';
3391: }
1.122 albertel 3392: return $currentstring;
3393: }
3394:
3395: sub end_blockquote {
3396: my ($target,$token) = @_;
3397: my $currentstring = '';
1.325 albertel 3398: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 3399: $currentstring = $token->[2];
3400: }
1.339 foxr 3401: if ($target eq 'tex') {
3402: $currentstring = '\end{quote}';
3403: }
1.122 albertel 3404: return $currentstring;
3405: }
3406:
1.181 sakharuk 3407: #-- <button> tag (end tag required)
1.122 albertel 3408: sub start_button {
3409: my ($target,$token) = @_;
3410: my $currentstring = '';
1.325 albertel 3411: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 3412: $currentstring = $token->[4];
3413: }
3414: return $currentstring;
3415: }
3416:
3417: sub end_button {
3418: my ($target,$token) = @_;
3419: my $currentstring = '';
1.325 albertel 3420: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 3421: $currentstring = $token->[2];
3422: }
3423: return $currentstring;
3424: }
3425:
1.181 sakharuk 3426: #-- <caption> tag (end tag required)
1.122 albertel 3427: sub start_caption {
3428: my ($target,$token) = @_;
3429: my $currentstring = '';
1.325 albertel 3430: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 3431: $currentstring = $token->[4];
3432: }
3433: return $currentstring;
3434: }
3435:
3436: sub end_caption {
3437: my ($target,$token) = @_;
3438: my $currentstring = '';
1.325 albertel 3439: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 3440: $currentstring = $token->[2];
3441: }
3442: return $currentstring;
3443: }
3444:
1.181 sakharuk 3445: #-- <col> tag (end tag forbdden)
1.122 albertel 3446: sub start_col {
3447: my ($target,$token) = @_;
3448: my $currentstring = '';
1.325 albertel 3449: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 3450: $currentstring = $token->[4];
3451: }
3452: return $currentstring;
3453: }
3454:
3455: sub end_col {
3456: my ($target,$token) = @_;
3457: my $currentstring = '';
1.325 albertel 3458: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 3459: $currentstring = $token->[2];
3460: }
3461: return $currentstring;
3462: }
3463:
1.430 foxr 3464: #-- <colgroup tag (end tag optional)
1.122 albertel 3465: sub start_colgroup {
1.430 foxr 3466: my ($target,$token,$tagstack, $parstack, $parser, $safeeval, $style) = @_;
1.122 albertel 3467: my $currentstring = '';
1.325 albertel 3468: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 3469: $currentstring = $token->[4];
3470: }
1.430 foxr 3471: if ($target eq 'tex') {
3472: # TODO: Ensure this tag is in a table:
3473:
3474: # Fetch the attributes and build the hash for the
3475: # call to define_colgroup.
3476:
3477: my $span = &Apache::lonxml::get_param('span', $parstack, $safeeval);
3478: my $halign = &Apache::lonxml::get_param('halign', $parstack, $safeeval);
3479:
3480: my %colgroup_params;
3481: if ($span ne '') {
3482: $colgroup_params{'span'} = $span;
3483: }
3484: if ($halign ne '') {
3485: $colgroup_params{'halign'} = $halign;
3486: }
3487:
3488: my $table = $Apache::londefdef::table[-1];
3489: $table->define_colgroup(\%colgroup_params);
3490:
3491: }
1.122 albertel 3492: return $currentstring;
3493: }
3494:
3495: sub end_colgroup {
3496: my ($target,$token) = @_;
3497: my $currentstring = '';
1.325 albertel 3498: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 3499: $currentstring = $token->[2];
3500: }
3501: return $currentstring;
3502: }
3503:
1.416 faziophi 3504:
1.181 sakharuk 3505: #-- <del> tag (end tag required)
1.122 albertel 3506: sub start_del {
3507: my ($target,$token) = @_;
3508: my $currentstring = '';
1.325 albertel 3509: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 3510: $currentstring = $token->[4];
1.416 faziophi 3511: } elsif ($target eq 'tex') {
3512: &disable_para();
3513: $currentstring .= '\st{';
1.122 albertel 3514: }
3515: return $currentstring;
3516: }
3517:
3518: sub end_del {
3519: my ($target,$token) = @_;
3520: my $currentstring = '';
1.325 albertel 3521: if ($target eq 'web' || $target eq 'webgrade') {
1.416 faziophi 3522: $currentstring = $token->[2];
3523: } elsif ($target eq 'tex') {
3524: &enable_para();
3525: $currentstring = '}';
1.122 albertel 3526: }
3527: return $currentstring;
3528: }
3529:
1.181 sakharuk 3530: #-- <fieldset> tag (end tag required)
1.122 albertel 3531: sub start_fieldset {
3532: my ($target,$token) = @_;
3533: my $currentstring = '';
1.325 albertel 3534: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 3535: $currentstring = $token->[4];
3536: }
3537: return $currentstring;
3538: }
3539:
3540: sub end_fieldset {
3541: my ($target,$token) = @_;
3542: my $currentstring = '';
1.325 albertel 3543: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 3544: $currentstring = $token->[2];
3545: }
3546: return $currentstring;
3547: }
3548:
1.181 sakharuk 3549: #-- <frame> tag (end tag forbidden)
1.122 albertel 3550: sub start_frame {
3551: my ($target,$token) = @_;
3552: my $currentstring = '';
1.325 albertel 3553: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 3554: $currentstring = $token->[4];
3555: }
3556: return $currentstring;
3557: }
3558:
3559: sub end_frame {
3560: my ($target,$token) = @_;
3561: my $currentstring = '';
1.325 albertel 3562: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 3563: $currentstring = $token->[2];
3564: }
3565: return $currentstring;
3566: }
3567:
1.181 sakharuk 3568: #-- <iframe> tag (end tag required)
1.122 albertel 3569: sub start_iframe {
3570: my ($target,$token) = @_;
3571: my $currentstring = '';
1.325 albertel 3572: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 3573: $currentstring = $token->[4];
3574: }
3575: return $currentstring;
3576: }
3577:
3578: sub end_iframe {
3579: my ($target,$token) = @_;
3580: my $currentstring = '';
1.325 albertel 3581: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 3582: $currentstring = $token->[2];
3583: }
3584: return $currentstring;
3585: }
3586:
1.181 sakharuk 3587: #-- <ins> tag (end tag required)
1.122 albertel 3588: sub start_ins {
3589: my ($target,$token) = @_;
3590: my $currentstring = '';
1.325 albertel 3591: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 3592: $currentstring = $token->[4];
3593: }
3594: return $currentstring;
3595: }
3596:
3597: sub end_ins {
3598: my ($target,$token) = @_;
3599: my $currentstring = '';
1.325 albertel 3600: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 3601: $currentstring = $token->[2];
3602: }
3603: return $currentstring;
3604: }
3605:
1.181 sakharuk 3606: #-- <isindex> tag (end tag forbidden)
1.122 albertel 3607: sub start_isindex {
3608: my ($target,$token) = @_;
3609: my $currentstring = '';
1.325 albertel 3610: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 3611: $currentstring = $token->[4];
3612: }
3613: return $currentstring;
3614: }
3615:
3616: sub end_isindex {
3617: my ($target,$token) = @_;
3618: my $currentstring = '';
1.325 albertel 3619: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 3620: $currentstring = $token->[2];
3621: }
3622: return $currentstring;
3623: }
3624:
1.181 sakharuk 3625: #-- <keygen> tag (end tag forbidden)
1.122 albertel 3626: sub start_keygen {
3627: my ($target,$token) = @_;
3628: my $currentstring = '';
1.325 albertel 3629: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 3630: $currentstring = $token->[4];
3631: }
3632: return $currentstring;
3633: }
3634:
3635: sub end_keygen {
3636: my ($target,$token) = @_;
3637: my $currentstring = '';
1.325 albertel 3638: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 3639: $currentstring = $token->[2];
3640: }
3641: return $currentstring;
3642: }
3643:
3644: #-- <label> tag
3645: sub start_label {
3646: my ($target,$token) = @_;
3647: my $currentstring = '';
1.325 albertel 3648: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 3649: $currentstring = $token->[4];
3650: }
3651: return $currentstring;
3652: }
3653:
3654: sub end_label {
3655: my ($target,$token) = @_;
3656: my $currentstring = '';
1.325 albertel 3657: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 3658: $currentstring = $token->[2];
3659: }
3660: return $currentstring;
3661: }
3662:
1.181 sakharuk 3663: #-- <layer> tag (end tag required)
1.122 albertel 3664: sub start_layer {
3665: my ($target,$token) = @_;
3666: my $currentstring = '';
1.325 albertel 3667: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 3668: $currentstring = $token->[4];
3669: }
3670: return $currentstring;
3671: }
3672:
3673: sub end_layer {
3674: my ($target,$token) = @_;
3675: my $currentstring = '';
1.325 albertel 3676: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 3677: $currentstring = $token->[2];
3678: }
3679: return $currentstring;
3680: }
3681:
1.181 sakharuk 3682: #-- <legend> tag (end tag required)
1.122 albertel 3683: sub start_legend {
3684: my ($target,$token) = @_;
3685: my $currentstring = '';
1.325 albertel 3686: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 3687: $currentstring = $token->[4];
3688: }
3689: return $currentstring;
3690: }
3691:
3692: sub end_legend {
3693: my ($target,$token) = @_;
3694: my $currentstring = '';
1.325 albertel 3695: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 3696: $currentstring = $token->[2];
3697: }
3698: return $currentstring;
3699: }
3700:
1.181 sakharuk 3701: #-- <link> tag (end tag forbidden)
1.122 albertel 3702: sub start_link {
1.292 albertel 3703: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1.122 albertel 3704: my $currentstring = '';
1.324 albertel 3705: if ($target eq 'web' || $target eq 'webgrade') {
1.291 albertel 3706: my $href=&Apache::lonxml::get_param('href',$parstack,$safeeval,
3707: undef,1);
3708: &Apache::lonxml::extlink($href);
1.122 albertel 3709: $currentstring = $token->[4];
3710: }
3711: return $currentstring;
3712: }
3713:
3714: sub end_link {
3715: my ($target,$token) = @_;
3716: my $currentstring = '';
1.325 albertel 3717: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 3718: $currentstring = $token->[2];
3719: }
3720: return $currentstring;
3721: }
3722:
1.181 sakharuk 3723: #-- <marquee> tag (end tag optional)
1.122 albertel 3724: sub start_marquee {
3725: my ($target,$token) = @_;
3726: my $currentstring = '';
1.325 albertel 3727: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 3728: $currentstring = $token->[4];
3729: }
3730: return $currentstring;
3731: }
3732:
3733: sub end_marquee {
3734: my ($target,$token) = @_;
3735: my $currentstring = '';
1.325 albertel 3736: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 3737: $currentstring = $token->[2];
3738: }
3739: return $currentstring;
3740: }
3741:
1.179 sakharuk 3742: #-- <multicol> tag (end tag required)
3743: sub start_multicol {
1.122 albertel 3744: my ($target,$token) = @_;
1.279 foxr 3745: my $currentstring = &end_p(); # Close any pending <p>
1.325 albertel 3746: if ($target eq 'web' || $target eq 'webgrade') {
1.277 foxr 3747: $currentstring .= $token->[4];
1.122 albertel 3748: }
3749: return $currentstring;
3750: }
3751:
1.179 sakharuk 3752: sub end_multicol {
1.122 albertel 3753: my ($target,$token) = @_;
3754: my $currentstring = '';
1.325 albertel 3755: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 3756: $currentstring = $token->[2];
3757: }
3758: return $currentstring;
3759: }
3760:
1.179 sakharuk 3761: #-- <nobr> tag (end tag required)
1.122 albertel 3762: sub start_nobr {
3763: my ($target,$token) = @_;
3764: my $currentstring = '';
1.325 albertel 3765: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 3766: $currentstring = $token->[4];
1.179 sakharuk 3767: } elsif ($target eq 'tex') {
3768: $currentstring='\mbox{';
3769: }
1.122 albertel 3770: return $currentstring;
3771: }
3772:
3773: sub end_nobr {
3774: my ($target,$token) = @_;
3775: my $currentstring = '';
1.325 albertel 3776: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 3777: $currentstring = $token->[2];
1.179 sakharuk 3778: } elsif ($target eq 'tex') {
3779: $currentstring='}';
3780: }
1.122 albertel 3781: return $currentstring;
3782: }
3783:
1.179 sakharuk 3784: #-- <noembed> tag (end tag required)
1.122 albertel 3785: sub start_noembed {
3786: my ($target,$token) = @_;
3787: my $currentstring = '';
1.325 albertel 3788: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 3789: $currentstring = $token->[4];
3790: }
3791: return $currentstring;
3792: }
3793:
3794: sub end_noembed {
3795: my ($target,$token) = @_;
3796: my $currentstring = '';
1.325 albertel 3797: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 3798: $currentstring = $token->[2];
3799: }
3800: return $currentstring;
3801: }
3802:
1.179 sakharuk 3803: #-- <noframes> tag (end tag required)
1.122 albertel 3804: sub start_noframes {
3805: my ($target,$token) = @_;
3806: my $currentstring = '';
1.325 albertel 3807: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 3808: $currentstring = $token->[4];
3809: }
3810: return $currentstring;
3811: }
3812:
3813: sub end_noframes {
3814: my ($target,$token) = @_;
3815: my $currentstring = '';
1.325 albertel 3816: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 3817: $currentstring = $token->[2];
3818: }
3819: return $currentstring;
3820: }
3821:
1.179 sakharuk 3822: #-- <nolayer> tag (end tag required)
1.122 albertel 3823: sub start_nolayer {
3824: my ($target,$token) = @_;
3825: my $currentstring = '';
1.325 albertel 3826: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 3827: $currentstring = $token->[4];
3828: }
3829: return $currentstring;
3830: }
3831:
3832: sub end_nolayer {
3833: my ($target,$token) = @_;
3834: my $currentstring = '';
1.325 albertel 3835: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 3836: $currentstring = $token->[2];
3837: }
3838: return $currentstring;
3839: }
3840:
1.179 sakharuk 3841: #-- <noscript> tag (end tag required)
1.122 albertel 3842: sub start_noscript {
3843: my ($target,$token) = @_;
3844: my $currentstring = '';
1.325 albertel 3845: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 3846: $currentstring = $token->[4];
3847: }
3848: return $currentstring;
3849: }
3850:
3851: sub end_noscript {
3852: my ($target,$token) = @_;
3853: my $currentstring = '';
1.325 albertel 3854: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 3855: $currentstring = $token->[2];
3856: }
3857: return $currentstring;
3858: }
3859:
1.179 sakharuk 3860: #-- <object> tag (end tag required)
1.122 albertel 3861: sub start_object {
3862: my ($target,$token) = @_;
3863: my $currentstring = '';
1.325 albertel 3864: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 3865: $currentstring = $token->[4];
3866: }
3867: return $currentstring;
3868: }
3869:
3870: sub end_object {
3871: my ($target,$token) = @_;
3872: my $currentstring = '';
1.325 albertel 3873: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 3874: $currentstring = $token->[2];
3875: }
3876: return $currentstring;
3877: }
3878:
1.179 sakharuk 3879: #-- <optgroup> tag (end tag required)
1.122 albertel 3880: sub start_optgroup {
3881: my ($target,$token) = @_;
3882: my $currentstring = '';
1.325 albertel 3883: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 3884: $currentstring = $token->[4];
3885: }
3886: return $currentstring;
3887: }
3888:
3889: sub end_optgroup {
3890: my ($target,$token) = @_;
3891: my $currentstring = '';
1.325 albertel 3892: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 3893: $currentstring = $token->[2];
3894: }
3895: return $currentstring;
3896: }
3897:
1.179 sakharuk 3898: #-- <samp> tag (end tag required)
1.122 albertel 3899: sub start_samp {
3900: my ($target,$token) = @_;
3901: my $currentstring = '';
1.325 albertel 3902: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 3903: $currentstring = $token->[4];
1.179 sakharuk 3904: } elsif ($target eq 'tex') {
3905: $currentstring='\texttt{';
3906: }
1.122 albertel 3907: return $currentstring;
3908: }
3909:
3910: sub end_samp {
3911: my ($target,$token) = @_;
3912: my $currentstring = '';
1.325 albertel 3913: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 3914: $currentstring = $token->[2];
1.179 sakharuk 3915: } elsif ($target eq 'tex') {
3916: $currentstring='}';
3917: }
1.122 albertel 3918: return $currentstring;
3919: }
3920:
3921: #-- <server> tag
3922: sub start_server {
3923: my ($target,$token) = @_;
3924: my $currentstring = '';
1.325 albertel 3925: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 3926: $currentstring = $token->[4];
3927: }
3928: return $currentstring;
3929: }
3930:
3931: sub end_server {
3932: my ($target,$token) = @_;
3933: my $currentstring = '';
1.325 albertel 3934: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 3935: $currentstring = $token->[2];
3936: }
3937: return $currentstring;
3938: }
3939:
1.179 sakharuk 3940: #-- <spacer> tag (end tag forbidden)
1.122 albertel 3941: sub start_spacer {
3942: my ($target,$token) = @_;
1.279 foxr 3943: my $currentstring = &end_p(); # Close off any open <p> tag.
1.325 albertel 3944: if ($target eq 'web' || $target eq 'webgrade') {
1.277 foxr 3945: $currentstring .= $token->[4];
1.122 albertel 3946: }
3947: return $currentstring;
3948: }
3949:
3950: sub end_spacer {
3951: my ($target,$token) = @_;
3952: my $currentstring = '';
1.325 albertel 3953: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 3954: $currentstring = $token->[2];
3955: }
3956: return $currentstring;
3957: }
3958:
1.179 sakharuk 3959: #-- <span> tag (end tag required)
1.122 albertel 3960: sub start_span {
3961: my ($target,$token) = @_;
3962: my $currentstring = '';
1.325 albertel 3963: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 3964: $currentstring = $token->[4];
3965: }
3966: return $currentstring;
3967: }
3968:
3969: sub end_span {
3970: my ($target,$token) = @_;
3971: my $currentstring = '';
1.325 albertel 3972: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 3973: $currentstring = $token->[2];
3974: }
3975: return $currentstring;
3976: }
3977:
1.179 sakharuk 3978: #-- <tbody> tag (end tag optional)
1.122 albertel 3979: sub start_tbody {
3980: my ($target,$token) = @_;
3981: my $currentstring = '';
1.325 albertel 3982: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 3983: $currentstring = $token->[4];
3984: }
1.430 foxr 3985: if ($target eq 'tex') {
3986: # TODO: Ensure this tag is within a table:
3987:
3988: my $table = $Apache::londefdef::table[-1];
3989: $table->start_body();
3990: }
1.122 albertel 3991: return $currentstring;
3992: }
3993:
3994: sub end_tbody {
3995: my ($target,$token) = @_;
3996: my $currentstring = '';
1.325 albertel 3997: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 3998: $currentstring = $token->[2];
3999: }
1.430 foxr 4000: if($target eq 'tex') {
4001: # TODO: Ensure this tag is within a table:
4002:
4003: my $table = $Apache::londefdef::table[-1];
4004: $table->end_body();
4005: }
1.122 albertel 4006: return $currentstring;
4007: }
4008:
1.166 sakharuk 4009: #-- <tfoot> tag (end tag optional)
1.122 albertel 4010: sub start_tfoot {
4011: my ($target,$token) = @_;
4012: my $currentstring = '';
1.325 albertel 4013: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 4014: $currentstring = $token->[4];
4015: }
1.430 foxr 4016: if ($target eq 'tex') {
4017: # TODO: ensure this is within a table tag.
4018: my $table = $Apache::londefdef::table[-1];
4019: $table->start_foot();
4020: }
1.122 albertel 4021: return $currentstring;
4022: }
4023:
4024: sub end_tfoot {
4025: my ($target,$token) = @_;
4026: my $currentstring = '';
1.325 albertel 4027: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 4028: $currentstring = $token->[2];
4029: }
1.430 foxr 4030: if ($target eq 'tex') {
4031: # TODO: Ensure this is in side a table
4032: my $table = $Apache::londefdef::table[-1];
4033: $table->end_foot();
4034: }
1.122 albertel 4035: return $currentstring;
4036: }
4037:
1.166 sakharuk 4038: #-- <thead> tag (end tag optional)
1.122 albertel 4039: sub start_thead {
4040: my ($target,$token) = @_;
4041: my $currentstring = '';
1.325 albertel 4042: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 4043: $currentstring = $token->[4];
4044: }
1.430 foxr 4045: if ($target eq 'tex') {
4046: # Assume we're in a table... TODO: Verify that and ignore tag if not.
4047: my $table = $Apache::londefdef::table[-1];
4048: $table->start_head();
4049: }
1.122 albertel 4050: return $currentstring;
4051: }
1.10 www 4052:
1.122 albertel 4053: sub end_thead {
4054: my ($target,$token) = @_;
4055: my $currentstring = '';
1.325 albertel 4056: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 4057: $currentstring = $token->[2];
4058: }
1.430 foxr 4059: if ($target eq 'tex') {
4060: # TODO: Verify we are in a table and ignore tag if not.
4061:
4062: my $table = $Apache::londefdef::table[-1];
4063: $table->end_head();
4064: }
1.122 albertel 4065: return $currentstring;
4066: }
1.119 www 4067:
1.122 albertel 4068: #-- <var> tag
4069: sub start_var {
1.44 sakharuk 4070: my ($target,$token) = @_;
4071: my $currentstring = '';
1.325 albertel 4072: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 4073: $currentstring = $token->[4];
1.163 sakharuk 4074: } elsif ($target eq 'tex') {
4075: $currentstring = '\textit{';
4076: }
1.44 sakharuk 4077: return $currentstring;
4078: }
1.10 www 4079:
1.122 albertel 4080: sub end_var {
4081: my ($target,$token) = @_;
1.44 sakharuk 4082: my $currentstring = '';
1.325 albertel 4083: if ($target eq 'web' || $target eq 'webgrade') {
1.163 sakharuk 4084: $currentstring = $token->[2];
4085: } elsif ($target eq 'tex') {
4086: $currentstring = '}';
1.44 sakharuk 4087: }
4088: return $currentstring;
4089: }
1.119 www 4090:
1.163 sakharuk 4091: #-- <wbr> tag (end tag forbidden)
1.122 albertel 4092: sub start_wbr {
4093: my ($target,$token) = @_;
4094: my $currentstring = '';
1.325 albertel 4095: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 4096: $currentstring = $token->[4];
4097: }
4098: return $currentstring;
1.98 albertel 4099: }
4100:
1.122 albertel 4101: sub end_wbr {
4102: my ($target,$token) = @_;
4103: my $currentstring = '';
1.325 albertel 4104: if ($target eq 'web' || $target eq 'webgrade') {
1.122 albertel 4105: $currentstring = $token->[2];
4106: }
4107: return $currentstring;
1.98 albertel 4108: }
1.134 sakharuk 4109:
4110: #-- <hideweboutput> tag
4111: sub start_hideweboutput {
4112: my ($target,$token) = @_;
1.325 albertel 4113: if ($target eq 'web' || $target eq 'webgrade') {
1.134 sakharuk 4114: &Apache::lonxml::startredirection();
4115: }
4116: return '';
4117: }
4118:
4119: sub end_hideweboutput {
4120: my ($target,$token) = @_;
4121: my $currentstring = '';
1.325 albertel 4122: if ($target eq 'web' || $target eq 'webgrade') {
1.134 sakharuk 4123: $currentstring = &Apache::lonxml::endredirection();
4124: }
4125: return '';
4126: }
4127:
1.94 sakharuk 4128:
4129: sub image_replication {
4130: my $src = shift;
1.187 albertel 4131: if (not -e $src) { &Apache::lonnet::repcopy($src); }
4132: #replicates eps or ps
4133: my $epssrc = my $pssrc = $src;
4134: $epssrc =~ s/\.(gif|jpg|jpeg|png)$/.eps/i;
4135: $pssrc =~ s/\.(gif|jpg|jpeg|png)$/.ps/i;
4136: if (not -e $epssrc && not -e $pssrc) {
4137: my $result=&Apache::lonnet::repcopy($epssrc);
1.264 raeburn 4138: if ($result ne 'ok') { &Apache::lonnet::repcopy($pssrc); }
1.94 sakharuk 4139: }
4140: return '';
1.195 sakharuk 4141: }
1.397 jms 4142:
4143:
4144:
1.275 foxr 4145: sub resize_image {
4146: my ($height_param, $width_param, $scaling,
4147: $parstack, $safeeval, $depth, $cis) = @_;
4148:
4149: # First apply the scaling...
1.271 foxr 4150:
1.275 foxr 4151: $height_param = $height_param * $scaling;
4152: $width_param = $width_param * $scaling;
1.261 foxr 4153:
1.197 sakharuk 4154: #do we have any specified LaTeX size of the picture?
1.261 foxr 4155: my $toget='TeXwidth';
4156: if ($cis) {
4157: $toget=lc($toget);
4158: }
1.256 albertel 4159: my $TeXwidth = &Apache::lonxml::get_param($toget,$parstack,
4160: $safeeval,$depth,$cis);
4161: $toget='TeXheight'; if ($cis) { $toget=lc($toget); }
4162: my $TeXheight = &Apache::lonxml::get_param($toget,$parstack,
4163: $safeeval,$depth,$cis);
1.197 sakharuk 4164: #do we have any specified web size of the picture?
4165: my $width = &Apache::lonxml::get_param('width',$parstack,$safeeval,
1.256 albertel 4166: $depth,1);
4167: if ($TeXwidth) {
1.252 matthew 4168: my $old_width_param=$width_param;
1.197 sakharuk 4169: if ($TeXwidth=~/(\d+)\s*\%/) {
1.267 albertel 4170: $width_param = $1*$env{'form.textwidth'}/100;
1.197 sakharuk 4171: } else {
4172: $width_param = $TeXwidth;
4173: }
1.266 albertel 4174: if ($TeXheight) {
4175: $height_param = $TeXheight;
4176: } elsif ($old_width_param) {
4177: $height_param=$TeXwidth/$old_width_param*$height_param;
4178: }
1.256 albertel 4179: } elsif ($TeXheight) {
1.248 foxr 4180: $height_param = $TeXheight;
1.266 albertel 4181: if ($height_param) {
4182: $width_param = $TeXheight/$height_param*$width_param;
4183: }
1.256 albertel 4184: } elsif ($width) {
1.252 matthew 4185: my $old_width_param=$width_param;
1.256 albertel 4186: $width_param = $width*$scaling;
1.266 albertel 4187: if ($old_width_param) {
4188: $height_param=$width_param/$old_width_param*$height_param;
4189: }
1.252 matthew 4190: }
1.267 albertel 4191: if ($width_param > $env{'form.textwidth'}) {
1.252 matthew 4192: my $old_width_param=$width_param;
1.267 albertel 4193: $width_param =0.95*$env{'form.textwidth'};
1.266 albertel 4194: if ($old_width_param) {
4195: $height_param=$width_param/$old_width_param*$height_param;
4196: }
1.197 sakharuk 4197: }
1.275 foxr 4198:
4199: return ($height_param, $width_param);
4200: }
4201:
4202: sub image_size {
4203: my ($src,$scaling,$parstack,$safeeval,$depth,$cis)=@_;
4204:
4205: #size of image from gif/jpg/jpeg/png
4206: my $ressrc=&Apache::lonnet::filelocation($Apache::lonxml::pwd[-1],$src);
4207: if (-e $ressrc) {
4208: $src = $ressrc;
4209: }
4210: my $image = Image::Magick->new;
4211: my $current_figure = $image->Read($src);
4212: my $width_param = $image->Get('width');
4213: my $height_param = $image->Get('height');
4214: &Apache::lonxml::debug("Image magick says: $src : Height = $height_param width = $width_param");
4215: undef($image);
4216:
4217: ($height_param, $width_param) = &resize_image($height_param, $width_param,
4218: $scaling, $parstack, $safeeval,
4219: $depth, $cis);
4220:
1.248 foxr 4221: return ($height_param, $width_param);
4222: }
4223:
4224: sub image_width {
4225: my ($height, $width) = &image_size(@_);
4226: return $width;
4227: }
4228: # Not yet 100% sure this is correct in all circumstances..
4229: # due to my uncertainty about mods to image_size.
4230: #
4231: sub image_height {
4232: my ($height, $width) = &image_size(@_);
4233: return $height;
1.197 sakharuk 4234: }
4235:
1.256 albertel 4236: sub get_eps_image {
4237: my ($src)=@_;
1.261 foxr 4238: my $orig_src=&Apache::lonnet::filelocation($Apache::lonxml::pwd[-1], $src);
1.285 foxr 4239:
4240: # In order to prevent the substitution of the alt text, we need to
4241: # be sure the orig_src file is on system now so:
4242:
4243: if (! -e $orig_src) {
4244: &Apache::lonnet::repcopy($orig_src); # Failure is not completely fatal.
4245: }
1.275 foxr 4246: &Apache::lonxml::debug("get_eps_image: Original image: $orig_src");
1.390 foxr 4247: my ($spath, $sname, $sext) = &fileparse($src, qr/\.(bmp|gif|png|jpg|jpeg)/i);
4248: $src=~s/\.(bmp|gif|png|jpg|jpeg)$/\.eps/i;
1.256 albertel 4249: $src=&Apache::lonnet::filelocation($Apache::lonxml::pwd[-1],$src);
1.275 foxr 4250: &Apache::lonxml::debug("Filelocation gives: $src");
1.256 albertel 4251: if (! -e $src) {
1.261 foxr 4252: &Apache::lonxml::debug("$src does not exist");
1.264 raeburn 4253: if (&Apache::lonnet::repcopy($src) ne 'ok' ) {
1.261 foxr 4254: &Apache::lonxml::debug("Repcopy of $src failed (1)");
1.256 albertel 4255: #if replication failed try to find ps file
4256: $src=~s/\.eps$/\.ps/;
1.261 foxr 4257: &Apache::lonxml::debug("Now looking for $src");
1.270 foxr 4258: #if no ps file try to replicate it.
4259: my $didrepcopy = &Apache::lonnet::repcopy($src);
4260: &Apache::lonxml::debug("repcopy of $src ... $didrepcopy");
4261: if ( (not -e $src) ||
4262: ($didrepcopy ne 'ok')) {
1.261 foxr 4263: &Apache::lonxml::debug("Failed to find or replicate $src");
4264:
1.256 albertel 4265: #if replication failed try to produce eps file dynamically
4266: $src=~s/\.ps$/\.eps/;
1.424 raeburn 4267: if (open(FILE,">>/home/httpd/prtspool/$env{'user.name'}_$env{'user.domain'}_printout.dat")) {
4268: my $newsrc=$orig_src;
4269: $newsrc =~ s|(.*)/res/|/home/httpd/html/res/|;
4270: &Apache::lonxml::debug("queueing $newsrc for dynamic eps production.");
4271: print FILE ("$newsrc\n");
4272: close(FILE);
4273: }
1.256 albertel 4274: $src=~s|/home/httpd/html/res|/home/httpd/prtspool|;
1.435 www 4275: $src=~s|/home/httpd/html/priv/[^/]+/([^/]*)/|/home/httpd/prtspool/$1/|;
1.283 albertel 4276: if ($sext ne "") { # Put the ext. back in to uniquify.
4277: $src =~ s/\.eps$/$sext.eps/;
4278: }
1.341 foxr 4279:
1.256 albertel 4280: }
1.343 foxr 4281:
1.256 albertel 4282: }
1.341 foxr 4283: } else {
4284: # If the postscript file has spaces in its name,
4285: # LaTeX will gratuitiously vomit. Therefore
4286: # queue such files for copy with " " replaced by "_".
4287: # printout.pm will know them by their .ps or .eps extensions.
4288: my $newsrc = $orig_src;
4289: $newsrc =~ s|(.*)/res/|/home/httpd/html/res/|;
4290: open(FILE,">>/home/httpd/prtspool/$env{'user.name'}_$env{'user.domain'}_printout.dat");
1.343 foxr 4291: print FILE "$src\n";
1.341 foxr 4292: close FILE;
4293: $src=~s|/home/httpd/html/res|/home/httpd/prtspool|;
1.435 www 4294: $src=~s|/home/httpd/html/priv/[^/]+/([^/]*)/|/home/httpd/prtspool/$1/|;
1.256 albertel 4295: }
4296: my ($path,$file)=($src=~m|(.*)/([^/]*)$|);
1.344 albertel 4297: $path =~ s/ /\_/g;
1.343 foxr 4298: $file =~ s/ /\_/g;
1.261 foxr 4299: &Apache::lonxml::debug("get_eps_image returning: $path / $file<BR />");
1.256 albertel 4300: return ($path.'/',$file);
4301: }
4302:
1.195 sakharuk 4303: sub eps_generation {
4304: my ($src,$file,$width_param) = @_;
1.267 albertel 4305: my $filename = "/home/httpd/prtspool/$env{'user.name'}_$env{'user.domain'}_printout.dat";
1.424 raeburn 4306: if (open(my $tmpfile,">>$filename")) {
4307: print $tmpfile "$src\n";
4308: close($tmpfile);
4309: }
1.195 sakharuk 4310: my $newsrc = $src;
1.390 foxr 4311: $newsrc =~ s/(\.bmp|\.gif|\.jpg|\.jpeg)$/\.eps/i;
1.345 albertel 4312: $newsrc=~s{/home/httpd/html/res}{};
1.435 www 4313: $newsrc=~s{/home/httpd/html/priv/[^/]+/($LONCAPA::username_re)/}{/$1/};
1.345 albertel 4314: $newsrc=~s{/\./}{/};
4315: $newsrc=~s{/([^/]+)\.(ps|eps)}{/};
4316: if ($newsrc=~m{/home/httpd/lonUsers/}) {
4317: $newsrc=~s{/home/httpd/lonUsers}{};
4318: $newsrc=~s{/($LONCAPA::domain_re)/./././}{/$1/};
1.213 sakharuk 4319: }
1.345 albertel 4320: if ($newsrc=~m{/userfiles/}) {
1.239 sakharuk 4321: return ' \graphicspath{{'.$newsrc.'}}\includegraphics[width='.$width_param.' mm]{'.$file.'} ';
4322: } else {
4323: return ' \graphicspath{{/home/httpd/prtspool'.$newsrc.'}}\includegraphics[width='.$width_param.' mm]{'.$file.'} ';
4324: }
1.197 sakharuk 4325: }
4326:
4327: sub file_path {
4328: my $src=shift;
4329: my ($file,$path);
4330: if ($src =~ m!(.*)/([^/]*)$!) {
4331: $file = $2;
4332: $path = $1.'/';
4333: }
4334: return $file,$path;
1.126 sakharuk 4335: }
1.397 jms 4336:
4337:
1.126 sakharuk 4338: sub recalc {
4339: my $argument = shift;
4340: if (not $argument=~/(mm|cm|in|pc|pt)/) {return $argument.' mm';}
1.132 sakharuk 4341: $argument=~/\s*(\d+\.?\d*)\s*(mm|cm|in|pc|pt)/;
1.126 sakharuk 4342: my $value=$1;
4343: my $units=$2;
4344: if ($units eq 'cm') {
4345: $value*=10;
4346: } elsif ($units eq 'in') {
4347: $value*=25.4;
4348: } elsif ($units eq 'pc') {
4349: $value*=(25.4*12/72.27);
4350: } elsif ($units eq 'pt') {
4351: $value*=(25.4/72.27);
4352: }
4353: return $value.' mm';
1.94 sakharuk 4354: }
1.184 sakharuk 4355:
4356: sub LATEX_length {
4357: my $garbage=shift;
1.206 sakharuk 4358: $garbage=~s/^\s+$//;
4359: $garbage=~s/^\s+(\S.*)/$1/;#space before
4360: $garbage=~s/(.*\S)\s+$/$1/;#space after
4361: $garbage=~s/(\s)+/$1/;#only one space
4362: $garbage=~s/(\\begin{([^\}]+)}|\\end{([^\}]+)})//g;#remove LaTeX \begin{...} and \end{...}
4363: $garbage=~s/(\$\_\{|\$\_|\$\^{|\$\^|\}\$)//g;#remove $_{,$_,$^{,$^,}$
4364: $garbage=~s/([^\\])\$/$1/g;#$
4365: $garbage=~s/(\\ensuremath\{\_\{|\\ensuremath\{\_|\\ensuremath\{\^{|\\ensuremath\{\^|\})//g;#remove \ensuremath{...}
4366: $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;
1.184 sakharuk 4367: $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;
4368: $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;
4369: $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;
1.206 sakharuk 4370: $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)/11/g;
4371: $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)/11/g;
4372: $garbage=~s/(\\hat{([^}]+)}|\\check{([^}]+)}|\\dot{([^}]+)}|\\breve{([^}]+)}|\\acute{([^}]+)}|\\ddot{([^}]+)}|\\grave{([^}]+)}|\\tilde{([^}]+)}|\\mathring{([^}]+)}|\\bar{([^}]+)}|\\vec{([^}]+)})/$1/g;
4373: #remove some other LaTeX command
4374: $garbage=~s|\\(\w+)\\|\\|g;
4375: $garbage=~s|\\(\w+)(\s*)|$2|g;
4376: $garbage=~s|\+|11|g;
1.184 sakharuk 4377: my $value=length($garbage);
4378: return $value;
4379: }
4380:
1.397 jms 4381:
1.353 foxr 4382: sub align_latex_image {
4383: my ($align, $latex_rendering, $image, $width, $height) = @_;
1.354 foxr 4384: my $currentstring; # The 1/2 wrapped image.
4385: my $closure; # The closure of the wrappage.
1.379 albertel 4386:
4387: # if it's none just return it back
4388: if ($latex_rendering eq 'none') {
4389: return ($image,'');
4390: }
4391:
1.353 foxr 4392: # If there's an alignment specification we need to honor it here.
4393: # For the horizontal alignments, we will also honor the
4394: # value of the latex specfication. The default is parbox,
4395: # and that's used for illegal values too.
4396: #
4397: # Even though we set a default alignment value, the user
4398: # could have given us an illegal value. In that case we
4399: # just use the default alignment of bottom..
1.415 foxr 4400: $currentstring = '';
1.353 foxr 4401: if ($align eq "top") {
1.354 foxr 4402: $currentstring .= '\raisebox{-'.$height.'mm}{'.$image;
4403: $closure = '}';
1.353 foxr 4404: } elsif (($align eq "center") || ($align eq "middle")) { # Being kind
4405: my $offset = $height/2;
1.354 foxr 4406: $currentstring .= '\raisebox{-'.$offset.'mm}{'.$image;
4407: $closure = '}';
1.353 foxr 4408: } elsif ($align eq "left") {
4409: if ($latex_rendering eq "parpic") {
1.354 foxr 4410: $currentstring .= '\parpic[l]{'.$image;
4411: $closure = '}';
1.353 foxr 4412: } elsif ($latex_rendering eq "parbox") {
1.354 foxr 4413: $currentstring .= '\begin{minipage}[l]{'.$width.'mm}'
4414: .$image;
4415: $closure = '\end{minipage}';
1.353 foxr 4416: } elsif ($latex_rendering eq "wrapfigure"
4417: || $latex_rendering ne 'none') { # wrapfig render
1.354 foxr 4418: $currentstring .=
1.353 foxr 4419: '\begin{wrapfigure}{l}{'.$width.'mm}'
1.354 foxr 4420: .'\scalebox{1.0}{'.$image;
4421: $closure = '}\end{wrapfigure}';
1.353 foxr 4422: }
4423: } elsif ($align eq "right") {
4424: if ($latex_rendering eq "parpic") {
1.354 foxr 4425: $currentstring .= '\parpic[r]{'.$image;
4426: $closure = '}';
1.353 foxr 4427: } elsif ($latex_rendering eq "parbox") {
1.354 foxr 4428: $currentstring .= '\begin{minipage}[r]{'.$width.'mm}'
4429: .$image;
4430: $closure = '\end{minipage}';
1.353 foxr 4431: } elsif ($latex_rendering eq "wrapfigure"
4432: || $latex_rendering ne 'none') { # wrapfig render
1.354 foxr 4433: $currentstring .=
1.353 foxr 4434: '\begin{wrapfigure}{r}{'.$width.'mm}'
1.354 foxr 4435: .'\scalebox{1.0}{'.$image;
4436: $closure = '}\end{wrapfigure}';
1.353 foxr 4437: }
4438: } else { # Bottom is also default.
4439: # $currentstring = '\raisebox{'.$height.'mm}{'.$image.'}';
1.354 foxr 4440: $currentstring .= "{$image";
4441: $closure = '}';
1.353 foxr 4442: }
1.354 foxr 4443: return ($currentstring, $closure);
1.353 foxr 4444: }
1.184 sakharuk 4445:
1.397 jms 4446:
1.287 foxr 4447: sub is_inside_of {
4448: my ($tagstack, $tag) = @_;
4449: my @stack = @$tagstack;
4450: for (my $i = ($#stack - 1); $i >= 0; $i--) {
4451: if ($stack[$i] eq $tag) {
4452: return 1;
4453: }
4454: }
4455: return 0;
4456: }
1.184 sakharuk 4457:
1.94 sakharuk 4458:
1.399 foxr 4459: #
4460: # This sub provides the typical LaTeX prefix matter for tex output:
4461: #
1.414 raeburn 4462: sub latex_header {
1.402 foxr 4463: my ($mode) = @_;
1.399 foxr 4464: my $currentstring = '';
4465:
4466: $currentstring .=
1.402 foxr 4467: "\n% &Apache::lonxml::londefdef \n" .
1.399 foxr 4468: '\documentclass[letterpaper,twoside]{article}\raggedbottom';
4469: if (($env{'form.latex_type'}=~'batchmode') ||
1.402 foxr 4470: (!$env{'request.role.adv'}) ||
4471: ($mode eq 'batchmode')) {$currentstring .='\batchmode';}
1.399 foxr 4472: $currentstring .= '\newcommand{\keephidden}[1]{}'.
4473: '\renewcommand{\deg}{$^{\circ}$}'.
4474: '\usepackage{multirow}'.
4475: '\usepackage{longtable}'.
4476: '\usepackage{textcomp}'.
4477: '\usepackage{makeidx}'.
4478: '\usepackage[dvips]{graphicx}'.
4479: '\usepackage{wrapfig}'.
4480: '\usepackage{picins}'.
4481: '\usepackage[T1]{fontenc}'."\n".
4482: '\usepackage{lmodern}'."\n".
4483: '\usepackage[postscript]{ucs}'."\n".
4484: '\usepackage[utf8x]{inputenc}'."\n".
4485: '\usepackage{pifont}' ."\n".
4486: '\usepackage{latexsym}'."\n".
4487: '\usepackage{epsfig}'.
4488: "\\usepackage{xtab}\n".
4489: "\\usepackage{tabularx}\n".
4490: "\\usepackage{booktabs}\n".
4491: "\\usepackage{array}\n".
4492: "\\usepackage{colortbl}\n".
4493: "\\usepackage{xcolor}\n".
4494: '\usepackage{calc}'.
4495: '\usepackage{amsmath}'.
1.442 raeburn 4496: '\usepackage{soul}'.
1.399 foxr 4497: '\usepackage{amssymb}'.
4498: '\usepackage{amsfonts}'.
4499: '\usepackage{amsthm}'.
1.402 foxr 4500: '\usepackage{amscd}'
4501: .'\usepackage{picins}\usepackage{calc}'."\n". # From lonprintout.pm
4502: '\usepackage[T1]{fontenc}'."\n".
4503: '\usepackage{lmodern}'."\n".
4504: '\usepackage[postscript]{ucs}'."\n".
4505: '\usepackage[utf8x]{inputenc}'."\n".
4506: '\usepackage{pifont}' . "\n";
4507:
1.399 foxr 4508: if($env{'form.pdfFormFields'} eq 'yes') {
4509: $currentstring .= '\usepackage{hyperref}'.
4510: '\usepackage{eforms}'.
4511: '\usepackage{tabularx}';
4512: }
4513:
4514: $currentstring .= '\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}}'.
4515: '\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.402 foxr 4516: $currentstring .= '\begin{document}';
1.399 foxr 4517:
4518: return $currentstring;
4519:
4520: }
4521:
1.397 jms 4522: =pod
4523:
4524: =head1 NAME
4525:
4526: Apache::londefdef.pm
4527:
4528: =head1 SYNOPSIS
4529:
4530: Tags Default Definition Module
4531:
4532: This is part of the LearningOnline Network with CAPA project
4533: described at http://www.lon-capa.org.
4534:
4535:
4536: =head1 NOTABLE SUBROUTINES
4537:
4538: =over
4539:
4540: =item start_hideweboutput()
4541:
4542: =item end_hideweboutput()
4543:
4544: =item image_replication()
4545:
4546: =item resize_image()
4547:
4548: Get correct sizing parameter for an image given
4549: it's initial ht. and wid. This allows sizing of
4550: images that are generated on-the-fly (e.g. gnuplot)
4551: as well as serving as a utility for image_size.
4552:
4553: Parameter:
4554: height_param
4555: width_param - Initial picture dimensions.
4556: scaling - A scale factor.
4557: parstack, - the current stack of tag attributes
4558: from the xml parser
4559: safeeval, - pointer to the safespace
4560: depth, - from what level in the stack to look for attributes
4561: (assumes -1 if unspecified)
4562: cis - look for attrubutes case insensitively
4563: (assumes false)
4564:
4565: Returns:
4566: height, width - new dimensions.
4567:
4568: =item image_size()
4569:
4570: =item image_width()
4571:
4572: =item image_height()
4573:
4574: =item get_eps_image()
4575:
4576: =item eps_generation()
4577:
4578: =item file_path()
4579:
4580: =item recalc()
4581:
4582: Converts a measurement in to mm from any of
4583: the other valid LaTeX units of measure.
4584: If the units of measure are missing from the
4585: parameter, it is assumed to be in and returned
4586: with mm units of measure
4587:
4588: =item LATEX_length()
4589:
4590: =item align_latex_image()
4591:
4592: Wrap image 'stuff' inside of the LaTeX required to implement
4593: alignment:
4594: align_tex_image(align, latex_rendering, image)
4595: Where:
4596: align - The HTML alignment specification.
4597: latex_rendering - rendering hint for latex.
4598: image - The LaTeX needed to insert the image itsef.
4599: width,height - dimensions of the image.
4600: Returns:
4601: The 1/2 wrapped image and the stuff required to close the
4602: wrappage. This allows e.g. randomlabel to insert more stuff
4603: into the closure.
4604:
4605:
4606: =item is_inside_of($tagstack, $tag)
4607: This sub returns true if the current state of Xml processing is inside of the tag.
4608: Parameters:
4609: tagstack - The tagstack from the parser.
4610: tag - The tag (without the <>'s.).
4611: Sample usage:
4612: if (is_inside_of($tagstack "table")) {
4613: I'm in a table....
4614: }
4615:
4616:
4617:
4618: =back
4619:
4620: =cut
4621:
4622:
1.1 sakharuk 4623: 1;
4624: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>