Annotation of loncom/xml/londefdef.pm, revision 1.86
1.1 sakharuk 1: # The LearningOnline Network with CAPA
2: # Tags Default Definition Module
3: #
1.86 ! sakharuk 4: # $Id: londefdef.pm,v 1.85 2002/08/20 15:22:40 sakharuk Exp $
1.41 sakharuk 5: #
1.34 www 6: #
7: # Copyright Michigan State University Board of Trustees
8: #
9: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
10: #
11: # LON-CAPA is free software; you can redistribute it and/or modify
12: # it under the terms of the GNU General Public License as published by
13: # the Free Software Foundation; either version 2 of the License, or
14: # (at your option) any later version.
15: #
16: # LON-CAPA is distributed in the hope that it will be useful,
17: # but WITHOUT ANY WARRANTY; without even the implied warranty of
18: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19: # GNU General Public License for more details.
20: #
21: # You should have received a copy of the GNU General Public License
22: # along with LON-CAPA; if not, write to the Free Software
23: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24: #
25: # /home/httpd/html/adm/gpl.txt
26: #
27: # http://www.lon-capa.org/
28: #
29: # Copyright for TtHfunc and TtMfunc by Ian Hutchinson.
30: # TtHfunc and TtMfunc (the "Code") may be compiled and linked into
31: # binary executable programs or libraries distributed by the
32: # Michigan State University (the "Licensee"), but any binaries so
33: # distributed are hereby licensed only for use in the context
34: # of a program or computational system for which the Licensee is the
35: # primary author or distributor, and which performs substantial
36: # additional tasks beyond the translation of (La)TeX into HTML.
37: # The C source of the Code may not be distributed by the Licensee
38: # to any other parties under any circumstances.
39: #
40: #
1.1 sakharuk 41: # last modified 06/26/00 by Alexander Sakharuk
1.28 www 42: # 11/6,11/30,02/01/01,5/4 Gerd Kortemeyer
1.41 sakharuk 43: # 01/18 Alex Sakharuk
1.1 sakharuk 44:
1.2 albertel 45: package Apache::londefdef;
1.1 sakharuk 46:
1.54 sakharuk 47: use Apache::lonnet;
1.1 sakharuk 48: use strict;
1.3 sakharuk 49: use Apache::lonxml;
1.57 sakharuk 50: use Apache::File();
1.70 sakharuk 51: use Image::Magick;
1.54 sakharuk 52:
1.38 harris41 53: BEGIN {
1.15 sakharuk 54:
1.85 sakharuk 55: &Apache::lonxml::register('Apache::londefdef',('m','html','head','map','select','option','input','textarea','form','meta','title','body','center','b','strong','dt','h1','h2','h3','h4','h5','h6','cite','i','address','dd','dl','dir','ol','ul','menu','dfn','kbd','tt','code','em','q','p','br','big','small','basefont','font','s','sub','strike','sup','hr','a','li','u','output','param','applet','img','embed','allow','frameset','pre','insert','div','externallink','table','tr','th','td','blankspace','bubble','bubbles','bubbleline'));
1.15 sakharuk 56:
1.3 sakharuk 57: }
1.1 sakharuk 58:
1.35 sakharuk 59: #======================= TAG SUBROUTINES =====================
1.8 sakharuk 60: #-- <output>
1.21 albertel 61: sub start_output {
62: my ($target) = @_;
1.22 albertel 63: if ($target eq 'meta') { $Apache::lonxml::metamode--; }
1.21 albertel 64: return '';
65: }
66: sub end_output {
67: my ($target) = @_;
1.22 albertel 68: if ($target eq 'meta') { $Apache::lonxml::metamode++; }
1.21 albertel 69: return '';
70: }
1.4 sakharuk 71: #-- <m> tag
1.33 albertel 72: sub start_m {
73: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
74: my $currentstring = '';
75: if ($target eq 'web') {
1.61 albertel 76: $Apache::lonxml::prevent_entity_encode++;
1.73 albertel 77: my $inside = &Apache::lonxml::get_all_text_unbalanced("/m",$parser);
1.33 albertel 78: $inside ='\\documentstyle{article}'.$inside;
1.37 albertel 79: &Apache::lonxml::debug("M is starting with:$inside:");
1.33 albertel 80: my $eval=&Apache::lonxml::get_param('eval',$parstack,$safeeval);
81: if ($eval eq 'on') {
82: $inside=&Apache::run::evaluate($inside,$safeeval,$$parstack[-1]);
83: #&Apache::lonxml::debug("M is evaulated to:$inside:");
84: }
85: $currentstring = &Apache::lontexconvert::converted(\$inside);
1.37 albertel 86: if ($Apache::lontexconvert::errorstring) {
87: &Apache::lonxml::warning("tth error: ".
88: $Apache::lontexconvert::errorstring);
89: $Apache::lontexconvert::errorstring='';
90: }
1.33 albertel 91: #&Apache::lonxml::debug("M is ends with:$currentstring:");
92: } elsif ($target eq 'tex') {
1.73 albertel 93: $currentstring = &Apache::lonxml::get_all_text_unbalanced("/m",$parser);
1.83 sakharuk 94: if ($currentstring=~/^(\s*\\\\\s*)*$/) {$currentstring = ' \vskip 0 mm ';}
1.73 albertel 95: } else {
96: my $inside = &Apache::lonxml::get_all_text_unbalanced("/m",$parser);
1.33 albertel 97: }
98: return $currentstring;
99: }
100: sub end_m {
101: my ($target,$token) = @_;
102: my $currentstring = '';
103: if ($target eq 'web') {
1.61 albertel 104: $Apache::lonxml::prevent_entity_encode--;
1.33 albertel 105: } elsif ($target eq 'tex') {
106: $currentstring = "";
107: } elsif ($target eq 'meta') {
108: }
109: return $currentstring;
110: }
1.35 sakharuk 111: #-- <html> tag
1.1 sakharuk 112: sub start_html {
113: my ($target,$token) = @_;
1.41 sakharuk 114: my $currentstring = '';
1.39 albertel 115: if ($ENV{'browser.mathml'}) {
116: &tth::ttminit();
117: } else {
118: &tth::tthinit();
119: }
1.1 sakharuk 120: if ($target eq 'web') {
1.29 www 121: $currentstring = &Apache::lonxml::xmlbegin().
122: &Apache::lonxml::fontsettings();
1.35 sakharuk 123: } elsif ($target eq 'tex') {
1.53 sakharuk 124: @Apache::londefdef::table = ();
1.35 sakharuk 125: $currentstring .= '\documentclass[letterpaper]{article}
1.77 sakharuk 126: \newcommand{\keephidden}[1]{}
127: \renewcommand{\deg}{$^{\circ}$}
1.44 sakharuk 128: \usepackage[dvips]{graphicx}
1.86 ! sakharuk 129: \usepackage{epsfig}\usepackage{calc}
! 130: \newenvironment{choicelist}{\begin{enumerate}}{\end{enumerate}}';
1.35 sakharuk 131: }
1.1 sakharuk 132: return $currentstring;
133: }
134: sub end_html {
135: my ($target,$token) = @_;
136: my $currentstring = '';
137: if ($target eq 'web') {
1.28 www 138: $currentstring = &Apache::lonxml::xmlend();
1.35 sakharuk 139: }
1.1 sakharuk 140: return $currentstring;
141: }
1.35 sakharuk 142: #-- <head> tag
1.1 sakharuk 143: sub start_head {
144: my ($target,$token) = @_;
145: my $currentstring = '';
146: if ($target eq 'web') {
147: $currentstring = $token->[4];
148: }
149: return $currentstring;
150: }
151: sub end_head {
152: my ($target,$token) = @_;
153: my $currentstring = '';
154: if ($target eq 'web') {
1.47 matthew 155: $currentstring = &Apache::lonxml::registerurl(undef,$target).
1.29 www 156: $token->[2];
1.1 sakharuk 157: }
158: return $currentstring;
159: }
1.35 sakharuk 160: #-- <map> tag
1.1 sakharuk 161: sub start_map {
162: my ($target,$token) = @_;
163: my $currentstring = '';
164: if ($target eq 'web') {
165: $currentstring = $token->[4];
166: }
167: return $currentstring;
168: }
169: sub end_map {
170: my ($target,$token) = @_;
171: my $currentstring = '';
172: if ($target eq 'web') {
173: $currentstring = $token->[2];
174: }
175: return $currentstring;
176: }
1.35 sakharuk 177: #-- <select> tag
1.1 sakharuk 178: sub start_select {
179: my ($target,$token) = @_;
180: my $currentstring = '';
181: if ($target eq 'web') {
182: $currentstring = $token->[4];
183: }
184: return $currentstring;
185: }
186: sub end_select {
187: my ($target,$token) = @_;
188: my $currentstring = '';
189: if ($target eq 'web') {
190: $currentstring = $token->[2];
191: }
192: return $currentstring;
193: }
1.35 sakharuk 194: #-- <option> tag
1.1 sakharuk 195: sub start_option {
196: my ($target,$token) = @_;
197: my $currentstring = '';
198: if ($target eq 'web') {
199: $currentstring = $token->[4];
200: }
201: return $currentstring;
202: }
203: sub end_option {
204: my ($target,$token) = @_;
205: my $currentstring = '';
206: if ($target eq 'web') {
207: $currentstring = $token->[2];
208: }
209: return $currentstring;
210: }
1.35 sakharuk 211: #-- <input> tag
1.1 sakharuk 212: sub start_input {
213: my ($target,$token) = @_;
214: my $currentstring = '';
215: if ($target eq 'web') {
216: $currentstring = $token->[4];
217: }
218: return $currentstring;
219: }
220: sub end_input {
221: my ($target,$token) = @_;
222: my $currentstring = '';
223: if ($target eq 'web') {
224: $currentstring = $token->[2];
225: }
226: return $currentstring;
227: }
1.35 sakharuk 228: #-- <textarea> tag
1.1 sakharuk 229: sub start_textarea {
230: my ($target,$token) = @_;
231: my $currentstring = '';
232: if ($target eq 'web') {
233: $currentstring = $token->[4];
234: }
235: return $currentstring;
236: }
237: sub end_textarea {
238: my ($target,$token) = @_;
239: my $currentstring = '';
240: if ($target eq 'web') {
241: $currentstring = $token->[2];
242: }
243: return $currentstring;
244: }
1.35 sakharuk 245: #-- <form> tag
1.1 sakharuk 246: sub start_form {
247: my ($target,$token) = @_;
248: my $currentstring = '';
249: if ($target eq 'web') {
250: $currentstring = $token->[4];
251: }
252: return $currentstring;
253: }
254: sub end_form {
255: my ($target,$token) = @_;
256: my $currentstring = '';
257: if ($target eq 'web') {
258: $currentstring = $token->[2];
259: }
260: return $currentstring;
261: }
1.35 sakharuk 262: #-- <title> tag
1.1 sakharuk 263: sub start_title {
264: my ($target,$token) = @_;
265: my $currentstring = '';
266: if ($target eq 'web') {
267: $currentstring = $token->[4];
1.35 sakharuk 268: } elsif ($target eq 'tex') {
269: $currentstring .= '\keephidden{'
1.1 sakharuk 270: }
1.13 www 271: if ($target eq 'meta') {
272: $currentstring='<title>';
273: &start_output();
274: }
1.1 sakharuk 275: return $currentstring;
276: }
277: sub end_title {
278: my ($target,$token) = @_;
279: my $currentstring = '';
280: if ($target eq 'web') {
281: $currentstring = $token->[2];
1.35 sakharuk 282: } elsif ($target eq 'tex') {
283: $currentstring .= '}';
284: }
1.13 www 285: if ($target eq 'meta') {
286: &end_output();
287: $currentstring='</title>';
1.1 sakharuk 288: }
289: return $currentstring;
290: }
1.35 sakharuk 291: #-- <meta> tag
1.1 sakharuk 292: sub start_meta {
1.30 albertel 293: my ($target,$token,$tagstack,$parstack,$parser) = @_;
1.1 sakharuk 294: my $currentstring = '';
295: if ($target eq 'web') {
1.25 albertel 296: my $args='';
297: if ( $#$parstack > -1 ) { $args=$$parstack[$#$parstack]; }
298: if ($args eq '') {
299: &Apache::lonxml::get_all_text("/meta",$$parser[$#$parser]);
300: } else {
301: $currentstring = $token->[4];
302: }
1.12 www 303: }
304: if ($target eq 'meta') {
305: unless ($token->[2]->{'http-equiv'}) {
306: my $name=$token->[2]->{'name'};
307: $name=~tr/A-Z/a-z/;
308: $name=~s/\s/\_/g;
309: if ($name) {
310: $currentstring='<'.$name.'>'.
311: $token->[2]->{'content'}.
312: '</'.$name.'>';
313: }
314: }
1.1 sakharuk 315: }
316: return $currentstring;
317: }
1.26 albertel 318: sub end_meta {
1.30 albertel 319: my ($target,$token,$tagstack,$parstack,$parser) = @_;
1.26 albertel 320: my $currentstring = '';
321: if ($target eq 'web') {
322: my $args='';
323: if ( $#$parstack > -1 ) { $args=$$parstack[$#$parstack]; }
324: if ($args ne '') {
325: $currentstring = $token->[4];
326: }
327: }
328: return $currentstring;
329: }
1.35 sakharuk 330: #-- <body> tag
1.1 sakharuk 331: sub start_body {
1.41 sakharuk 332: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
333: # my ($target,$token) = @_;
1.1 sakharuk 334: my $currentstring = '';
335: if ($target eq 'web') {
1.31 albertel 336: if (!$Apache::lonxml::registered) {
1.47 matthew 337: $currentstring.='<head>'.
338: &Apache::lonxml::registerurl(undef,$target).'</head>';
1.31 albertel 339: }
1.32 albertel 340: my $onLoad='';
341: foreach my $key (keys(%{$token->[2]})) {
342: if ($key =~ /^onload$/i) {
343: $onLoad.=$token->[2]->{$key}.';';
344: delete($token->[2]->{$key});
345: }
346: }
1.56 albertel 347: $token->[2]->{'onLoad'}=&Apache::lonxml::loadevents().
348: ';'.$onLoad;
1.32 albertel 349: my $onUnload='';
350: foreach my $key (keys(%{$token->[2]})) {
351: if ($key =~ /^onunload$/i) {
352: $onUnload.=$token->[2]->{$key}.';';
353: delete($token->[2]->{$key});
354: }
355: }
1.56 albertel 356: $token->[2]->{'onUnload'}=&Apache::lonxml::unloadevents().
357: ';'.$onUnload;
1.31 albertel 358:
359: $currentstring .= '<'.$token->[1];
1.37 albertel 360: foreach (keys %{$token->[2]}) {
361: $currentstring.=' '.$_.'="'.$token->[2]->{$_}.'"';
362: }
1.31 albertel 363: $currentstring.='>';
1.40 albertel 364: if ($ENV{'request.state'} ne 'published') {
365: $currentstring.=(<<EDITBUTTON);
366: <form method="post">
1.49 albertel 367: <input type="submit" name="editmode" value="Edit" />
1.40 albertel 368: </form>
369: EDITBUTTON
370: }
1.28 www 371: } elsif ($target eq 'tex') {
1.35 sakharuk 372: $currentstring = '\begin{document}';
1.1 sakharuk 373: }
374: return $currentstring;
375: }
376: sub end_body {
377: my ($target,$token) = @_;
378: my $currentstring = '';
379: if ($target eq 'web') {
380: $currentstring = $token->[2];
381: } elsif ($target eq 'tex') {
1.35 sakharuk 382: $currentstring = '\end{document}';
1.1 sakharuk 383: }
384: return $currentstring;
385: }
1.35 sakharuk 386: #-- <center> tag
1.1 sakharuk 387: sub start_center {
388: my ($target,$token) = @_;
389: my $currentstring = '';
390: if ($target eq 'web') {
391: $currentstring = $token->[4];
392: } elsif ($target eq 'tex') {
1.35 sakharuk 393: $currentstring = '\begin{center}';
1.18 sakharuk 394: } elsif ($target eq 'latexsource') {
1.35 sakharuk 395: $currentstring = '\begin{center}';
1.1 sakharuk 396: }
397: return $currentstring;
398: }
399: sub end_center {
400: my ($target,$token) = @_;
401: my $currentstring = '';
402: if ($target eq 'web') {
403: $currentstring = $token->[2];
404: } elsif ($target eq 'tex') {
1.35 sakharuk 405: $currentstring = '\end{center}';
1.18 sakharuk 406: } elsif ($target eq 'latexsource') {
1.35 sakharuk 407: $currentstring = '\end{center}';
1.1 sakharuk 408: }
409: return $currentstring;
410: }
1.35 sakharuk 411: #-- <b> tag
1.1 sakharuk 412: sub start_b {
413: my ($target,$token) = @_;
414: my $currentstring = '';
415: if ($target eq 'web') {
416: $currentstring = $token->[4];
417: } elsif ($target eq 'tex') {
1.35 sakharuk 418: $currentstring = '\textbf{';
1.18 sakharuk 419: } elsif ($target eq 'latexsource') {
1.35 sakharuk 420: $currentstring = '\textbf{';
1.1 sakharuk 421: }
422: return $currentstring;
423: }
424: sub end_b {
425: my ($target,$token) = @_;
426: my $currentstring = '';
427: if ($target eq 'web') {
428: $currentstring = $token->[2];
429: } elsif ($target eq 'tex') {
1.35 sakharuk 430: $currentstring = '}';
431:
1.18 sakharuk 432: } elsif ($target eq 'latexsource') {
1.35 sakharuk 433: $currentstring = '}';
1.1 sakharuk 434: }
435: return $currentstring;
436: }
1.35 sakharuk 437: #-- <strong> tag
1.1 sakharuk 438: sub start_strong {
439: my ($target,$token) = @_;
440: my $currentstring = '';
441: if ($target eq 'web') {
442: $currentstring = $token->[4];
443: } elsif ($target eq 'tex') {
1.35 sakharuk 444: $currentstring = '\textbf{';
1.18 sakharuk 445: } elsif ($target eq 'latexsource') {
1.35 sakharuk 446: $currentstring = '\textbf{';
1.1 sakharuk 447: }
448: return $currentstring;
449: }
450: sub end_strong {
451: my ($target,$token) = @_;
452: my $currentstring = '';
453: if ($target eq 'web') {
454:
455: $currentstring = $token->[2];
456: } elsif ($target eq 'tex') {
1.35 sakharuk 457: $currentstring = '}';
1.18 sakharuk 458: } elsif ($target eq 'latexsource') {
1.35 sakharuk 459: $currentstring = '}';
1.1 sakharuk 460: }
461: return $currentstring;
462: }
1.35 sakharuk 463: #-- <h1> tag
1.1 sakharuk 464: sub start_h1 {
465: my ($target,$token) = @_;
466: my $currentstring = '';
467: if ($target eq 'web') {
468: $currentstring .= $token->[4];
469: } elsif ($target eq 'tex') {
1.35 sakharuk 470: $currentstring .= '\large{\textbf{';
1.13 www 471: } elsif ($target eq 'meta') {
472: $currentstring='<subject>';
473: &start_output();
474: }
1.1 sakharuk 475: return $currentstring;
476: }
477: sub end_h1 {
478: my ($target,$token) = @_;
479: my $currentstring = '';
480: if ($target eq 'web') {
481: $currentstring .= $token->[2];
482: } elsif ($target eq 'tex') {
1.35 sakharuk 483: $currentstring .= '}}';
1.13 www 484: } elsif ($target eq 'meta') {
485: &end_output();
486: $currentstring='</subject>';
487: }
1.1 sakharuk 488: return $currentstring;
489: }
1.35 sakharuk 490: #-- <h2> tag
1.1 sakharuk 491: sub start_h2 {
492: my ($target,$token) = @_;
493: my $currentstring = '';
494: if ($target eq 'web') {
495: $currentstring .= $token->[4];
496: } elsif ($target eq 'tex') {
1.35 sakharuk 497: $currentstring .= '\large{\textbf{';
1.1 sakharuk 498: }
499: return $currentstring;
500: }
501: sub end_h2 {
502: my ($target,$token) = @_;
503: my $currentstring = '';
504: if ($target eq 'web') {
505: $currentstring .= $token->[2];
506: } elsif ($target eq 'tex') {
1.35 sakharuk 507: $currentstring .= '}}';
1.1 sakharuk 508: }
509: return $currentstring;
510: }
1.35 sakharuk 511: #-- <h3> tag
1.1 sakharuk 512: sub start_h3 {
513: my ($target,$token) = @_;
514: my $currentstring = '';
515: if ($target eq 'web') {
516: $currentstring .= $token->[4];
517: } elsif ($target eq 'tex') {
1.35 sakharuk 518: $currentstring .= '\large{\textbf{';
1.1 sakharuk 519: }
520: return $currentstring;
521: }
522: sub end_h3 {
523: my ($target,$token) = @_;
524: my $currentstring = '';
525: if ($target eq 'web') {
526: $currentstring .= $token->[2];
527: } elsif ($target eq 'tex') {
1.35 sakharuk 528: $currentstring .= '}}';
1.1 sakharuk 529: }
530: return $currentstring;
531: }
1.35 sakharuk 532: #-- <h4> tag
1.1 sakharuk 533: sub start_h4 {
534: my ($target,$token) = @_;
535: my $currentstring = '';
536: if ($target eq 'web') {
537: $currentstring .= $token->[4];
538: } elsif ($target eq 'tex') {
1.41 sakharuk 539: $currentstring .= '\large{\textbf{';
1.1 sakharuk 540: }
541: return $currentstring;
542: }
543: sub end_h4 {
544: my ($target,$token) = @_;
545: my $currentstring = '';
546: if ($target eq 'web') {
547: $currentstring .= $token->[2];
548: } elsif ($target eq 'tex') {
1.35 sakharuk 549: $currentstring .= '}}';
1.1 sakharuk 550: }
551: return $currentstring;
552: }
1.35 sakharuk 553: #-- <h5> tag
1.1 sakharuk 554: sub start_h5 {
555: my ($target,$token) = @_;
556: my $currentstring = '';
557: if ($target eq 'web') {
558: $currentstring .= $token->[4];
559: } elsif ($target eq 'tex') {
1.35 sakharuk 560: $currentstring .= '\large{\textbf{';
1.1 sakharuk 561: }
562: return $currentstring;
563: }
564: sub end_h5 {
565: my ($target,$token) = @_;
566: my $currentstring = '';
567: if ($target eq 'web') {
568: $currentstring .= $token->[2];
569: } elsif ($target eq 'tex') {
1.35 sakharuk 570: $currentstring .= '}}';
1.1 sakharuk 571: }
572: return $currentstring;
573: }
1.35 sakharuk 574: #-- <h6> tag
1.1 sakharuk 575: sub start_h6 {
576: my ($target,$token) = @_;
577: my $currentstring = '';
578: if ($target eq 'web') {
579: $currentstring .= $token->[4];
580: } elsif ($target eq 'tex') {
1.35 sakharuk 581: $currentstring .= '\large{\textbf{';
1.1 sakharuk 582: }
583: return $currentstring;
584: }
585: sub end_h6 {
586: my ($target,$token) = @_;
587: my $currentstring = '';
588: if ($target eq 'web') {
589: $currentstring .= $token->[2];
590: } elsif ($target eq 'tex') {
1.35 sakharuk 591: $currentstring .= '}}';
1.1 sakharuk 592: }
593: return $currentstring;
594: }
1.35 sakharuk 595: #--- <cite> tag
1.1 sakharuk 596: sub start_cite {
597: my ($target,$token) = @_;
598: my $currentstring = '';
599: if ($target eq 'web') {
600: $currentstring .= $token->[4];
601: } elsif ($target eq 'tex') {
1.18 sakharuk 602: $currentstring .= "\\textit{";
603: } elsif ($target eq 'latexsource') {
604: $currentstring .= "\\textit{";
1.1 sakharuk 605: }
606: return $currentstring;
607: }
608: sub end_cite {
609: my ($target,$token) = @_;
610: my $currentstring = '';
611: if ($target eq 'web') {
612: $currentstring .= $token->[2];
613: } elsif ($target eq 'tex') {
614: $currentstring .= "}";
1.18 sakharuk 615: } elsif ($target eq 'latexsource') {
616: $currentstring .= "}";
1.1 sakharuk 617: }
618: return $currentstring;
619: }
1.35 sakharuk 620: #-- <i> tag
1.1 sakharuk 621: sub start_i {
622: my ($target,$token) = @_;
623: my $currentstring = '';
624: if ($target eq 'web') {
625: $currentstring .= $token->[4];
626: } elsif ($target eq 'tex') {
1.35 sakharuk 627: $currentstring .= '\textit{';
1.18 sakharuk 628: } elsif ($target eq 'latexsource') {
1.35 sakharuk 629: $currentstring .= '\textit{';
1.1 sakharuk 630: }
631: return $currentstring;
632: }
633: sub end_i {
634: my ($target,$token) = @_;
635: my $currentstring = '';
636: if ($target eq 'web') {
637: $currentstring .= $token->[2];
638: } elsif ($target eq 'tex') {
1.35 sakharuk 639: $currentstring .= '}';
1.18 sakharuk 640: } elsif ($target eq 'latexsource') {
1.35 sakharuk 641: $currentstring .= '}';
1.1 sakharuk 642: }
643: return $currentstring;
644: }
1.35 sakharuk 645: #-- <address> tag
1.1 sakharuk 646: sub start_address {
647: my ($target,$token) = @_;
648: my $currentstring = '';
649: if ($target eq 'web') {
650: $currentstring .= $token->[4];
651: } elsif ($target eq 'tex') {
1.18 sakharuk 652: $currentstring .= "\\textit{";
653: } elsif ($target eq 'latexsource') {
654: $currentstring .= "\\textit{";
1.1 sakharuk 655: }
656: return $currentstring;
657: }
658: sub end_address {
659: my ($target,$token) = @_;
660: my $currentstring = '';
661: if ($target eq 'web') {
662: $currentstring .= $token->[2];
663: } elsif ($target eq 'tex') {
664: $currentstring .= "}";
1.18 sakharuk 665: } elsif ($target eq 'latexsource') {
666: $currentstring .= "}";
1.1 sakharuk 667: }
668: return $currentstring;
669: }
1.35 sakharuk 670: #-- <dfn> tag
1.1 sakharuk 671: sub start_dfn {
672: my ($target,$token) = @_;
673: my $currentstring = '';
674: if ($target eq 'web') {
675: $currentstring .= $token->[4];
676: } elsif ($target eq 'tex') {
1.18 sakharuk 677: $currentstring .= "\\textit{";
678: } elsif ($target eq 'latexsource') {
679: $currentstring .= "\\textit{";
1.1 sakharuk 680: }
681: return $currentstring;
682: }
683: sub end_dfn {
684: my ($target,$token) = @_;
685: my $currentstring = '';
686: if ($target eq 'web') {
687: $currentstring .= $token->[2];
688: } elsif ($target eq 'tex') {
689: $currentstring .= "}";
1.18 sakharuk 690: } elsif ($target eq 'latexsource') {
691: $currentstring .= "}";
1.1 sakharuk 692: }
693: return $currentstring;
694: }
1.35 sakharuk 695: #-- <tt> tag
1.1 sakharuk 696: sub start_tt {
697: my ($target,$token) = @_;
698: my $currentstring = '';
699: if ($target eq 'web') {
700: $currentstring .= $token->[4];
701: } elsif ($target eq 'tex') {
1.35 sakharuk 702: $currentstring .= '\texttt{';
1.18 sakharuk 703: } elsif ($target eq 'latexsource') {
1.35 sakharuk 704: $currentstring .= '\texttt{';
1.1 sakharuk 705: }
706: return $currentstring;
707: }
708: sub end_tt {
709: my ($target,$token) = @_;
710: my $currentstring = '';
711: if ($target eq 'web') {
712: $currentstring .= $token->[2];
713: } elsif ($target eq 'tex') {
1.35 sakharuk 714: $currentstring .= '}';
1.18 sakharuk 715: } elsif ($target eq 'latexsource') {
1.35 sakharuk 716: $currentstring .= '}';
1.18 sakharuk 717: }
1.1 sakharuk 718: return $currentstring;
719: }
1.35 sakharuk 720: #-- <kbd> tag
1.1 sakharuk 721: sub start_kbd {
722: my ($target,$token) = @_;
723: my $currentstring = '';
724: if ($target eq 'web') {
725: $currentstring .= $token->[4];
726: } elsif ($target eq 'tex') {
1.18 sakharuk 727: $currentstring .= "\\texttt";
728: } elsif ($target eq 'latexsource') {
729: $currentstring .= "\\texttt{";
1.1 sakharuk 730: }
731: return $currentstring;
732: }
733: sub end_kbd {
734: my ($target,$token) = @_;
735: my $currentstring = '';
736: if ($target eq 'web') {
737: $currentstring .= $token->[2];
738: } elsif ($target eq 'tex') {
739: $currentstring .= "}";
1.18 sakharuk 740: } elsif ($target eq 'latexsource') {
741: $currentstring .= "}";
1.1 sakharuk 742: }
743: return $currentstring;
744: }
1.35 sakharuk 745: #-- <code> tag
1.1 sakharuk 746: sub start_code {
747: my ($target,$token) = @_;
748: my $currentstring = '';
749: if ($target eq 'web') {
750: $currentstring .= $token->[4];
751: } elsif ($target eq 'tex') {
1.35 sakharuk 752: $currentstring .= '\texttt{';
1.1 sakharuk 753: }
754: return $currentstring;
755: }
756: sub end_code {
757: my ($target,$token) = @_;
758: my $currentstring = '';
759: if ($target eq 'web') {
760: $currentstring .= $token->[2];
761: } elsif ($target eq 'tex') {
1.35 sakharuk 762: $currentstring .= '}';
1.1 sakharuk 763: }
764: return $currentstring;
765: }
1.35 sakharuk 766: #-- <em> tag
1.1 sakharuk 767: sub start_em {
768: my ($target,$token) = @_;
769: my $currentstring = '';
770: if ($target eq 'web') {
771: $currentstring .= $token->[4];
772: } elsif ($target eq 'tex') {
1.35 sakharuk 773: $currentstring .= '\emph{';
1.18 sakharuk 774: } elsif ($target eq 'latexsource') {
1.35 sakharuk 775: $currentstring .= '\emph{';
1.1 sakharuk 776: }
777: return $currentstring;
778: }
779: sub end_em {
780: my ($target,$token) = @_;
781: my $currentstring = '';
782: if ($target eq 'web') {
783: $currentstring .= $token->[2];
784: } elsif ($target eq 'tex') {
1.35 sakharuk 785: $currentstring .= '}';
1.18 sakharuk 786: } elsif ($target eq 'latexsource') {
1.35 sakharuk 787: $currentstring .= '}';
1.18 sakharuk 788: }
1.1 sakharuk 789: return $currentstring;
790: }
1.35 sakharuk 791: #-- <q> tag
1.1 sakharuk 792: sub start_q {
793: my ($target,$token) = @_;
794: my $currentstring = '';
795: if ($target eq 'web') {
796: $currentstring .= $token->[4];
797: } elsif ($target eq 'tex') {
1.18 sakharuk 798: $currentstring .= "\\emph{";
799: } elsif ($target eq 'latexsource') {
800: $currentstring .= "\\emph{";
801: }
1.1 sakharuk 802: return $currentstring;
803: }
804: sub end_q {
805: my ($target,$token) = @_;
806: my $currentstring = '';
807: if ($target eq 'web') {
808: $currentstring .= $token->[2];
809: } elsif ($target eq 'tex') {
810: $currentstring .= "}";
1.18 sakharuk 811: } elsif ($target eq 'latexsource') {
812: $currentstring .= "}";
813: }
1.1 sakharuk 814: return $currentstring;
815: }
1.35 sakharuk 816: #-- <p> tag
1.1 sakharuk 817: sub start_p {
818: my ($target,$token) = @_;
819: my $currentstring = '';
820: if ($target eq 'web') {
821: $currentstring .= $token->[4];
822: } elsif ($target eq 'tex') {
1.35 sakharuk 823: $currentstring .= '{\par ';
1.18 sakharuk 824: } elsif ($target eq 'latexsource') {
1.35 sakharuk 825: $currentstring .= '{\par ';
1.1 sakharuk 826: }
827: return $currentstring;
828: }
829: sub end_p {
830: my ($target,$token) = @_;
831: my $currentstring = '';
832: if ($target eq 'web') {
833: $currentstring .= $token->[2];
834: } elsif ($target eq 'tex') {
1.35 sakharuk 835: $currentstring .= '}';
1.18 sakharuk 836: } elsif ($target eq 'latexsource') {
1.35 sakharuk 837: $currentstring .= '}';
1.1 sakharuk 838: }
839: return $currentstring;
840: }
1.35 sakharuk 841: #-- <br> tag
1.1 sakharuk 842: sub start_br {
1.75 sakharuk 843: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1.1 sakharuk 844: my $currentstring = '';
845: if ($target eq 'web') {
846: $currentstring .= $token->[4];
847: } elsif ($target eq 'tex') {
1.76 sakharuk 848: if ($$tagstack[-2] ne 'sub' && $$tagstack[-2] ne 'sup') {
1.75 sakharuk 849: $currentstring .= '\vskip 0 mm';
850: }
1.18 sakharuk 851: } elsif ($target eq 'latexsource') {
1.35 sakharuk 852: $currentstring .= '\\';
1.1 sakharuk 853: }
854: return $currentstring;
855: }
856: sub end_br {
857: my ($target,$token) = @_;
858: my $currentstring = '';
859: if ($target eq 'web') {
860: $currentstring .= $token->[2];
861: }
862: return $currentstring;
863: }
1.35 sakharuk 864: #-- <big> tag
1.1 sakharuk 865: sub start_big {
866: my ($target,$token) = @_;
867: my $currentstring = '';
868: if ($target eq 'web') {
869: $currentstring .= $token->[4];
870: } elsif ($target eq 'tex') {
1.36 albertel 871: $currentstring .= '\large{';
1.18 sakharuk 872: } elsif ($target eq 'latexsource') {
1.41 sakharuk 873: $currentstring .= '{\Large ';
1.18 sakharuk 874: }
1.1 sakharuk 875: return $currentstring;
876: }
877: sub end_big {
878: my ($target,$token) = @_;
879: my $currentstring = '';
880: if ($target eq 'web') {
881: $currentstring .= $token->[2];
882: } elsif ($target eq 'tex') {
1.35 sakharuk 883: $currentstring .= '}';
1.18 sakharuk 884: } elsif ($target eq 'latexsource') {
1.35 sakharuk 885: $currentstring .= '}';
1.1 sakharuk 886: }
887: return $currentstring;
888: }
1.35 sakharuk 889: #-- <small> tag
1.1 sakharuk 890: sub start_small {
891: my ($target,$token) = @_;
892: my $currentstring = '';
893: if ($target eq 'web') {
894: $currentstring .= $token->[4];
895: } elsif ($target eq 'tex') {
1.41 sakharuk 896: $currentstring .= '{\footnotesize ';
1.18 sakharuk 897: } elsif ($target eq 'latexsource') {
1.41 sakharuk 898: $currentstring .= '{\footnotesize ';
1.1 sakharuk 899: }
900: return $currentstring;
901: }
902: sub end_small {
903: my ($target,$token) = @_;
904: my $currentstring = '';
905: if ($target eq 'web') {
906: $currentstring .= $token->[2];
907: } elsif ($target eq 'tex') {
1.35 sakharuk 908: $currentstring .= '}';
1.18 sakharuk 909: } elsif ($target eq 'latexsource') {
1.35 sakharuk 910: $currentstring .= '}';
1.1 sakharuk 911: }
912: return $currentstring;
913: }
1.35 sakharuk 914: #-- <basefont> tag
1.1 sakharuk 915: sub start_basefont {
1.14 albertel 916: my ($target,$token) = @_;
917: my $currentstring = '';
918: if ($target eq 'web') {
919: $currentstring = $token->[4];
920: }
921: return $currentstring;
922: }
923: sub end_basefont {
924: my ($target,$token) = @_;
925: my $currentstring = '';
926: if ($target eq 'web') {
927: $currentstring = $token->[4];
928: }
929: return $currentstring;
930: }
1.35 sakharuk 931: #-- <font> tag
1.1 sakharuk 932: sub start_font {
1.61 albertel 933: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1.1 sakharuk 934: my $currentstring = '';
935: if ($target eq 'web') {
1.61 albertel 936: my $face=&Apache::lonxml::get_param('face',$parstack,$safeeval);
937: if ($face=~/symbol/i) {$Apache::lonxml::prevent_entity_encode++;}
1.1 sakharuk 938: $currentstring = $token->[4];
939: }
940: return $currentstring;
941: }
942: sub end_font {
1.61 albertel 943: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1.1 sakharuk 944: my $currentstring = '';
945: if ($target eq 'web') {
1.61 albertel 946: my $face=&Apache::lonxml::get_param('face',$parstack,$safeeval);
947: if ($face=~/symbol/i) {$Apache::lonxml::prevent_entity_encode--;}
1.1 sakharuk 948: $currentstring = $token->[2];
949: }
950: return $currentstring;
951: }
1.35 sakharuk 952: #-- <strike> tag
1.1 sakharuk 953: sub start_strike {
954: my ($target,$token) = @_;
955: my $currentstring = '';
956: if ($target eq 'web') {
957: $currentstring .= $token->[4];
958: } elsif ($target eq 'tex') {
1.76 sakharuk 959: $currentstring .= '\underline{';
1.1 sakharuk 960: }
961: return $currentstring;
962: }
963: sub end_strike {
964: my ($target,$token) = @_;
965: my $currentstring = '';
966: if ($target eq 'web') {
967: $currentstring .= $token->[2];
968: } elsif ($target eq 'tex') {
1.76 sakharuk 969: $currentstring .= '}';
1.1 sakharuk 970: }
971: return $currentstring;
972: }
1.35 sakharuk 973: #-- <s> tag
1.1 sakharuk 974: sub start_s {
975: my ($target,$token) = @_;
976: my $currentstring = '';
977: if ($target eq 'web') {
978: $currentstring .= $token->[4];
979: } elsif ($target eq 'tex') {
1.76 sakharuk 980: $currentstring .= '\underline{';
1.1 sakharuk 981: }
982: return $currentstring;
983: }
984: sub end_s {
985: my ($target,$token) = @_;
986: my $currentstring = '';
987: if ($target eq 'web') {
988: $currentstring .= $token->[2];
989: } elsif ($target eq 'tex') {
1.76 sakharuk 990: $currentstring .= '}';
1.1 sakharuk 991: }
992: return $currentstring;
993: }
1.35 sakharuk 994: #-- <sub> tag
1.1 sakharuk 995: sub start_sub {
996: my ($target,$token) = @_;
997: my $currentstring = '';
998: if ($target eq 'web') {
999: $currentstring .= $token->[4];
1000: } elsif ($target eq 'tex') {
1001: $currentstring .= "\$_{ ";
1002: }
1003: return $currentstring;
1004: }
1005: sub end_sub {
1006: my ($target,$token) = @_;
1007: my $currentstring = '';
1008: if ($target eq 'web') {
1009: $currentstring .= $token->[2];
1010: } elsif ($target eq 'tex') {
1011: $currentstring .= " }\$";
1012: }
1013: return $currentstring;
1014: }
1.35 sakharuk 1015: #-- <sup> tag
1.1 sakharuk 1016: sub start_sup {
1017: my ($target,$token) = @_;
1018: my $currentstring = '';
1019: if ($target eq 'web') {
1020: $currentstring .= $token->[4];
1021: } elsif ($target eq 'tex') {
1022: $currentstring .= "\$^{ ";
1023: }
1024: return $currentstring;
1025: }
1026: sub end_sup {
1027: my ($target,$token) = @_;
1028: my $currentstring = '';
1029: if ($target eq 'web') {
1030: $currentstring .= $token->[2];
1031: } elsif ($target eq 'tex') {
1032: $currentstring .= " }\$";
1033: }
1034: return $currentstring;
1035: }
1.35 sakharuk 1036: #-- <hr> tag
1.1 sakharuk 1037: sub start_hr {
1038: my ($target,$token) = @_;
1039: my $currentstring = '';
1040: if ($target eq 'web') {
1041: $currentstring .= $token->[4];
1042: } elsif ($target eq 'tex') {
1.85 sakharuk 1043: $currentstring .= '\vskip 0 mm \noindent\makebox[\textwidth/2 ][b]{\hrulefill}\vskip 0 mm ';
1.6 sakharuk 1044: }
1045: return $currentstring;
1046: }
1047: sub end_hr {
1048: my ($target,$token) = @_;
1049: my $currentstring = '';
1050: if ($target eq 'web') {
1051: $currentstring .= $token->[2];
1052: } elsif ($target eq 'tex') {
1.85 sakharuk 1053: }
1054: return $currentstring;
1055: }
1056: #-- <div> tag
1057: sub start_div {
1058: my ($target,$token) = @_;
1059: my $currentstring = '';
1060: if ($target eq 'web') {
1061: $currentstring .= $token->[4];
1062: }
1063: return $currentstring;
1064: }
1065: sub end_div {
1066: my ($target,$token) = @_;
1067: my $currentstring = '';
1068: if ($target eq 'web') {
1069: $currentstring .= $token->[2];
1.1 sakharuk 1070: }
1071: return $currentstring;
1072: }
1.35 sakharuk 1073: #-- <a> tag
1.1 sakharuk 1074: sub start_a {
1075: my ($target,$token) = @_;
1076: my $currentstring = '';
1077: if ($target eq 'web') {
1078: $currentstring .= $token->[4];
1079: } elsif ($target eq 'tex') {
1080: }
1081: return $currentstring;
1082: }
1083: sub end_a {
1.30 albertel 1084: my ($target,$token,$tagstack,$stackref) = @_;
1.1 sakharuk 1085: my $currentstring = '';
1086: if ($target eq 'web') {
1087: $currentstring .= $token->[2];
1088: } elsif ($target eq 'tex') {
1089: my $tempor_var = $stackref->[$#$stackref];
1090: if (index($tempor_var,'name') != -1 ) {
1091: $tempor_var =~ s/name=([^,]*),/$1/g;
1.15 sakharuk 1092: # $currentstring .= " \\label{$tempor_var}";
1.1 sakharuk 1093: } elsif (index($tempor_var,'href') != -1 ) {
1094: $tempor_var =~ s/href=([^,]*),/$1/g;
1095: $currentstring .= " \\ref{$tempor_var}";
1096: }
1097: }
1098: return $currentstring;
1099: }
1.35 sakharuk 1100: #-- <li> tag
1.1 sakharuk 1101: sub start_li {
1.30 albertel 1102: my ($target,$token,$tagstack,$stackref) = @_;
1.1 sakharuk 1103: my $currentstring = '';
1104: if ($target eq 'web') {
1105: $currentstring = $token->[4];
1106: } elsif ($target eq 'tex') {
1.15 sakharuk 1107: my $tempor_var = $stackref->[$#$stackref];
1.1 sakharuk 1108: if (index($tempor_var,'circle') != -1 ) {
1109: $currentstring .= " \\item[o] ";
1110: } elsif (index($tempor_var,'square') != -1 ) {
1111: $currentstring .= " \\item[$\Box$] ";
1.15 sakharuk 1112: } elsif ($tempor_var ne '') {
1113: $_ = $tempor_var;
1114: m/my\s*([^=]*)=/;
1115: $currentstring .= " \\item[$1] ";
1116: } else {
1.1 sakharuk 1117: $currentstring .= " \\item ";
1118: }
1119: }
1120: return $currentstring;
1121: }
1122: sub end_li {
1123: my ($target,$token) = @_;
1124: my $currentstring = '';
1125: if ($target eq 'web') {
1126: $currentstring = $token->[2];
1127: }
1128: return $currentstring;
1129: }
1.35 sakharuk 1130: #-- <u> tag
1.1 sakharuk 1131: sub start_u {
1132: my ($target,$token) = @_;
1133: my $currentstring = '';
1134: if ($target eq 'web') {
1135: $currentstring .= $token->[4];
1136: } elsif ($target eq 'tex') {
1.76 sakharuk 1137: $currentstring .= '\underline{';
1.1 sakharuk 1138: }
1139: return $currentstring;
1140: }
1141: sub end_u {
1142: my ($target,$token) = @_;
1143: my $currentstring = '';
1144: if ($target eq 'web') {
1145: $currentstring .= $token->[2];
1146: } elsif ($target eq 'tex') {
1.76 sakharuk 1147: $currentstring .= '}';
1.1 sakharuk 1148: }
1149: return $currentstring;
1150: }
1.35 sakharuk 1151: #-- <ul> tag
1.1 sakharuk 1152: sub start_ul {
1153: my ($target,$token) = @_;
1154: my $currentstring = '';
1155: if ($target eq 'web') {
1156: $currentstring = $token->[4];
1157: } elsif ($target eq 'tex') {
1.41 sakharuk 1158: $currentstring = '\begin{itemize}';
1.1 sakharuk 1159: }
1160: return $currentstring;
1161: }
1162: sub end_ul {
1163: my ($target,$token) = @_;
1164: my $currentstring = '';
1165: if ($target eq 'web') {
1166: $currentstring = $token->[2];
1167: } elsif ($target eq 'tex') {
1.41 sakharuk 1168: $currentstring = '\end{itemize}';
1.1 sakharuk 1169: }
1170: return $currentstring;
1171: }
1.35 sakharuk 1172: #-- <menu> tag
1.1 sakharuk 1173: sub start_menu {
1174: my ($target,$token) = @_;
1175: my $currentstring = '';
1176: if ($target eq 'web') {
1177: $currentstring = $token->[4];
1178: } elsif ($target eq 'tex') {
1179: $currentstring = " \\begin{itemize} ";
1180: }
1181: return $currentstring;
1182: }
1183: sub end_menu {
1184: my ($target,$token) = @_;
1185: my $currentstring = '';
1186: if ($target eq 'web') {
1187: $currentstring = $token->[2];
1188: } elsif ($target eq 'tex') {
1189: $currentstring = " \\end{itemize}";
1190: }
1191: return $currentstring;
1192: }
1.35 sakharuk 1193: #-- <dir> tag
1.1 sakharuk 1194: sub start_dir {
1195: my ($target,$token) = @_;
1196: my $currentstring = '';
1197: if ($target eq 'web') {
1198: $currentstring = $token->[4];
1199: } elsif ($target eq 'tex') {
1200: $currentstring = " \\begin{itemize} ";
1201: }
1202: return $currentstring;
1203: }
1204: sub end_dir {
1205: my ($target,$token) = @_;
1206: my $currentstring = '';
1207: if ($target eq 'web') {
1208: $currentstring = $token->[2];
1209: } elsif ($target eq 'tex') {
1210: $currentstring = " \\end{itemize}";
1211: }
1212: return $currentstring;
1213: }
1.35 sakharuk 1214: #-- <ol> tag
1.1 sakharuk 1215: sub start_ol {
1216: my ($target,$token) = @_;
1217: my $currentstring = '';
1218: if ($target eq 'web') {
1219: $currentstring = $token->[4];
1220: } elsif ($target eq 'tex') {
1.41 sakharuk 1221: $currentstring = '\begin{enumerate}';
1.1 sakharuk 1222: }
1223: return $currentstring;
1224: }
1225: sub end_ol {
1226: my ($target,$token) = @_;
1227: my $currentstring = '';
1228: if ($target eq 'web') {
1229: $currentstring = $token->[2];
1230: } elsif ($target eq 'tex') {
1.41 sakharuk 1231: $currentstring = '\end{enumerate}';
1.1 sakharuk 1232: }
1233: return $currentstring;
1234: }
1.35 sakharuk 1235: #-- <dl> tag
1.1 sakharuk 1236: sub start_dl {
1237: my ($target,$token) = @_;
1238: my $currentstring = '';
1239: if ($target eq 'web') {
1240: $currentstring = $token->[4];
1241: } elsif ($target eq 'tex') {
1.41 sakharuk 1242: $currentstring = '\begin{description}';
1.1 sakharuk 1243: }
1244: return $currentstring;
1245: }
1246: sub end_dl {
1247: my ($target,$token) = @_;
1248: my $currentstring = '';
1249: if ($target eq 'web') {
1250: $currentstring = $token->[2];
1251: } elsif ($target eq 'tex') {
1.41 sakharuk 1252: $currentstring = '\end{description}';
1.1 sakharuk 1253: }
1254: return $currentstring;
1255: }
1.35 sakharuk 1256: #-- <dt> tag
1.1 sakharuk 1257: sub start_dt {
1258: my ($target,$token) = @_;
1259: my $currentstring = '';
1260: if ($target eq 'web') {
1261: $currentstring = $token->[4];
1262: } elsif ($target eq 'tex') {
1.41 sakharuk 1263: $currentstring = '\item[';
1.1 sakharuk 1264: }
1265: return $currentstring;
1266: }
1267: sub end_dt {
1268: my ($target,$token) = @_;
1269: my $currentstring = '';
1270: if ($target eq 'web') {
1271: $currentstring = $token->[2];
1272: } elsif ($target eq 'tex') {
1.41 sakharuk 1273: $currentstring = ']';
1.1 sakharuk 1274: }
1275: return $currentstring;
1276: }
1.35 sakharuk 1277: #-- <dd> tag
1.1 sakharuk 1278: sub start_dd {
1279: my ($target,$token) = @_;
1280: my $currentstring = '';
1281: if ($target eq 'web') {
1282: $currentstring = $token->[4];
1283: }
1284: return $currentstring;
1285: }
1286: sub end_dd {
1287: my ($target,$token) = @_;
1288: my $currentstring = '';
1289: if ($target eq 'web') {
1290: $currentstring = $token->[2];
1291: }
1292: return $currentstring;
1293: }
1.35 sakharuk 1294: #-- <table> tag
1.1 sakharuk 1295: sub start_table {
1.50 sakharuk 1296: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1.1 sakharuk 1297: my $currentstring = '';
1298: if ($target eq 'web') {
1299: $currentstring = $token->[4];
1300: } elsif ($target eq 'tex') {
1.53 sakharuk 1301: my $aa = {};
1302: push @Apache::londefdef::table, $aa;
1303: $Apache::londefdef::table[-1]{'row_number'} = -1;
1.79 sakharuk 1304: $Apache::londefdef::table[-1]{'output'} = ' \noindent \begin{tabular} ';
1.50 sakharuk 1305: my $border = &Apache::lonxml::get_param('border',$parstack,$safeeval);
1306: unless (defined $border) { $border = 0; }
1.51 sakharuk 1307: if ($border) {
1.53 sakharuk 1308: $Apache::londefdef::table[-1]{'hinc'} = '\hline ';
1309: $Apache::londefdef::table[-1]{'vinc'} = '&';
1310: $Apache::londefdef::table[-1]{'vvinc'} = '|';
1.52 sakharuk 1311: } else {
1.53 sakharuk 1312: $Apache::londefdef::table[-1]{'hinc'} = '';
1.69 sakharuk 1313: $Apache::londefdef::table[-1]{'vinc'} = '&';
1.53 sakharuk 1314: $Apache::londefdef::table[-1]{'vvinc'} = '';
1.50 sakharuk 1315: }
1.51 sakharuk 1316: }
1317: return $currentstring;
1318: }
1319: sub end_table {
1.79 sakharuk 1320: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1.51 sakharuk 1321: my $currentstring = '';
1322: if ($target eq 'web') {
1323: $currentstring = $token->[2];
1324: } elsif ($target eq 'tex') {
1.53 sakharuk 1325: my $inmemory = '';
1.52 sakharuk 1326: my $output = '';
1.79 sakharuk 1327: #construct header of the table
1.53 sakharuk 1328: my $header_of_table = '{'.$Apache::londefdef::table[-1]{'vvinc'};
1.50 sakharuk 1329: my $in;
1.53 sakharuk 1330: for ($in=0;$in<=$Apache::londefdef::table[-1]{'counter_columns'};$in++) {
1331: $header_of_table .= $Apache::londefdef::table[-1]{'columns'}[$in].$Apache::londefdef::table[-1]{'vvinc'};
1332: }
1333: $header_of_table .= '}';
1.79 sakharuk 1334: #fill the table
1.53 sakharuk 1335: for ($in=0;$in<=$Apache::londefdef::table[-1]{'row_number'};$in++) {
1336: $output .= $Apache::londefdef::table[-1]{'rowdata'}[$in];
1.52 sakharuk 1337: chop $output;
1338: $output .= ' \\\\ ';
1.50 sakharuk 1339: }
1.79 sakharuk 1340: #define the length of the table cells
1341: my @lengthforoutput = split(/,/,$Apache::londefdef::table[-1]{'lengthrow'}[0]);
1342: my $how_many_columns = $#lengthforoutput + 1;
1343: my $filled_columns = 0;
1344: foreach my $tempo_length (@{ $Apache::londefdef::table[-1]{'lengthrow'} }) {
1345: my @length = split(/,/,$tempo_length);
1.82 sakharuk 1346: my $nfilled_columns = 0;
1.79 sakharuk 1347: for (my $ico=0;$ico<$how_many_columns;$ico++) {
1.82 sakharuk 1348: if (not $lengthforoutput[$ico]=~m/\s*0\s*/) {$nfilled_columns++;}
1.79 sakharuk 1349: }
1.82 sakharuk 1350: if ($nfilled_columns > $filled_columns) {$filled_columns=$nfilled_columns;}
1.79 sakharuk 1351: }
1352: my $temp_file;
1353: my $filename = "/home/httpd/prtspool/$ENV{'user.name'}_$ENV{'user.domain'}_printout.tbl";
1354: if (-e $filename) {
1355: $temp_file = Apache::File->new($filename);
1356: my @tbl_file_content = <$temp_file>;
1357: my ($one,$two) = split(/,/,$tbl_file_content[0]);
1358: $how_many_columns+=$one-1;
1359: $filled_columns+=$two;
1360: } else {
1361: $temp_file = Apache::File->new('>>'.$filename);
1362: }
1363: print $temp_file "$how_many_columns,$filled_columns\n";
1364: foreach my $tempo_length (@{ $Apache::londefdef::table[-1]{'lengthrow'} }) {
1365: my @length = split(/,/,$tempo_length);
1366: for (my $ico=0;$ico<=$#lengthforoutput;$ico++) {
1367: $lengthforoutput[$ico] =~ m/(\d*\.?\d*)\s*(\w+)/;
1368: my $old_value = $1;
1369: my $old_unit = $2;
1370: if ($old_unit eq 'cm') {
1371: $old_value = $old_value * 10;
1372: } elsif ($old_unit eq 'in') {
1373: $old_value = $old_value * 25.4;
1374: } elsif ($old_unit eq 'pt') {
1375: $old_value = $old_value * 25.4/72.27;
1376: } elsif ($old_unit eq 'pc') {
1377: $old_value = $old_value * 25.4/6.022;
1378: }
1379: $old_unit = 'mm';
1380: $length[$ico] =~ m/(\d*\.?\d*)\s*(\w+)/;
1381: my $new_value = $1;
1382: my $new_unit = $2;
1383: if ($new_unit eq 'cm') {
1384: $new_value = $new_value * 10;
1385: } elsif ($old_unit eq 'in') {
1386: $new_value = $new_value * 25.4;
1387: } elsif ($old_unit eq 'pt') {
1388: $new_value = $new_value * 25.4/72.27;
1389: } elsif ($old_unit eq 'pc') {
1390: $new_value = $new_value * 25.4/6.022;
1391: }
1392: $new_unit = 'mm';
1393: if ($old_value < $new_value) {
1394: $lengthforoutput[$ico] = $new_value.' mm';
1395: } else {
1396: $lengthforoutput[$ico] = $old_value.' mm';
1397: }
1398: }
1399: }
1.71 sakharuk 1400: my $parboxlength = '(\textwidth';
1.79 sakharuk 1401: for (my $io=0; $io<=$#lengthforoutput;$io++) {
1402: $parboxlength .= ' - '.$lengthforoutput[$io].' ';
1.71 sakharuk 1403: }
1.82 sakharuk 1404: $parboxlength .= ')/($GLOBALnumberOFcolumns+1) - 3 mm';
1.79 sakharuk 1405: $output =~ s/\\parbox{}{}/\\parbox{1 mm}{}/g;
1406: $output =~ s/\\parbox{}{(\\textbf{\w?\.?})}/\\parbox{5 mm}{$1}/g; #for stupid tables with empty columns
1.71 sakharuk 1407: $output =~ s/\\parbox{}/\\parbox{$parboxlength}/g;
1.79 sakharuk 1408: my ($howmanyatall,$howmanyfilled) = (0,0);
1409:
1410: my @tagar = @$tagstack;
1411: my $signature = 1;
1412: for (my $ico=0;$ico<$#tagar;$ico++) {
1413: if ($tagar[$ico] eq 'table') { $signature = 0; }
1414: }
1415: if ($signature) {
1416: my $totalnumber = $how_many_columns-$filled_columns-1;
1417: $output =~ s/\$GLOBALnumberOFcolumns/$totalnumber/g;
1418: }
1.70 sakharuk 1419: $Apache::londefdef::table[-1]{'output'} .= $header_of_table.$output.$Apache::londefdef::table[-1]{'hinc'}.'\end{tabular}\vskip 0 mm ';
1.53 sakharuk 1420: if ($#Apache::londefdef::table > 0) {
1421: $inmemory = $Apache::londefdef::table[-1]{'output'};
1422: pop @Apache::londefdef::table;
1423: $Apache::londefdef::table[-1]{'rowdata'}[$Apache::londefdef::table[-1]{'row_number'}] .= $inmemory;
1424: } else {
1425: $currentstring = $Apache::londefdef::table[-1]{'output'};
1426: $currentstring =~ s/\\\\\s+\\\\/\\\\/g;
1427: pop @Apache::londefdef::table;
1.81 sakharuk 1428: if (-e $filename) {
1429: unlink $filename;
1430: }
1.53 sakharuk 1431: }
1.51 sakharuk 1432: }
1433: return $currentstring;
1434: }
1435: #-- <tr> tag
1436: sub start_tr {
1437: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1438: my $currentstring = '';
1439: if ($target eq 'web') {
1440: $currentstring = $token->[4];
1441: } elsif ($target eq 'tex') {
1.53 sakharuk 1442: $Apache::londefdef::table[-1]{'row_number'}++;
1443: my $alignchar = substr(&Apache::lonxml::get_param('align',$parstack,$safeeval),0,1);
1444: if ($alignchar ne '') {
1445: push @ {$Apache::londefdef::table[-1]{'rows'} }, $alignchar;
1.51 sakharuk 1446: } else {
1.69 sakharuk 1447: push @ {$Apache::londefdef::table[-1]{'rows'} }, 'l';
1.51 sakharuk 1448: }
1.53 sakharuk 1449: push ( @{ $Apache::londefdef::table[-1]{'rowdata'} }, $Apache::londefdef::table[-1]{'hinc'});
1450: $Apache::londefdef::table[-1]{'counter_columns'} = -1;
1.78 sakharuk 1451: $Apache::londefdef::table[-1]{'length'} = '';
1.1 sakharuk 1452: }
1453: return $currentstring;
1.51 sakharuk 1454: }
1455: sub end_tr {
1456: my ($target,$token) = @_;
1457: my $currentstring = '';
1458: if ($target eq 'web') {
1459: $currentstring = $token->[2];
1460: } elsif ($target eq 'tex') {
1.79 sakharuk 1461: # $currentstring .= ' START ROW '. $Apache::londefdef::table[-1]{'rowdata'}[$Apache::londefdef::table[-1]{'row_number'}].' END ROW ';
1462: push @{ $Apache::londefdef::table[-1]{'lengthrow'} },$Apache::londefdef::table[-1]{'length'};
1463:
1.51 sakharuk 1464: }
1465: return $currentstring;
1.1 sakharuk 1466: }
1.51 sakharuk 1467: #-- <td> tag
1468: sub start_td {
1469: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1470: my $currentstring = '';
1471: if ($target eq 'web') {
1472: $currentstring = $token->[4];
1473: } elsif ($target eq 'tex') {
1474: my $what_to_push = substr(&Apache::lonxml::get_param('align',$parstack,$safeeval),0,1);
1475: if ($what_to_push eq '') {
1.53 sakharuk 1476: $what_to_push = substr($Apache::londefdef::table[-1]{'rows'}[0],0,1);;
1.51 sakharuk 1477: }
1.53 sakharuk 1478: push @{ $Apache::londefdef::table[-1]{'columns'} }, $what_to_push;
1479: $Apache::londefdef::table[-1]{'counter_columns'}++;
1.52 sakharuk 1480: &Apache::lonxml::startredirection();
1481: ;
1.51 sakharuk 1482: }
1483: return $currentstring;
1484: }
1485: sub end_td {
1.59 sakharuk 1486: my ($target,$token) = @_;
1487: my $currentstring = '';
1.82 sakharuk 1488: my $tempolen = '';
1.59 sakharuk 1489: if ($target eq 'web') {
1490: $currentstring = $token->[2];
1491: } elsif ($target eq 'tex') {
1492: my $current_row = $Apache::londefdef::table[-1]{'row_number'};
1493: my $data=&Apache::lonxml::endredirection();
1.82 sakharuk 1494: if ($data=~m/width\s*=\s*(\d+\.*\d*\s*(mm|cm|in|pc|pt))/) {
1495: $Apache::londefdef::table[-1]{'length'} .= $1.',';
1496: $tempolen = $1;
1.78 sakharuk 1497: } else {
1.82 sakharuk 1498: if (length($data)<5) {
1499: $Apache::londefdef::table[-1]{'length'} .= '7 mm,';
1500: $tempolen = '5 mm';
1501: } else {
1502: $Apache::londefdef::table[-1]{'length'} .= '0 mm,';
1503: $tempolen = '';
1504: }
1.79 sakharuk 1505: }
1.82 sakharuk 1506: @{ $Apache::londefdef::table[-1]{'rowdata'} }[$current_row] .= '\parbox{'.$tempolen.'}{'.$data.'} '.$Apache::londefdef::table[-1]{'vinc'};
1.59 sakharuk 1507: }
1508: return $currentstring;
1509: }
1510: #-- <th> tag
1511: sub start_th {
1512: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1513: my $currentstring = '';
1514: if ($target eq 'web') {
1515: $currentstring = $token->[4];
1516: } elsif ($target eq 'tex') {
1517: my $what_to_push = substr(&Apache::lonxml::get_param('align',$parstack,$safeeval),0,1);
1518: if ($what_to_push eq '') {
1519: $what_to_push = substr($Apache::londefdef::table[-1]{'rows'}[0],0,1);;
1520: }
1521: push @{ $Apache::londefdef::table[-1]{'columns'} }, $what_to_push;
1522: $Apache::londefdef::table[-1]{'counter_columns'}++;
1523: &Apache::lonxml::startredirection();
1524: ;
1525: }
1526: return $currentstring;
1527: }
1528: sub end_th {
1.1 sakharuk 1529: my ($target,$token) = @_;
1530: my $currentstring = '';
1531: if ($target eq 'web') {
1.51 sakharuk 1532: $currentstring = $token->[2];
1533: } elsif ($target eq 'tex') {
1.53 sakharuk 1534: my $current_row = $Apache::londefdef::table[-1]{'row_number'};
1.52 sakharuk 1535: my $data=&Apache::lonxml::endredirection();
1.78 sakharuk 1536: if ($data=~m/width\s*=\s*(\d+\.*\d*\s*(mm|cm))/) {
1537: $Apache::londefdef::table[-1]{'length'} .= $1.',';
1538: } else {
1539: $Apache::londefdef::table[-1]{'length'} .= '0 mm,';
1540: }
1.72 sakharuk 1541: @{ $Apache::londefdef::table[-1]{'rowdata'} }[$current_row] .= '\parbox{'.$1.'}{\textbf{'.$data.'}} '.$Apache::londefdef::table[-1]{'vinc'};
1.44 sakharuk 1542: }
1.1 sakharuk 1543: return $currentstring;
1544: }
1.35 sakharuk 1545: #-- <img> tag
1.10 www 1546: sub start_img {
1.41 sakharuk 1547: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1.44 sakharuk 1548: $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=
1.10 www 1549: $token->[2]->{'src'};
1550: my $currentstring = '';
1.58 sakharuk 1551: my $width_param = '';
1.69 sakharuk 1552: my $height_param = '';
1.84 sakharuk 1553: my $scaling = .3;
1.44 sakharuk 1554:
1.42 albertel 1555: if ($target eq 'web') {
1.10 www 1556: $currentstring = $token->[4];
1557: } elsif ($target eq 'tex') {
1.42 albertel 1558: my $src = &Apache::lonxml::get_param('src',$parstack,$safeeval);
1.54 sakharuk 1559: $src=&Apache::lonnet::filelocation($Apache::lonxml::pwd[-1],$src);
1.84 sakharuk 1560: #if original gif/jpg file exist do following:
1561: if (-e $src) {
1562: #defines the default size of image
1.80 sakharuk 1563: my $image = Image::Magick->new;
1564: my $current_figure = $image->Read($src);
1565: $width_param = $image->Get('width') * $scaling;;
1566: $height_param = $image->Get('height') * $scaling;;
1567: undef $image;
1568: #do we have any specified size of the picture?
1569: my $TeXwidth = &Apache::lonxml::get_param('TeXwidth',$parstack,$safeeval);
1570: my $TeXheight = &Apache::lonxml::get_param('TeXheight',$parstack,$safeeval);
1571: my $width = &Apache::lonxml::get_param('width',$parstack,$safeeval);
1572: if ($TeXwidth ne '') {
1573: $width_param = $TeXwidth;
1574: } elsif ($TeXheight ne '') {
1575: $width_param = $TeXheight/$height_param*$width_param;
1576: } elsif ($width ne '') {
1577: $width_param = $width*$scaling;
1578: }
1.84 sakharuk 1579: my $file;
1580: my $path;
1581: if ($src =~ m!(.*)/([^/]*)$!) {
1582: $file = $2;
1583: $path = $1.'/';
1584: }
1585: my $newsrc = $src;
1586: $newsrc =~ s/(\.gif|\.jpg)$/\.eps/i;
1587: $file=~s/(\.gif|\.jpg)$/\.eps/i;
1.80 sakharuk 1588: #where can we find the picture?
1589: if (-e $newsrc) {
1.84 sakharuk 1590: #eps counterpart for image exist
1.80 sakharuk 1591: if ($path) {
1592: $currentstring .= '\noindent\graphicspath{{'.$path.'}}\fbox{\includegraphics[width='.$width_param.' mm]{'.$file.'}} ';
1.62 sakharuk 1593: }
1.80 sakharuk 1594: } else {
1.84 sakharuk 1595: #there is no eps counterpart for image - check for ps one
1596: $newsrc =~ s/\.eps$/\.ps/;
1597: if (-e $newsrc) {
1598: #ps counterpart for image exist
1599: $file =~ s/\.eps$/\.ps/;
1600: if ($path) {
1601: $currentstring .= '\noindent\graphicspath{{'.$path.'}}\fbox{\includegraphics[width='.$width_param.' mm]{'.$file.'}} ';
1602: }
1603: } else {
1604: #there aren't eps or ps - so create eps
1605: my $temp_file;
1606: my $filename = "/home/httpd/prtspool/$ENV{'user.name'}_$ENV{'user.domain'}_printout.dat";
1607: $temp_file = Apache::File->new('>>'.$filename);
1608: print $temp_file "$src\n";
1609: $currentstring .= '\graphicspath{{/home/httpd/prtspool/}}\fbox{\includegraphics[width='.$width_param.' mm]{'.$file.'}} ';
1610: }
1.62 sakharuk 1611: }
1.80 sakharuk 1612: } else {
1.84 sakharuk 1613: #original image file doesn't exist so check the alt attribute
1.80 sakharuk 1614: my $alt = &Apache::lonxml::get_param('alt',$parstack,$safeeval);
1615: if ($alt) {
1616: $currentstring .= ' '.$alt.' ';
1.62 sakharuk 1617: } else {
1.84 sakharuk 1618: #there are no image and alt attribute
1619: $currentstring .= ' THE ORIGINAL PROBLEM CONTAINS EMPTY IMG TAG WITHOUT IMAGE AND ALT ATTRIBUTE ';
1.57 sakharuk 1620: }
1.42 albertel 1621: }
1622: }
1623: return $currentstring;
1.10 www 1624: }
1625: sub end_img {
1626: my ($target,$token) = @_;
1627: my $currentstring = '';
1628: if ($target eq 'web') {
1.44 sakharuk 1629: $currentstring = $token->[2];
1.10 www 1630: } elsif ($target eq 'tex') {
1.44 sakharuk 1631: $currentstring = '';
1632: }
1.10 www 1633: return $currentstring;
1634: }
1.35 sakharuk 1635: #-- <applet> tag
1.10 www 1636:
1637: sub start_applet {
1638: my ($target,$token) = @_;
1639: $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=
1640: $token->[2]->{'code'};
1.44 sakharuk 1641: $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=
1.10 www 1642: $token->[2]->{'archive'};
1643: my $currentstring = '';
1644: if ($target eq 'web') {
1.44 sakharuk 1645: $currentstring = $token->[4];
1.10 www 1646: } elsif ($target eq 'tex') {
1.44 sakharuk 1647: $currentstring = " \\begin{figure} ";
1.10 www 1648: }
1649: return $currentstring;
1650: }
1.44 sakharuk 1651: sub end_applet {
1652: my ($target,$token) = @_;
1653: my $currentstring = '';
1654: if ($target eq 'web') {
1655: $currentstring = $token->[2];
1656: } elsif ($target eq 'tex') {
1657: $currentstring = " \\end{figure}";
1658: }
1659: return $currentstring;
1660: }
1.10 www 1661:
1.35 sakharuk 1662: #-- <embed> tag
1.10 www 1663:
1.45 sakharuk 1664: sub start_embed {
1.44 sakharuk 1665: my ($target,$token) = @_;
1666: $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=
1667: $token->[2]->{'src'};
1668: my $currentstring = '';
1669: if ($target eq 'web') {
1670: $currentstring = $token->[4];
1671: } elsif ($target eq 'tex') {
1672: $currentstring = " \\begin{figure} ";
1673: }
1674: return $currentstring;
1675: }
1.10 www 1676: sub end_embed {
1677: my ($target,$token) = @_;
1678: my $currentstring = '';
1679: if ($target eq 'web') {
1680: $currentstring = $token->[2];
1681: } elsif ($target eq 'tex') {
1682: $currentstring = " \\end{figure}";
1683: }
1684: return $currentstring;
1685: }
1686:
1.35 sakharuk 1687: #-- <param> tag
1.10 www 1688:
1.11 www 1689: sub start_param {
1.10 www 1690: my ($target,$token) = @_;
1691: if ($token->[2]->{'name'} eq 'cabbase') {
1692: $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=
1693: $token->[2]->{'value'};
1694: }
1.20 www 1695: $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=
1.10 www 1696: $token->[2]->{'src'};
1697: my $currentstring = '';
1698: if ($target eq 'web') {
1699: $currentstring = $token->[4];
1700: } elsif ($target eq 'tex') {
1701: $currentstring = " \\begin{figure} ";
1702: }
1703: return $currentstring;
1704: }
1.11 www 1705: sub end_param {
1.10 www 1706: my ($target,$token) = @_;
1707: my $currentstring = '';
1708: if ($target eq 'web') {
1709: $currentstring = $token->[2];
1710: } elsif ($target eq 'tex') {
1711: $currentstring = " \\end{figure}";
1712: }
1713: return $currentstring;
1714: }
1715:
1.35 sakharuk 1716: #-- <allow> tag
1.10 www 1717:
1718: sub start_allow {
1719: my ($target,$token) = @_;
1720:
1.20 www 1721: $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=
1.10 www 1722: $token->[2]->{'src'};
1723:
1724: return '';
1725: }
1726: sub end_allow {
1727: return '';
1728: }
1.35 sakharuk 1729: #-- Frames
1.31 albertel 1730: sub start_frameset {
1731: my ($target,$token) = @_;
1732: my $currentstring = '';
1733: if ($target eq 'web') {
1734: if (!$Apache::lonxml::registered) {
1.47 matthew 1735: $currentstring.='<head>'.
1736: &Apache::lonxml::registerurl(undef,$target).'</head>';
1.31 albertel 1737: }
1738: $currentstring .= $token->[4];
1739: }
1740: return $currentstring;
1741: }
1742: sub end_frameset {
1743: my ($target,$token) = @_;
1744: my $currentstring = '';
1745: if ($target eq 'web') {
1746: $currentstring = $token->[2];
1747: }
1748: return $currentstring;
1.41 sakharuk 1749: }
1750: #-- <pre>
1751: sub start_pre {
1752: my ($target,$token) = @_;
1753: my $currentstring = '';
1754: if ($target eq 'web') {
1755: $currentstring .= $token->[4];
1756: } elsif ($target eq 'tex') {
1757: $currentstring .= '\begin{verbatim}';
1758: }
1759: return $currentstring;
1760: }
1761: sub end_pre {
1762: my ($target,$token) = @_;
1763: my $currentstring = '';
1764: if ($target eq 'web') {
1765: $currentstring .= $token->[2];
1766: } elsif ($target eq 'tex') {
1767: $currentstring .= '\end{verbatim}';
1.44 sakharuk 1768: }
1769: return $currentstring;
1770: }
1771: #-- <insert>
1772: sub start_insert {
1.46 sakharuk 1773: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1.44 sakharuk 1774: my $currentstring = '';
1775: if ($target eq 'web') {
1.46 sakharuk 1776: my $display = &Apache::lonxml::get_param('display',$parstack,$safeeval);
1777: $currentstring .= '<b>'.$display.'</b>';;
1.44 sakharuk 1778: }
1779: return $currentstring;
1780: }
1781: sub end_insert {
1.48 sakharuk 1782: my ($target,$token) = @_;
1783: my $currentstring = '';
1784: if ($target eq 'web') {
1785: $currentstring .= '';
1786: }
1787: return $currentstring;
1788: }
1789: #-- <externallink>
1790: sub start_externallink {
1791: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1792: my $currentstring = '';
1793: if ($target eq 'web') {
1794: my $display = &Apache::lonxml::get_param('display',$parstack,$safeeval);
1795: $currentstring .= '<b>'.$display.'</b>';;
1796: }
1797: return $currentstring;
1798: }
1799: sub end_externallink {
1.44 sakharuk 1800: my ($target,$token) = @_;
1801: my $currentstring = '';
1802: if ($target eq 'web') {
1803: $currentstring .= '';
1.65 sakharuk 1804: }
1805: return $currentstring;
1806: }
1807: #-- <blankspace heigth="">
1808: sub start_blankspace {
1809: my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
1810: my $currentstring = '';
1811: if ($target eq 'tex') {
1812: my $howmuch = &Apache::lonxml::get_param('heigth',$parstack,$safeeval);
1813: $currentstring .= '\vskip '.$howmuch.' ';
1814: }
1815: return $currentstring;
1816: }
1817: sub end_blankspace {
1818: my ($target,$token) = @_;
1819: my $currentstring = '';
1820: if ($target eq 'tex') {
1821: $currentstring .= '';
1822: }
1823: return $currentstring;
1824: }
1.66 sakharuk 1825:
1.1 sakharuk 1826: 1;
1827: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>