1: # The LearningOnline Network with CAPA
2: # Tags Default Definition Module
3: #
4: # $Id: londefdef.pm,v 1.184 2003/10/21 13:36:32 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: my $lengthnewdata=1.8*LATEX_length($elementdata);
1998: if ($lengthnewdata>$current_length) {$current_length=$lengthnewdata;}
1999: }
2000: } else {
2001: $current_length=1.8*LATEX_length($data);
2002: }
2003: $Apache::londefdef::table[-1]{'length'} .= $current_length.',';
2004: $Apache::londefdef::table[-1]{'TeXlength'} .= '0,';
2005: }
2006: }
2007: for (my $in=0; $in<=$#{$Apache::londefdef::table[-1]{'include'}};$in++) {
2008: $data=~s/\\keephidden\{NEW TABLE ENTRY\}/$Apache::londefdef::table[-1]{'include'}[$in]/;
2009: }
2010: @{ $Apache::londefdef::table[-1]{'rowdata'} }[$current_row] .= '\parbox{TOBECHANGEDONNUMBER}{'.$data.'} '.$Apache::londefdef::table[-1]{'vinc'};
2011: return'';
2012: }
2013:
2014: sub end_td {
2015: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
2016: my $currentstring = '';
2017: if ($target eq 'web') {
2018: $currentstring = $token->[2];
2019: } elsif ($target eq 'tex') {
2020: $Apache::londefdef::TD_redirection =0;
2021: &end_td_tex($parstack,$parser,$safeeval);
2022: }
2023: return $currentstring;
2024: }
2025:
2026: #-- <th> tag (end tag optional)
2027: sub start_th {
2028: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
2029: my $currentstring = '';
2030: if ($target eq 'web') {
2031: $currentstring = $token->[4];
2032: } elsif ($target eq 'tex') {
2033: my $what_to_push = substr(&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1),0,1);
2034: if ($what_to_push eq '') {
2035: $what_to_push = substr($Apache::londefdef::table[-1]{'rows'}[0],0,1);;
2036: }
2037: push @{ $Apache::londefdef::table[-1]{'columns'} }, $what_to_push;
2038: $Apache::londefdef::table[-1]{'counter_columns'}++;
2039: &Apache::lonxml::startredirection();
2040: }
2041: return $currentstring;
2042: }
2043:
2044: sub end_th {
2045: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
2046: my $currentstring = '';
2047: if ($target eq 'web') {
2048: $currentstring = $token->[2];
2049: } elsif ($target eq 'tex') {
2050: my $current_row = $Apache::londefdef::table[-1]{'row_number'};
2051: my $data=&Apache::lonxml::endredirection();
2052: my $TeXwidth=&Apache::lonxml::get_param('TeXwidth',$parstack,$safeeval,undef,0);
2053: if (defined $TeXwidth) {
2054: my $current_length=&recalc($TeXwidth);
2055: $current_length=~/(\d+)/;
2056: $Apache::londefdef::table[-1]{'TeXlength'} .= $1.',';
2057: $Apache::londefdef::table[-1]{'length'} .= '0,';
2058: } else {
2059: if ($data=~m/width\s*=\s*(\d+\.?\d*\s*(mm|cm|in|pc|pt)*)/) {
2060: my $current_length=&recalc($1);
2061: $current_length=~/(\d+)/;
2062: $Apache::londefdef::table[-1]{'TeXlength'} .= $1.',';
2063: $Apache::londefdef::table[-1]{'length'} .= '0,';
2064: } else {
2065: $data=~/^\s*(\S.*)/;
2066: $data=$1;
2067: $data=~/(.*\S)\s*$/;
2068: $data=$1;
2069: my $current_length=2*length($data);
2070: $Apache::londefdef::table[-1]{'length'} .= $current_length.',';
2071: $Apache::londefdef::table[-1]{'TeXlength'} .= '0,';
2072: }
2073: }
2074: for (my $in=0; $in<=$#{$Apache::londefdef::table[-1]{'include'}};$in++) {
2075: $data=~s/\\keephidden\{NEW TABLE ENTRY\}/$Apache::londefdef::table[-1]{'include'}[$in]/;
2076: }
2077: $data='\textbf{'.$data.'}';
2078: @{ $Apache::londefdef::table[-1]{'rowdata'} }[$current_row] .= '\parbox{TOBECHANGEDONNUMBER}{'.$data.'} '.$Apache::londefdef::table[-1]{'vinc'};
2079: }
2080: return $currentstring;
2081: }
2082: #-- <img> tag (end tag forbidden)
2083: sub start_img {
2084: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
2085: my $src = &Apache::lonxml::get_param('src',$parstack,$safeeval,
2086: undef,1);
2087: $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=$src;
2088: my $currentstring = '';
2089: my $width_param = '';
2090: my $height_param = '';
2091: my $scaling = .3;
2092: if ($target eq 'web') {
2093: if ($ENV{'browser.imagesuppress'} ne 'on') {
2094: $currentstring.= $token->[4];
2095: } else {
2096: my $alttag= &Apache::lonxml::get_param
2097: ('alt',$parstack,$safeeval,undef,1);
2098: unless ($alttag) {
2099: $alttag=&Apache::lonmeta::alttag
2100: ($Apache::lonxml::pwd[-1],$src);
2101: }
2102: $currentstring.='[IMAGE: '.$alttag.']';
2103: }
2104: } elsif ($target eq 'tex') {
2105: $src=&Apache::lonnet::filelocation($Apache::lonxml::pwd[-1],$src);
2106: &image_replication($src);
2107: #if original gif/jpg/png file exist do following:
2108: if (-e $src) {
2109: #defines the default size of image
2110: my $image = Image::Magick->new;
2111: my $current_figure = $image->Read($src);
2112: $width_param = $image->Get('width') * $scaling;;
2113: $height_param = $image->Get('height') * $scaling;;
2114: undef $image;
2115: #do we have any specified size of the picture?
2116: my $TeXwidth = &Apache::lonxml::get_param('TeXwidth',$parstack,$safeeval);
2117: my $TeXheight = &Apache::lonxml::get_param('TeXheight',$parstack,$safeeval);
2118: my $width = &Apache::lonxml::get_param('width',$parstack,$safeeval,
2119: undef,1);
2120: if ($TeXwidth ne '') {
2121: if ($TeXwidth=~/(\d+)\s*\%/) {
2122: $width_param = $1*$ENV{'form.textwidth'}/100;
2123: } else {
2124: $width_param = $TeXwidth;
2125: }
2126: } elsif ($TeXheight ne '') {
2127: $width_param = $TeXheight/$height_param*$width_param;
2128: } elsif ($width ne '') {
2129: $width_param = $width*$scaling;
2130: }
2131: if ($width_param > $ENV{'form.textwidth'}) {$width_param =0.95*$ENV{'form.textwidth'}}
2132: my $file;
2133: my $path;
2134: if ($src =~ m!(.*)/([^/]*)$!) {
2135: $file = $2;
2136: $path = $1.'/';
2137: }
2138: my $newsrc = $src;
2139: $newsrc =~ s/\.(gif|jpg|png)$/.eps/i;
2140: $file=~s/\.(gif|jpg|png)$/.eps/i;
2141: #where can we find the picture?
2142: if (-e $newsrc) {
2143: #eps counterpart for image exist
2144: if ($path) {
2145: $currentstring .= '\vskip 1 mm \noindent\graphicspath{{'.$path.'}}\includegraphics[width='.$width_param.' mm]{'.$file.'} ';
2146: }
2147: } else {
2148: #there is no eps counterpart for image - check for ps one
2149: $newsrc =~ s/\.eps$/\.ps/;
2150: if (-e $newsrc) {
2151: #ps counterpart for image exist
2152: $file =~ s/\.eps$/\.ps/;
2153: if ($path) {
2154: $currentstring .= '\vskip 1 mm \noindent\graphicspath{{'.$path.'}}\includegraphics[width='.$width_param.' mm]{'.$file.'} ';
2155: }
2156: } else {
2157: #there aren't eps or ps - so create eps
2158: my $temp_file;
2159: my $filename = "/home/httpd/prtspool/$ENV{'user.name'}_$ENV{'user.domain'}_printout.dat";
2160: $temp_file = Apache::File->new('>>'.$filename);
2161: print $temp_file "$src\n";
2162: $newsrc=~s/\/home\/httpd\/html\/res//;
2163: $newsrc=~s/\/([^\/]+)\.(ps|eps)/\//;
2164: $currentstring .= '\vskip 1 mm \graphicspath{{/home/httpd/prtspool'.$newsrc.'}}\includegraphics[width='.$width_param.' mm]{'.$file.'} ';
2165: }
2166: }
2167: } else {
2168: #original image file doesn't exist so check the alt attribute
2169: my $alt =
2170: &Apache::lonxml::get_param('alt',$parstack,$safeeval,undef,1);
2171: unless ($alt) {
2172: $alt=&Apache::lonmeta::alttag($Apache::lonxml::pwd[-1],$src);
2173: }
2174:
2175: if ($alt) {
2176: $currentstring .= ' '.$alt.' ';
2177: } else {
2178: #<allow> tag will care about replication
2179: }
2180: }
2181: }
2182: return $currentstring;
2183: }
2184:
2185: sub end_img {
2186: my ($target,$token) = @_;
2187: my $currentstring = '';
2188: if ($target eq 'web') {
2189: $currentstring = $token->[2];
2190: } elsif ($target eq 'tex') {
2191: $currentstring = '';
2192: }
2193: return $currentstring;
2194: }
2195:
2196: #-- <applet> tag (end tag required)
2197: sub start_applet {
2198: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
2199:
2200: my $code=&Apache::lonxml::get_param('code',$parstack,$safeeval,undef,1);
2201: $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=$code;
2202:
2203: my $archive=&Apache::lonxml::get_param('archive',$parstack,$safeeval,
2204: undef,1);
2205: $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=$archive;
2206:
2207: my $currentstring = '';
2208: if ($target eq 'web') {
2209: if ($ENV{'browser.appletsuppress'} ne 'on') {
2210: $currentstring = $token->[4];
2211: } else {
2212: my $alttag= &Apache::lonxml::get_param('alt',$parstack,
2213: $safeeval,undef,1);
2214: unless ($alttag) {
2215: $alttag=&Apache::lonmeta::alttag($Apache::lonxml::pwd[-1],
2216: $code);
2217: }
2218: $currentstring='[APPLET: '.$alttag.']';
2219: }
2220: } elsif ($target eq 'tex') {
2221: my $alttag= &Apache::lonxml::get_param('alt',$parstack,
2222: $safeeval,undef,1);
2223: unless ($alttag) {
2224: my $code=&Apache::lonxml::get_param('code',$parstack,$safeeval,
2225: undef,1);
2226: $alttag=&Apache::lonmeta::alttag($Apache::lonxml::pwd[-1],
2227: $code);
2228: }
2229: $currentstring.='\begin{center} \fbox{Java Applet: '.$alttag.
2230: '.}\end{center}';
2231: }
2232: return $currentstring;
2233: }
2234:
2235: sub end_applet {
2236: my ($target,$token) = @_;
2237: my $currentstring = '';
2238: if ($target eq 'web') {
2239: $currentstring = $token->[2];
2240: } elsif ($target eq 'tex') {
2241: }
2242: return $currentstring;
2243: }
2244:
2245: #-- <embed> tag (end tag optional/required)
2246: sub start_embed {
2247: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
2248: my $src=&Apache::lonxml::get_param('src',$parstack,$safeeval,undef,1);
2249: $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=$src;
2250: my $currentstring = '';
2251: if ($target eq 'web') {
2252: if ($ENV{'browser.embedsuppress'} ne 'on') {
2253: $currentstring = $token->[4];
2254: } else {
2255: my $alttag=&Apache::lonxml::get_param
2256: ('alt',$parstack,$safeeval,undef,1);
2257: unless ($alttag) {
2258: $alttag=&Apache::lonmeta::alttag($Apache::lonxml::pwd[-1],$src);
2259: }
2260: $currentstring='[EMBED: '.$alttag.']';
2261: }
2262: } elsif ($target eq 'tex') {
2263: }
2264: return $currentstring;
2265: }
2266:
2267: sub end_embed {
2268: my ($target,$token) = @_;
2269: my $currentstring = '';
2270: if ($target eq 'web') {
2271: $currentstring = $token->[2];
2272: } elsif ($target eq 'tex') {
2273: }
2274: return $currentstring;
2275: }
2276:
2277: #-- <param> tag (end tag forbidden)
2278: sub start_param {
2279: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
2280: if (&Apache::lonxml::get_param
2281: ('name',$parstack,$safeeval,undef,1)=~/^cabbase$/i) {
2282: $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=
2283: &Apache::lonxml::get_param('value',$parstack,$safeeval,undef,1);
2284: }
2285: $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=
2286: &Apache::lonxml::get_param('src',$parstack,$safeeval,undef,1);
2287: my $currentstring = '';
2288: if ($target eq 'web') {
2289: $currentstring = $token->[4];
2290: } elsif ($target eq 'tex') {
2291: }
2292: return $currentstring;
2293: }
2294:
2295: sub end_param {
2296: my ($target,$token) = @_;
2297: my $currentstring = '';
2298: if ($target eq 'web') {
2299: $currentstring = $token->[2];
2300: } elsif ($target eq 'tex') {
2301: }
2302: return $currentstring;
2303: }
2304:
2305: #-- <allow> tag
2306: sub start_allow {
2307: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
2308: my $src = &Apache::lonxml::get_param('src',$parstack,$safeeval,undef,1);
2309: $src=&Apache::lonnet::filelocation($Apache::lonxml::pwd[-1],$src);
2310: $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=
2311: &Apache::lonnet::clutter($src);
2312: &image_replication($src);
2313: my $result;
2314: if ($target eq 'edit') {
2315: $result .=&Apache::edit::tag_start($target,$token);
2316: $result .=&Apache::edit::text_arg('File Spec:','src',$token,70);
2317: $result .=&Apache::edit::end_row();#.&Apache::edit::start_spanning_row();
2318: } elsif ($target eq 'modified') {
2319: my $constructtag=&Apache::edit::get_new_args($token,$parstack,
2320: $safeeval,'src');
2321: if ($constructtag) { $result = &Apache::edit::rebuild_tag($token); }
2322: }
2323: return $result;
2324: }
2325:
2326: sub end_allow {
2327: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
2328: if ( $target eq 'edit') { return (&Apache::edit::end_table()); }
2329: return '';
2330: }
2331:
2332: #-- Frames (end tag required)
2333: #-- <frameset>
2334: sub start_frameset {
2335: my ($target,$token) = @_;
2336: my $currentstring = '';
2337: if ($target eq 'web') {
2338: if (!$Apache::lonxml::registered &&
2339: $ENV{'request.state'} eq 'published') {
2340: $currentstring.='<head>'.
2341: &Apache::lonmenu::registerurl(undef,$target).'</head>';
2342: }
2343: my $onLoad='';
2344: foreach my $key (keys(%{$token->[2]})) {
2345: if ($key =~ /^onload$/i) {
2346: $onLoad.=$token->[2]->{$key}.';';
2347: delete($token->[2]->{$key});
2348: }
2349: }
2350: $token->[2]->{'onload'}=&Apache::lonmenu::loadevents().';'.$onLoad;
2351: my $onUnload='';
2352: foreach my $key (keys(%{$token->[2]})) {
2353: if ($key =~ /^onunload$/i) {
2354: $onUnload.=$token->[2]->{$key}.';';
2355: delete($token->[2]->{$key});
2356: }
2357: }
2358: $token->[2]->{'onunload'}=&Apache::lonmenu::unloadevents().
2359: ';'.$onUnload;
2360:
2361: $currentstring .= '<'.$token->[1];
2362: foreach (keys %{$token->[2]}) {
2363: $currentstring.=' '.$_.'="'.$token->[2]->{$_}.'"';
2364: }
2365: $currentstring.='>';
2366: }
2367: return $currentstring;
2368: }
2369:
2370: sub end_frameset {
2371: my ($target,$token) = @_;
2372: my $currentstring = '';
2373: if ($target eq 'web') {
2374: $currentstring = $token->[2];
2375: }
2376: return $currentstring;
2377: }
2378:
2379: #-- <xmp> (end tag required)
2380: sub start_xmp {
2381: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
2382: my $currentstring = '';
2383: if ($target eq 'web') {
2384: $currentstring .= $token->[4];
2385: } elsif ($target eq 'tex') {
2386: $currentstring .= '\begin{verbatim}';
2387: }
2388: return $currentstring;
2389: }
2390:
2391: sub end_xmp {
2392: my ($target,$token) = @_;
2393: my $currentstring = '';
2394: if ($target eq 'web') {
2395: $currentstring .= $token->[2];
2396: } elsif ($target eq 'tex') {
2397: $currentstring .= '\end{verbatim}';
2398: }
2399: return $currentstring;
2400: }
2401:
2402: #-- <pre> (end tag required)
2403: sub start_pre {
2404: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
2405: my $currentstring = '';
2406: if ($target eq 'web') {
2407: $currentstring .= $token->[4];
2408: } elsif ($target eq 'tex') {
2409: $currentstring .= '\begin{verbatim}';
2410: }
2411: return $currentstring;
2412: }
2413:
2414: sub end_pre {
2415: my ($target,$token) = @_;
2416: my $currentstring = '';
2417: if ($target eq 'web') {
2418: $currentstring .= $token->[2];
2419: } elsif ($target eq 'tex') {
2420: $currentstring .= '\end{verbatim}';
2421: }
2422: return $currentstring;
2423: }
2424:
2425: #-- <insert>
2426: sub start_insert {
2427: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
2428: my $currentstring = '';
2429: if ($target eq 'web') {
2430: my $display = &Apache::lonxml::get_param('display',$parstack,$safeeval,undef,1);
2431: $currentstring .= '<b>'.$display.'</b>';;
2432: }
2433: return $currentstring;
2434: }
2435:
2436: sub end_insert {
2437: my ($target,$token) = @_;
2438: my $currentstring = '';
2439: if ($target eq 'web') {
2440: $currentstring .= '';
2441: }
2442: return $currentstring;
2443: }
2444:
2445: #-- <externallink>
2446: sub start_externallink {
2447: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
2448: my $currentstring = '';
2449: if ($target eq 'web') {
2450: my $display = &Apache::lonxml::get_param('display',$parstack,$safeeval,undef,1);
2451: $currentstring .= '<b>'.$display.'</b>';;
2452: }
2453: return $currentstring;
2454: }
2455:
2456: sub end_externallink {
2457: my ($target,$token) = @_;
2458: my $currentstring = '';
2459: if ($target eq 'web') {
2460: $currentstring .= '';
2461: }
2462: return $currentstring;
2463: }
2464:
2465: #-- <blankspace heigth="">
2466: sub start_blankspace {
2467: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
2468: my $currentstring = '';
2469: if ($target eq 'tex') {
2470: my $howmuch = &Apache::lonxml::get_param('heigth',$parstack,$safeeval,undef,1);
2471: $currentstring .= '\vskip '.$howmuch.' ';
2472: }
2473: return $currentstring;
2474: }
2475:
2476: sub end_blankspace {
2477: my ($target,$token) = @_;
2478: my $currentstring = '';
2479: if ($target eq 'tex') {
2480: $currentstring .= '';
2481: }
2482: return $currentstring;
2483: }
2484:
2485: #-- <abbr> tag (end tag required)
2486: sub start_abbr {
2487: my ($target,$token) = @_;
2488: my $currentstring = '';
2489: if ($target eq 'web') {
2490: $currentstring = $token->[4];
2491: }
2492: return $currentstring;
2493: }
2494:
2495: sub end_abbr {
2496: my ($target,$token) = @_;
2497: my $currentstring = '';
2498: if ($target eq 'web') {
2499: $currentstring = $token->[2];
2500: }
2501: return $currentstring;
2502: }
2503:
2504: #-- <acronym> tag (end tag required)
2505: sub start_acronym {
2506: my ($target,$token) = @_;
2507: my $currentstring = '';
2508: if ($target eq 'web') {
2509: $currentstring = $token->[4];
2510: }
2511: return $currentstring;
2512: }
2513:
2514: sub end_acronym {
2515: my ($target,$token) = @_;
2516: my $currentstring = '';
2517: if ($target eq 'web') {
2518: $currentstring = $token->[2];
2519: }
2520: return $currentstring;
2521: }
2522:
2523: #-- <area> tag (end tag forbidden)
2524: sub start_area {
2525: my ($target,$token) = @_;
2526: my $currentstring = '';
2527: if ($target eq 'web') {
2528: $currentstring = $token->[4];
2529: }
2530: return $currentstring;
2531: }
2532:
2533: sub end_area {
2534: my ($target,$token) = @_;
2535: my $currentstring = '';
2536: if ($target eq 'web') {
2537: $currentstring = $token->[2];
2538: }
2539: return $currentstring;
2540: }
2541:
2542: #-- <base> tag (end tag forbidden)
2543: sub start_base {
2544: my ($target,$token) = @_;
2545: my $currentstring = '';
2546: if ($target eq 'web') {
2547: $currentstring = $token->[4];
2548: }
2549: return $currentstring;
2550: }
2551:
2552: sub end_base {
2553: my ($target,$token) = @_;
2554: my $currentstring = '';
2555: if ($target eq 'web') {
2556: $currentstring = $token->[2];
2557: }
2558: return $currentstring;
2559: }
2560:
2561: #-- <bdo> tag (end tag required)
2562: sub start_bdo {
2563: my ($target,$token) = @_;
2564: my $currentstring = '';
2565: if ($target eq 'web') {
2566: $currentstring = $token->[4];
2567: }
2568: return $currentstring;
2569: }
2570:
2571: sub end_bdo {
2572: my ($target,$token) = @_;
2573: my $currentstring = '';
2574: if ($target eq 'web') {
2575: $currentstring = $token->[2];
2576: }
2577: return $currentstring;
2578: }
2579:
2580: #-- <bgsound> tag (end tag optional)
2581: sub start_bgsound {
2582: my ($target,$token) = @_;
2583: my $currentstring = '';
2584: if ($target eq 'web') {
2585: $currentstring = $token->[4];
2586: }
2587: return $currentstring;
2588: }
2589:
2590: sub end_bgsound {
2591: my ($target,$token) = @_;
2592: my $currentstring = '';
2593: if ($target eq 'web') {
2594: $currentstring = $token->[2];
2595: }
2596: return $currentstring;
2597: }
2598:
2599: #-- <blink> tag (end tag required)
2600: sub start_blink {
2601: my ($target,$token) = @_;
2602: my $currentstring = '';
2603: if ($target eq 'web') {
2604: $currentstring = $token->[4];
2605: }
2606: return $currentstring;
2607: }
2608:
2609: sub end_blink {
2610: my ($target,$token) = @_;
2611: my $currentstring = '';
2612: if ($target eq 'web') {
2613: $currentstring = $token->[2];
2614: }
2615: return $currentstring;
2616: }
2617:
2618: #-- <blockquote> tag (end tag required)
2619: sub start_blockquote {
2620: my ($target,$token) = @_;
2621: my $currentstring = '';
2622: if ($target eq 'web') {
2623: $currentstring = $token->[4];
2624: }
2625: return $currentstring;
2626: }
2627:
2628: sub end_blockquote {
2629: my ($target,$token) = @_;
2630: my $currentstring = '';
2631: if ($target eq 'web') {
2632: $currentstring = $token->[2];
2633: }
2634: return $currentstring;
2635: }
2636:
2637: #-- <button> tag (end tag required)
2638: sub start_button {
2639: my ($target,$token) = @_;
2640: my $currentstring = '';
2641: if ($target eq 'web') {
2642: $currentstring = $token->[4];
2643: }
2644: return $currentstring;
2645: }
2646:
2647: sub end_button {
2648: my ($target,$token) = @_;
2649: my $currentstring = '';
2650: if ($target eq 'web') {
2651: $currentstring = $token->[2];
2652: }
2653: return $currentstring;
2654: }
2655:
2656: #-- <caption> tag (end tag required)
2657: sub start_caption {
2658: my ($target,$token) = @_;
2659: my $currentstring = '';
2660: if ($target eq 'web') {
2661: $currentstring = $token->[4];
2662: }
2663: return $currentstring;
2664: }
2665:
2666: sub end_caption {
2667: my ($target,$token) = @_;
2668: my $currentstring = '';
2669: if ($target eq 'web') {
2670: $currentstring = $token->[2];
2671: }
2672: return $currentstring;
2673: }
2674:
2675: #-- <col> tag (end tag forbdden)
2676: sub start_col {
2677: my ($target,$token) = @_;
2678: my $currentstring = '';
2679: if ($target eq 'web') {
2680: $currentstring = $token->[4];
2681: }
2682: return $currentstring;
2683: }
2684:
2685: sub end_col {
2686: my ($target,$token) = @_;
2687: my $currentstring = '';
2688: if ($target eq 'web') {
2689: $currentstring = $token->[2];
2690: }
2691: return $currentstring;
2692: }
2693:
2694: #-- <colgroup> tag (end tag optional)
2695: sub start_colgroup {
2696: my ($target,$token) = @_;
2697: my $currentstring = '';
2698: if ($target eq 'web') {
2699: $currentstring = $token->[4];
2700: }
2701: return $currentstring;
2702: }
2703:
2704: sub end_colgroup {
2705: my ($target,$token) = @_;
2706: my $currentstring = '';
2707: if ($target eq 'web') {
2708: $currentstring = $token->[2];
2709: }
2710: return $currentstring;
2711: }
2712:
2713: #-- <del> tag (end tag required)
2714: sub start_del {
2715: my ($target,$token) = @_;
2716: my $currentstring = '';
2717: if ($target eq 'web') {
2718: $currentstring = $token->[4];
2719: }
2720: return $currentstring;
2721: }
2722:
2723: sub end_del {
2724: my ($target,$token) = @_;
2725: my $currentstring = '';
2726: if ($target eq 'web') {
2727: $currentstring = $token->[2];
2728: }
2729: return $currentstring;
2730: }
2731:
2732: #-- <fieldset> tag (end tag required)
2733: sub start_fieldset {
2734: my ($target,$token) = @_;
2735: my $currentstring = '';
2736: if ($target eq 'web') {
2737: $currentstring = $token->[4];
2738: }
2739: return $currentstring;
2740: }
2741:
2742: sub end_fieldset {
2743: my ($target,$token) = @_;
2744: my $currentstring = '';
2745: if ($target eq 'web') {
2746: $currentstring = $token->[2];
2747: }
2748: return $currentstring;
2749: }
2750:
2751: #-- <frame> tag (end tag forbidden)
2752: sub start_frame {
2753: my ($target,$token) = @_;
2754: my $currentstring = '';
2755: if ($target eq 'web') {
2756: $currentstring = $token->[4];
2757: }
2758: return $currentstring;
2759: }
2760:
2761: sub end_frame {
2762: my ($target,$token) = @_;
2763: my $currentstring = '';
2764: if ($target eq 'web') {
2765: $currentstring = $token->[2];
2766: }
2767: return $currentstring;
2768: }
2769:
2770: #-- <iframe> tag (end tag required)
2771: sub start_iframe {
2772: my ($target,$token) = @_;
2773: my $currentstring = '';
2774: if ($target eq 'web') {
2775: $currentstring = $token->[4];
2776: }
2777: return $currentstring;
2778: }
2779:
2780: sub end_iframe {
2781: my ($target,$token) = @_;
2782: my $currentstring = '';
2783: if ($target eq 'web') {
2784: $currentstring = $token->[2];
2785: }
2786: return $currentstring;
2787: }
2788:
2789: #-- <ins> tag (end tag required)
2790: sub start_ins {
2791: my ($target,$token) = @_;
2792: my $currentstring = '';
2793: if ($target eq 'web') {
2794: $currentstring = $token->[4];
2795: }
2796: return $currentstring;
2797: }
2798:
2799: sub end_ins {
2800: my ($target,$token) = @_;
2801: my $currentstring = '';
2802: if ($target eq 'web') {
2803: $currentstring = $token->[2];
2804: }
2805: return $currentstring;
2806: }
2807:
2808: #-- <isindex> tag (end tag forbidden)
2809: sub start_isindex {
2810: my ($target,$token) = @_;
2811: my $currentstring = '';
2812: if ($target eq 'web') {
2813: $currentstring = $token->[4];
2814: }
2815: return $currentstring;
2816: }
2817:
2818: sub end_isindex {
2819: my ($target,$token) = @_;
2820: my $currentstring = '';
2821: if ($target eq 'web') {
2822: $currentstring = $token->[2];
2823: }
2824: return $currentstring;
2825: }
2826:
2827: #-- <keygen> tag (end tag forbidden)
2828: sub start_keygen {
2829: my ($target,$token) = @_;
2830: my $currentstring = '';
2831: if ($target eq 'web') {
2832: $currentstring = $token->[4];
2833: }
2834: return $currentstring;
2835: }
2836:
2837: sub end_keygen {
2838: my ($target,$token) = @_;
2839: my $currentstring = '';
2840: if ($target eq 'web') {
2841: $currentstring = $token->[2];
2842: }
2843: return $currentstring;
2844: }
2845:
2846: #-- <label> tag
2847: sub start_label {
2848: my ($target,$token) = @_;
2849: my $currentstring = '';
2850: if ($target eq 'web') {
2851: $currentstring = $token->[4];
2852: }
2853: return $currentstring;
2854: }
2855:
2856: sub end_label {
2857: my ($target,$token) = @_;
2858: my $currentstring = '';
2859: if ($target eq 'web') {
2860: $currentstring = $token->[2];
2861: }
2862: return $currentstring;
2863: }
2864:
2865: #-- <layer> tag (end tag required)
2866: sub start_layer {
2867: my ($target,$token) = @_;
2868: my $currentstring = '';
2869: if ($target eq 'web') {
2870: $currentstring = $token->[4];
2871: }
2872: return $currentstring;
2873: }
2874:
2875: sub end_layer {
2876: my ($target,$token) = @_;
2877: my $currentstring = '';
2878: if ($target eq 'web') {
2879: $currentstring = $token->[2];
2880: }
2881: return $currentstring;
2882: }
2883:
2884: #-- <legend> tag (end tag required)
2885: sub start_legend {
2886: my ($target,$token) = @_;
2887: my $currentstring = '';
2888: if ($target eq 'web') {
2889: $currentstring = $token->[4];
2890: }
2891: return $currentstring;
2892: }
2893:
2894: sub end_legend {
2895: my ($target,$token) = @_;
2896: my $currentstring = '';
2897: if ($target eq 'web') {
2898: $currentstring = $token->[2];
2899: }
2900: return $currentstring;
2901: }
2902:
2903: #-- <link> tag (end tag forbidden)
2904: sub start_link {
2905: my ($target,$token) = @_;
2906: my $currentstring = '';
2907: if ($target eq 'web') {
2908: $currentstring = $token->[4];
2909: }
2910: return $currentstring;
2911: }
2912:
2913: sub end_link {
2914: my ($target,$token) = @_;
2915: my $currentstring = '';
2916: if ($target eq 'web') {
2917: $currentstring = $token->[2];
2918: }
2919: return $currentstring;
2920: }
2921:
2922: #-- <marquee> tag (end tag optional)
2923: sub start_marquee {
2924: my ($target,$token) = @_;
2925: my $currentstring = '';
2926: if ($target eq 'web') {
2927: $currentstring = $token->[4];
2928: }
2929: return $currentstring;
2930: }
2931:
2932: sub end_marquee {
2933: my ($target,$token) = @_;
2934: my $currentstring = '';
2935: if ($target eq 'web') {
2936: $currentstring = $token->[2];
2937: }
2938: return $currentstring;
2939: }
2940:
2941: #-- <multicol> tag (end tag required)
2942: sub start_multicol {
2943: my ($target,$token) = @_;
2944: my $currentstring = '';
2945: if ($target eq 'web') {
2946: $currentstring = $token->[4];
2947: }
2948: return $currentstring;
2949: }
2950:
2951: sub end_multicol {
2952: my ($target,$token) = @_;
2953: my $currentstring = '';
2954: if ($target eq 'web') {
2955: $currentstring = $token->[2];
2956: }
2957: return $currentstring;
2958: }
2959:
2960: #-- <nobr> tag (end tag required)
2961: sub start_nobr {
2962: my ($target,$token) = @_;
2963: my $currentstring = '';
2964: if ($target eq 'web') {
2965: $currentstring = $token->[4];
2966: } elsif ($target eq 'tex') {
2967: $currentstring='\mbox{';
2968: }
2969: return $currentstring;
2970: }
2971:
2972: sub end_nobr {
2973: my ($target,$token) = @_;
2974: my $currentstring = '';
2975: if ($target eq 'web') {
2976: $currentstring = $token->[2];
2977: } elsif ($target eq 'tex') {
2978: $currentstring='}';
2979: }
2980: return $currentstring;
2981: }
2982:
2983: #-- <noembed> tag (end tag required)
2984: sub start_noembed {
2985: my ($target,$token) = @_;
2986: my $currentstring = '';
2987: if ($target eq 'web') {
2988: $currentstring = $token->[4];
2989: }
2990: return $currentstring;
2991: }
2992:
2993: sub end_noembed {
2994: my ($target,$token) = @_;
2995: my $currentstring = '';
2996: if ($target eq 'web') {
2997: $currentstring = $token->[2];
2998: }
2999: return $currentstring;
3000: }
3001:
3002: #-- <noframes> tag (end tag required)
3003: sub start_noframes {
3004: my ($target,$token) = @_;
3005: my $currentstring = '';
3006: if ($target eq 'web') {
3007: $currentstring = $token->[4];
3008: }
3009: return $currentstring;
3010: }
3011:
3012: sub end_noframes {
3013: my ($target,$token) = @_;
3014: my $currentstring = '';
3015: if ($target eq 'web') {
3016: $currentstring = $token->[2];
3017: }
3018: return $currentstring;
3019: }
3020:
3021: #-- <nolayer> tag (end tag required)
3022: sub start_nolayer {
3023: my ($target,$token) = @_;
3024: my $currentstring = '';
3025: if ($target eq 'web') {
3026: $currentstring = $token->[4];
3027: }
3028: return $currentstring;
3029: }
3030:
3031: sub end_nolayer {
3032: my ($target,$token) = @_;
3033: my $currentstring = '';
3034: if ($target eq 'web') {
3035: $currentstring = $token->[2];
3036: }
3037: return $currentstring;
3038: }
3039:
3040: #-- <noscript> tag (end tag required)
3041: sub start_noscript {
3042: my ($target,$token) = @_;
3043: my $currentstring = '';
3044: if ($target eq 'web') {
3045: $currentstring = $token->[4];
3046: }
3047: return $currentstring;
3048: }
3049:
3050: sub end_noscript {
3051: my ($target,$token) = @_;
3052: my $currentstring = '';
3053: if ($target eq 'web') {
3054: $currentstring = $token->[2];
3055: }
3056: return $currentstring;
3057: }
3058:
3059: #-- <object> tag (end tag required)
3060: sub start_object {
3061: my ($target,$token) = @_;
3062: my $currentstring = '';
3063: if ($target eq 'web') {
3064: $currentstring = $token->[4];
3065: }
3066: return $currentstring;
3067: }
3068:
3069: sub end_object {
3070: my ($target,$token) = @_;
3071: my $currentstring = '';
3072: if ($target eq 'web') {
3073: $currentstring = $token->[2];
3074: }
3075: return $currentstring;
3076: }
3077:
3078: #-- <optgroup> tag (end tag required)
3079: sub start_optgroup {
3080: my ($target,$token) = @_;
3081: my $currentstring = '';
3082: if ($target eq 'web') {
3083: $currentstring = $token->[4];
3084: }
3085: return $currentstring;
3086: }
3087:
3088: sub end_optgroup {
3089: my ($target,$token) = @_;
3090: my $currentstring = '';
3091: if ($target eq 'web') {
3092: $currentstring = $token->[2];
3093: }
3094: return $currentstring;
3095: }
3096:
3097: #-- <samp> tag (end tag required)
3098: sub start_samp {
3099: my ($target,$token) = @_;
3100: my $currentstring = '';
3101: if ($target eq 'web') {
3102: $currentstring = $token->[4];
3103: } elsif ($target eq 'tex') {
3104: $currentstring='\texttt{';
3105: }
3106: return $currentstring;
3107: }
3108:
3109: sub end_samp {
3110: my ($target,$token) = @_;
3111: my $currentstring = '';
3112: if ($target eq 'web') {
3113: $currentstring = $token->[2];
3114: } elsif ($target eq 'tex') {
3115: $currentstring='}';
3116: }
3117: return $currentstring;
3118: }
3119:
3120: #-- <server> tag
3121: sub start_server {
3122: my ($target,$token) = @_;
3123: my $currentstring = '';
3124: if ($target eq 'web') {
3125: $currentstring = $token->[4];
3126: }
3127: return $currentstring;
3128: }
3129:
3130: sub end_server {
3131: my ($target,$token) = @_;
3132: my $currentstring = '';
3133: if ($target eq 'web') {
3134: $currentstring = $token->[2];
3135: }
3136: return $currentstring;
3137: }
3138:
3139: #-- <spacer> tag (end tag forbidden)
3140: sub start_spacer {
3141: my ($target,$token) = @_;
3142: my $currentstring = '';
3143: if ($target eq 'web') {
3144: $currentstring = $token->[4];
3145: }
3146: return $currentstring;
3147: }
3148:
3149: sub end_spacer {
3150: my ($target,$token) = @_;
3151: my $currentstring = '';
3152: if ($target eq 'web') {
3153: $currentstring = $token->[2];
3154: }
3155: return $currentstring;
3156: }
3157:
3158: #-- <span> tag (end tag required)
3159: sub start_span {
3160: my ($target,$token) = @_;
3161: my $currentstring = '';
3162: if ($target eq 'web') {
3163: $currentstring = $token->[4];
3164: }
3165: return $currentstring;
3166: }
3167:
3168: sub end_span {
3169: my ($target,$token) = @_;
3170: my $currentstring = '';
3171: if ($target eq 'web') {
3172: $currentstring = $token->[2];
3173: }
3174: return $currentstring;
3175: }
3176:
3177: #-- <tbody> tag (end tag optional)
3178: sub start_tbody {
3179: my ($target,$token) = @_;
3180: my $currentstring = '';
3181: if ($target eq 'web') {
3182: $currentstring = $token->[4];
3183: }
3184: return $currentstring;
3185: }
3186:
3187: sub end_tbody {
3188: my ($target,$token) = @_;
3189: my $currentstring = '';
3190: if ($target eq 'web') {
3191: $currentstring = $token->[2];
3192: }
3193: return $currentstring;
3194: }
3195:
3196: #-- <tfoot> tag (end tag optional)
3197: sub start_tfoot {
3198: my ($target,$token) = @_;
3199: my $currentstring = '';
3200: if ($target eq 'web') {
3201: $currentstring = $token->[4];
3202: }
3203: return $currentstring;
3204: }
3205:
3206: sub end_tfoot {
3207: my ($target,$token) = @_;
3208: my $currentstring = '';
3209: if ($target eq 'web') {
3210: $currentstring = $token->[2];
3211: }
3212: return $currentstring;
3213: }
3214:
3215: #-- <thead> tag (end tag optional)
3216: sub start_thead {
3217: my ($target,$token) = @_;
3218: my $currentstring = '';
3219: if ($target eq 'web') {
3220: $currentstring = $token->[4];
3221: }
3222: return $currentstring;
3223: }
3224:
3225: sub end_thead {
3226: my ($target,$token) = @_;
3227: my $currentstring = '';
3228: if ($target eq 'web') {
3229: $currentstring = $token->[2];
3230: }
3231: return $currentstring;
3232: }
3233:
3234: #-- <var> tag
3235: sub start_var {
3236: my ($target,$token) = @_;
3237: my $currentstring = '';
3238: if ($target eq 'web') {
3239: $currentstring = $token->[4];
3240: } elsif ($target eq 'tex') {
3241: $currentstring = '\textit{';
3242: }
3243: return $currentstring;
3244: }
3245:
3246: sub end_var {
3247: my ($target,$token) = @_;
3248: my $currentstring = '';
3249: if ($target eq 'web') {
3250: $currentstring = $token->[2];
3251: } elsif ($target eq 'tex') {
3252: $currentstring = '}';
3253: }
3254: return $currentstring;
3255: }
3256:
3257: #-- <wbr> tag (end tag forbidden)
3258: sub start_wbr {
3259: my ($target,$token) = @_;
3260: my $currentstring = '';
3261: if ($target eq 'web') {
3262: $currentstring = $token->[4];
3263: }
3264: return $currentstring;
3265: }
3266:
3267: sub end_wbr {
3268: my ($target,$token) = @_;
3269: my $currentstring = '';
3270: if ($target eq 'web') {
3271: $currentstring = $token->[2];
3272: }
3273: return $currentstring;
3274: }
3275:
3276: #-- <hideweboutput> tag
3277: sub start_hideweboutput {
3278: my ($target,$token) = @_;
3279: if ($target eq 'web') {
3280: &Apache::lonxml::startredirection();
3281: }
3282: return '';
3283: }
3284:
3285: sub end_hideweboutput {
3286: my ($target,$token) = @_;
3287: my $currentstring = '';
3288: if ($target eq 'web') {
3289: $currentstring = &Apache::lonxml::endredirection();
3290: }
3291: return '';
3292: }
3293:
3294:
3295: sub image_replication {
3296: my $src = shift;
3297: if (not -e $src) {
3298: #replicates image itself
3299: &Apache::lonnet::repcopy($src);
3300: #replicates eps or ps
3301: my $newsrc = $src;
3302: $newsrc =~ s/\.(gif|jpg|jpeg|png)$/.eps/i;
3303: if (not -e $newsrc) {
3304: if (&Apache::lonnet::repcopy($newsrc) ne 'OK') {
3305: $newsrc =~ s/\.eps$/\.ps/;
3306: &Apache::lonnet::repcopy($newsrc);
3307: }
3308: }
3309: }
3310: return '';
3311: }
3312:
3313: sub recalc {
3314: my $argument = shift;
3315: if (not $argument=~/(mm|cm|in|pc|pt)/) {return $argument.' mm';}
3316: $argument=~/\s*(\d+\.?\d*)\s*(mm|cm|in|pc|pt)/;
3317: my $value=$1;
3318: my $units=$2;
3319: if ($units eq 'cm') {
3320: $value*=10;
3321: } elsif ($units eq 'in') {
3322: $value*=25.4;
3323: } elsif ($units eq 'pc') {
3324: $value*=(25.4*12/72.27);
3325: } elsif ($units eq 'pt') {
3326: $value*=(25.4/72.27);
3327: }
3328: return $value.' mm';
3329: }
3330:
3331: sub LATEX_length {
3332: my $garbage=shift;
3333: $garbage=~s/^\s+(\S.*)/$1/;
3334: $garbage=~s/(.*\S)\s+$/$1/;
3335: $garbage=~s/(\s)+/$1/;
3336: $garbage=~s/(\\begin{([^\}]+)}|\\end{([^\}]+)})//g;
3337: $garbage=~s/(\$\_\{|\$\_|\$\^{|\$\^|\}\$|\$)//g;
3338: $garbage=~s/(\\alpha|\\beta|\\gamma|\\delta|\\epsilon|\\verepsilon|\\zeta|\\eta|\\theta|\\vartheta|\\iota|\\kappa|\\lambda|\\mu|\\nu|\\xi|\\pi|\\varpi|\\rho|\\varrho|\\sigma|\\varsigma|\\tau|\\upsilon|\\phi|\\varphi|\\chi|\\psi|\\omega|\\Gamma|\\Delta|\\Theta|\\Lambda|\\Xi|\\Pi|\\Sigma|\\Upsilon|\\Phi|\\Psi|\\Omega)/1/g;
3339: $garbage=~s/(\\pm|\\mp|\\times|\\div|\\cdot|\\ast|\\star|\\dagger|\\ddagger|\\amalg|\\cap|\\cup|\\uplus|\\sqcap|\\sqcup|\\vee|\\wedge|\\oplus|\\ominus|\\otimes|\\circ|\\bullet|\\diamond|\\lhd|\\rhd|\\unlhd|\\unrhd|\\oslash|\\odot|\\bigcirc|\\Box|\\Diamond|\\bigtriangleup|\\bigtriangledown|\\triangleleft|\\triangleright|\\setminus|\\wr)/1/g;
3340: $garbage=~s/(\\le|\\ll|\\leq|\\ge|\\geq|\\gg|\\neq|\\doreq|\\sim|\\simeq|\\subset|\\subseteq|\\sqsubset|\\sqsubseteq|\\in|\\vdash|\\models|\\supset|\\supseteq|\\sqsupset|\\sqsupseteq|\\ni|\\dash|\\perp|\\approx|\\cong|\\equiv|\\propto|\\prec|\\preceq|\\parallel|\\asymp|\\smile|\\frown|\\bowtie|\\succ|\\succeq|\\mid)/1/g;
3341: $garbage=~s/(\\not<|\\\\not\\le|\\not\\prec|\\not\\preceq|\\not\\subset|\\not\\subseteq|\\not\\sqsubseteq|\\not\\in|\\not>|\\not\\ge|\\not\\succ|\\notsucceq|\\not\\supset|\\notsupseteq|\\not\\sqsupseteq|\\notin|\\not=|\\not\\equiv|\\not\\sim|\\not\\simeq|\\not\\approx|\\not\\cong|\\not\\asymp)/1/g;
3342: $garbage=~s/(\\leftarrow|\\gets|\\Leftarrow|\\rightarrow|\\to|\\Rightarrow|\\leftrightarrow|\\Leftrightarrow|\\mapsto|\\hookleftarrow|\\leftharpoonup|\\leftkarpoondown|\\rightleftharpoons|\\longleftarrow|\\Longleftarrow|\\longrightarrow|\\Longrightarrow|\\longleftrightarrow|\\Longleftrightarrow|\\longmapsto|\\hookrightarrow|\\rightharpoonup|\\rightharpoondown|\\uparrow|\\Uparrow|\\downarrow|\\Downarrow|\\updownarrow|\\Updownarrow|\\nearrow|\\searrow|\\swarrow|\\nwarrow)/1/g;
3343: $garbage=~s/(\\aleph|\\hbar|\\imath|\\jmath|\\ell|\\wp|\\Re|\\Im|\\mho|\\prime|\\emptyset|\\nabla|\\surd|\\partial|\\top|\\bot|\\vdash|\\dashv|\\forall|\\exists|\\neg|\\flat|\\natural|\\sharp|\\\||\\angle|\\backslash|\\Box|\\Diamond|\\triangle|\\clubsuit|\\diamondsuit|\\heartsuit|\\spadesuit|\\Join|\\infty)/ /g;
3344: $garbage=~s/(\\hat{([^}]+)}|\\check{([^}]+)}|\\dot{([^}]+)}|\\breve{([^}]+)}|\\acute{([^}]+)}|\\ddot{([^}]+)}|\\grave{([^}]+)}|\\tilde{([^}]+)}|\\mathring{([^}]+)}|\\bar{([^}]+)}|\\vec{([^}]+)})/$1/g;
3345: my $value=length($garbage);
3346: return $value;
3347: }
3348:
3349:
3350:
3351:
3352: 1;
3353: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>