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