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