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