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