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