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