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