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