Annotation of loncom/xml/lonxml.pm, revision 1.1
1.1 ! sakharuk 1: package Apache::lonxml;
! 2:
! 3: use strict;
! 4: use HTML::TokeParser;
! 5: use Safe;
! 6: use Apache::Constants qw(:common);
! 7: use Apache::lontexconvert;
! 8:
! 9:
! 10: #======================================================= Main subroutine: xmlparse
! 11:
! 12: sub xmlparse {
! 13:
! 14: my ($target,$content_file_string,%style_for_target) = @_;
! 15: my $pars = HTML::TokeParser->new(\$content_file_string);
! 16: my $currentstring = '';
! 17: my $finaloutput = '';
! 18: my $newarg = '';
! 19: my $tempostring = '';
! 20: my $tempocont = '';
! 21: my $safeeval = new Safe;
! 22:
! 23: #------------------------- Redefinition of the target in the case of compound target
! 24: ($target, my @tenta) = split('&&',$target);
! 25: #------------------------------ Stack definition (in stack we have all current tags)
! 26:
! 27: my @stack = ();
! 28: my @parstack = ();
! 29:
! 30: #------------------------------------------ Parse input string (content_file_string)
! 31:
! 32: my $token;
! 33:
! 34: while ($token = $pars->get_token) {
! 35: if ($token->[0] eq 'T') {
! 36: $finaloutput .= $token->[1];
! 37: $tempocont .= $token->[1];
! 38: } elsif ($token->[0] eq 'S') {
! 39: #------------------------------------------------------------------ add tag to stack
! 40: push (@stack,$token->[1]);
! 41: #---------------------------------------------- add parameters list to another stack
! 42: map {$tempostring .= "$_=$token->[2]->{$_},"} @{$token->[3]};
! 43: push (@parstack,$tempostring);
! 44: $tempostring = '';
! 45: $tempocont = '';
! 46:
! 47: if (exists $style_for_target{$token->[1]}) {
! 48:
! 49: #--------------------------------------------------------- use style file definition
! 50:
! 51: $newarg = $style_for_target{$token->[1]};
! 52:
! 53: if (index($newarg,'script') != -1 ) {
! 54: my $pat = HTML::TokeParser->new(\$newarg);
! 55: my $tokenpat;
! 56: my $partstring = '';
! 57: my $oustring = '';
! 58: my $outputstring;
! 59:
! 60: while ($tokenpat = $pat->get_token) {
! 61: if ($tokenpat->[0] eq 'T') {
! 62: $oustring .= $tokenpat->[1];
! 63: } elsif ($tokenpat->[0] eq 'S') {
! 64: if ($tokenpat->[1] eq 'script') {
! 65: while ($tokenpat = $pat->get_token and $tokenpat->[1] ne 'script') {
! 66: if ($tokenpat->[0] eq 'S') {
! 67: $partstring .= $tokenpat->[4];
! 68: } elsif ($tokenpat->[0] eq 'T') {
! 69: $partstring .= $tokenpat->[1];
! 70: } elsif ($tokenpat->[0] eq 'E') {
! 71: $partstring .= $tokenpat->[2];
! 72: }
! 73: }
! 74:
! 75: map {$partstring =~ s/\$$_/$token->[2]->{$_}/g; } @{$token->[3]};
! 76:
! 77: &run($partstring,$safeeval);
! 78: $partstring = '';
! 79: } elsif ($tokenpat->[1] eq 'evaluate') {
! 80: $outputstring = &evaluate($tokenpat->[2]{expression},$safeeval);
! 81: $oustring .= $outputstring;
! 82: } else {
! 83: $oustring .= $tokenpat->[4];
! 84: }
! 85: } elsif ($tokenpat->[0] eq 'E' and $tokenpat->[1] ne 'evaluate') {
! 86: $oustring .= $tokenpat->[1];
! 87: }
! 88: }
! 89: $newarg = $oustring;
! 90: } else {
! 91: map {$newarg =~ s/\$$_/$token->[2]->{$_}/g; } @{$token->[3]};
! 92: }
! 93: $finaloutput .= $newarg;
! 94: } else {
! 95: #----------------------------------------------------- use default definition of tag
! 96: my $sub="start_$token->[1]";
! 97:
! 98: {
! 99: no strict 'refs';
! 100: if (defined (&$sub)) {
! 101: $currentstring = &$sub($target,$token,\@parstack);
! 102: $finaloutput .= $currentstring;
! 103: $currentstring = '';
! 104: } else {
! 105: $finaloutput .= $token->[4];
! 106: }
! 107: use strict 'refs';
! 108: }
! 109: }
! 110: } elsif ($token->[0] eq 'E') {
! 111: pop @stack;
! 112: unless (exists $style_for_target{$token->[1]}) {
! 113: my $sub="end_$token->[1]";
! 114: {
! 115: no strict 'refs';
! 116: if (defined (&$sub)) {
! 117: $currentstring = &$sub($target,$token,\@parstack);
! 118: $finaloutput .= $currentstring;
! 119: $currentstring = '';
! 120: } else {
! 121: $finaloutput .= $token->[4];
! 122: }
! 123: use strict 'refs';
! 124: }
! 125: }
! 126: #------------------------------------------------------- end tag from the style file
! 127: if (exists $style_for_target{'/'."$token->[1]"}) {
! 128: $newarg = $style_for_target{'/'."$token->[1]"};
! 129: my @very_temp = split(',',@parstack[$#parstack]);
! 130: map {my @ret= split('=',$_); $newarg =~ s/\$$ret[0]/$ret[1]/g; } @very_temp;
! 131: $finaloutput .= $newarg;
! 132: }
! 133: pop @parstack;
! 134: }
! 135: }
! 136: return $finaloutput;
! 137: }
! 138:
! 139:
! 140: #================================================================== style subroutine
! 141:
! 142: sub styleparser {
! 143:
! 144: my ($target,$content_style_string) = @_;
! 145:
! 146: #------------------------------------------------ target redefinition (if necessary)
! 147:
! 148: my @target_string = '';
! 149: my $element;
! 150:
! 151: ($element,@target_string) = split ('&&',$target);
! 152:
! 153: map {$content_style_string =~ s/\<(.*)$_\>/\<$1$element\>/g; } @target_string;
! 154:
! 155: $target = $element;
! 156:
! 157: #------------------------------------------------- create a table for defined target
! 158: #---------------------------------------------- from the information from Style File
! 159:
! 160: my @value_style = ();
! 161: my $current_key = '';
! 162: my $current_value = '';
! 163:
! 164: my $pstyle = HTML::TokeParser->new(\$content_style_string);
! 165:
! 166: my $stoken;
! 167:
! 168: while ($stoken = $pstyle->get_token) {
! 169: #---------------------------------------------------------- start for tag definition
! 170: if ($stoken->[0] eq 'S' and $stoken->[1] eq 'definetag') {
! 171: #------------------------------------------------------------------- new key in hash
! 172: $current_key = $stoken->[2]{name};
! 173: if ($target eq 'meta') {
! 174: #-------------------------------------------------- reserved for the metadate output
! 175:
! 176:
! 177: } else {
! 178: #-------------------------------------------------------------------- outtext output
! 179: while ($stoken = $pstyle->get_token and $stoken->[1] ne 'outtext') {
! 180: }
! 181: while ($stoken = $pstyle->get_token and $stoken->[0] ne 'S') {
! 182: $current_value .= $stoken->[1];
! 183: }
! 184: while ($stoken->[1] ne 'definetag') {
! 185: if ($stoken->[0] eq 'S' and $stoken->[1] eq $target) {
! 186: while ($stoken = $pstyle->get_token) {
! 187: if ($stoken->[1] ne $target) {
! 188: if ($stoken->[0] eq 'S') {
! 189: $current_value .= $stoken->[4];
! 190: }
! 191: if ($stoken->[0] eq 'E') {
! 192: $current_value .= $stoken->[2];
! 193: }
! 194: if ($stoken->[0] eq 'T') {
! 195: $current_value .= $stoken->[1];
! 196: }
! 197: } else {
! 198: last;
! 199: }
! 200: }
! 201: } elsif ($stoken->[0] eq 'S' and $stoken->[1] ne $target) {
! 202: while ($stoken = $pstyle->get_token and $stoken->[0] ne 'E') {
! 203: }
! 204: }
! 205:
! 206: while ($stoken = $pstyle->get_token) {
! 207: if ($stoken->[0] eq 'T') {
! 208: $current_value .= $stoken->[1];
! 209: }
! 210: if ($stoken->[0] eq 'E') {
! 211: last;
! 212: }
! 213: if ($stoken->[0] eq 'S') {
! 214: last;
! 215: }
! 216: }
! 217:
! 218: }
! 219: }
! 220:
! 221: }
! 222: push (@value_style,lc $current_key,$current_value);
! 223: $current_key = '';
! 224: $current_value = '';
! 225:
! 226: }
! 227:
! 228: my %style_for_target = @value_style;
! 229:
! 230: #-------------------------------------------------------------------- check printing
! 231: # while (($current_key,$current_value) = each %style_for_target) {
! 232: # print "$current_key => $current_value\n";
! 233: # }
! 234:
! 235: return %style_for_target;
! 236:
! 237: }
! 238:
! 239:
! 240:
! 241: #=============================================================== Subroutine definition
! 242: #--------------------------------------------------------------------------------- Run
! 243: sub evaluate {
! 244: my ($expression,$safeeval) = @_;
! 245: return $safeeval->reval($expression);
! 246: }
! 247:
! 248: sub run {
! 249: my ($code,$safeeval) = @_;
! 250: $safeeval->reval($code);
! 251: }
! 252:
! 253: #===================================================================== TAG SUBROUTINES
! 254: #----------------------------------------------------------------------------- <m> tag
! 255: sub start_m {
! 256: my ($target,$token) = @_;
! 257: my $currentstring = '';
! 258: if ($target eq 'web') {
! 259: $currentstring = "\$out = lontexconvert::converted(\$in = '\$'.\"";
! 260: } elsif ($target eq 'tex') {
! 261: $currentstring = "\$";
! 262: }
! 263: return $currentstring;
! 264: }
! 265: sub end_m {
! 266: my ($target,$token) = @_;
! 267: my $currentstring = '';
! 268: if ($target eq 'web') {
! 269: $currentstring = "\".'\$') ";
! 270: } elsif ($target eq 'tex') {
! 271: $currentstring = "\$";
! 272: }
! 273: return $currentstring;
! 274: }
! 275: #-------------------------------------------------------------------------- <html> tag
! 276: sub start_html {
! 277: my ($target,$token) = @_;
! 278: my $currentstring = '';
! 279: if ($target eq 'web') {
! 280: $currentstring = $token->[4];
! 281: }
! 282: return $currentstring;
! 283: }
! 284: sub end_html {
! 285: my ($target,$token) = @_;
! 286: my $currentstring = '';
! 287: if ($target eq 'web') {
! 288: $currentstring = $token->[2];
! 289: }
! 290: return $currentstring;
! 291: }
! 292: #-------------------------------------------------------------------------- <head> tag
! 293: sub start_head {
! 294: my ($target,$token) = @_;
! 295: my $currentstring = '';
! 296: if ($target eq 'web') {
! 297: $currentstring = $token->[4];
! 298: }
! 299: return $currentstring;
! 300: }
! 301: sub end_head {
! 302: my ($target,$token) = @_;
! 303: my $currentstring = '';
! 304: if ($target eq 'web') {
! 305: $currentstring = $token->[2];
! 306: }
! 307: return $currentstring;
! 308: }
! 309: #--------------------------------------------------------------------------- <map> tag
! 310: sub start_map {
! 311: my ($target,$token) = @_;
! 312: my $currentstring = '';
! 313: if ($target eq 'web') {
! 314: $currentstring = $token->[4];
! 315: }
! 316: return $currentstring;
! 317: }
! 318: sub end_map {
! 319: my ($target,$token) = @_;
! 320: my $currentstring = '';
! 321: if ($target eq 'web') {
! 322: $currentstring = $token->[2];
! 323: }
! 324: return $currentstring;
! 325: }
! 326: #------------------------------------------------------------------------ <applet> tag
! 327: sub start_applet {
! 328: my ($target,$token) = @_;
! 329: my $currentstring = '';
! 330: if ($target eq 'web') {
! 331: $currentstring = $token->[4];
! 332: }
! 333: return $currentstring;
! 334: }
! 335: sub end_applet {
! 336: my ($target,$token) = @_;
! 337: my $currentstring = '';
! 338: if ($target eq 'web') {
! 339: $currentstring = $token->[2];
! 340: }
! 341: return $currentstring;
! 342: }
! 343: #------------------------------------------------------------------------ <select> tag
! 344: sub start_select {
! 345: my ($target,$token) = @_;
! 346: my $currentstring = '';
! 347: if ($target eq 'web') {
! 348: $currentstring = $token->[4];
! 349: }
! 350: return $currentstring;
! 351: }
! 352: sub end_select {
! 353: my ($target,$token) = @_;
! 354: my $currentstring = '';
! 355: if ($target eq 'web') {
! 356: $currentstring = $token->[2];
! 357: }
! 358: return $currentstring;
! 359: }
! 360: #------------------------------------------------------------------------ <option> tag
! 361: sub start_option {
! 362: my ($target,$token) = @_;
! 363: my $currentstring = '';
! 364: if ($target eq 'web') {
! 365: $currentstring = $token->[4];
! 366: }
! 367: return $currentstring;
! 368: }
! 369: sub end_option {
! 370: my ($target,$token) = @_;
! 371: my $currentstring = '';
! 372: if ($target eq 'web') {
! 373: $currentstring = $token->[2];
! 374: }
! 375: return $currentstring;
! 376: }
! 377: #------------------------------------------------------------------------- <input> tag
! 378: sub start_input {
! 379: my ($target,$token) = @_;
! 380: my $currentstring = '';
! 381: if ($target eq 'web') {
! 382: $currentstring = $token->[4];
! 383: }
! 384: return $currentstring;
! 385: }
! 386: sub end_input {
! 387: my ($target,$token) = @_;
! 388: my $currentstring = '';
! 389: if ($target eq 'web') {
! 390: $currentstring = $token->[2];
! 391: }
! 392: return $currentstring;
! 393: }
! 394: #---------------------------------------------------------------------- <textarea> tag
! 395: sub start_textarea {
! 396: my ($target,$token) = @_;
! 397: my $currentstring = '';
! 398: if ($target eq 'web') {
! 399: $currentstring = $token->[4];
! 400: }
! 401: return $currentstring;
! 402: }
! 403: sub end_textarea {
! 404: my ($target,$token) = @_;
! 405: my $currentstring = '';
! 406: if ($target eq 'web') {
! 407: $currentstring = $token->[2];
! 408: }
! 409: return $currentstring;
! 410: }
! 411: #-------------------------------------------------------------------------- <form> tag
! 412: sub start_form {
! 413: my ($target,$token) = @_;
! 414: my $currentstring = '';
! 415: if ($target eq 'web') {
! 416: $currentstring = $token->[4];
! 417: }
! 418: return $currentstring;
! 419: }
! 420: sub end_form {
! 421: my ($target,$token) = @_;
! 422: my $currentstring = '';
! 423: if ($target eq 'web') {
! 424: $currentstring = $token->[2];
! 425: }
! 426: return $currentstring;
! 427: }
! 428: #------------------------------------------------------------------------- <title> tag
! 429: sub start_title {
! 430: my ($target,$token) = @_;
! 431: my $currentstring = '';
! 432: if ($target eq 'web') {
! 433: $currentstring = $token->[4];
! 434: }
! 435: return $currentstring;
! 436: }
! 437: sub end_title {
! 438: my ($target,$token) = @_;
! 439: my $currentstring = '';
! 440: if ($target eq 'web') {
! 441: $currentstring = $token->[2];
! 442: }
! 443: return $currentstring;
! 444: }
! 445: #-------------------------------------------------------------------------- <meta> tag
! 446: sub start_meta {
! 447: my ($target,$token) = @_;
! 448: my $currentstring = '';
! 449: if ($target eq 'web') {
! 450: $currentstring = $token->[4];
! 451: }
! 452: return $currentstring;
! 453: }
! 454: sub end_meta {
! 455: my ($target,$token) = @_;
! 456: my $currentstring = '';
! 457: if ($target eq 'web') {
! 458: $currentstring = $token->[2];
! 459: }
! 460: return $currentstring;
! 461: }
! 462: #-------------------------------------------------------------------------- <body> tag
! 463: sub start_body {
! 464: my ($target,$token) = @_;
! 465: my $currentstring = '';
! 466: if ($target eq 'web') {
! 467: $currentstring = $token->[4];
! 468: } elsif ($target eq 'tex') {
! 469: $currentstring = " \\begin{document} ";
! 470: }
! 471: return $currentstring;
! 472: }
! 473: sub end_body {
! 474: my ($target,$token) = @_;
! 475: my $currentstring = '';
! 476: if ($target eq 'web') {
! 477: $currentstring = $token->[2];
! 478: } elsif ($target eq 'tex') {
! 479: $currentstring = " \\end{document}";
! 480: }
! 481: return $currentstring;
! 482: }
! 483: #------------------------------------------------------------------------ <center> tag
! 484: sub start_center {
! 485: my ($target,$token) = @_;
! 486: my $currentstring = '';
! 487: if ($target eq 'web') {
! 488: $currentstring = $token->[4];
! 489: } elsif ($target eq 'tex') {
! 490: $currentstring = " \\begin{center} ";
! 491: }
! 492: return $currentstring;
! 493: }
! 494: sub end_center {
! 495: my ($target,$token) = @_;
! 496: my $currentstring = '';
! 497: if ($target eq 'web') {
! 498: $currentstring = $token->[2];
! 499: } elsif ($target eq 'tex') {
! 500: $currentstring = " \\end{center}";
! 501: }
! 502: return $currentstring;
! 503: }
! 504: #----------------------------------------------------------------------------- <b> tag
! 505: sub start_b {
! 506: my ($target,$token) = @_;
! 507: my $currentstring = '';
! 508: if ($target eq 'web') {
! 509: $currentstring = $token->[4];
! 510: } elsif ($target eq 'tex') {
! 511: $currentstring = " {\\bf ";
! 512: }
! 513: return $currentstring;
! 514: }
! 515: sub end_b {
! 516: my ($target,$token) = @_;
! 517: my $currentstring = '';
! 518: if ($target eq 'web') {
! 519: $currentstring = $token->[2];
! 520: } elsif ($target eq 'tex') {
! 521: $currentstring = "}";
! 522: }
! 523: return $currentstring;
! 524: }
! 525: #------------------------------------------------------------------------ <strong> tag
! 526: sub start_strong {
! 527: my ($target,$token) = @_;
! 528: my $currentstring = '';
! 529: if ($target eq 'web') {
! 530: $currentstring = $token->[4];
! 531: } elsif ($target eq 'tex') {
! 532: $currentstring = " {\\bf ";
! 533: }
! 534: return $currentstring;
! 535: }
! 536: sub end_strong {
! 537: my ($target,$token) = @_;
! 538: my $currentstring = '';
! 539: if ($target eq 'web') {
! 540:
! 541: $currentstring = $token->[2];
! 542: } elsif ($target eq 'tex') {
! 543: $currentstring = "}";
! 544: }
! 545: return $currentstring;
! 546: }
! 547: #---------------------------------------------------------------------------- <h1> tag
! 548: sub start_h1 {
! 549: my ($target,$token) = @_;
! 550: my $currentstring = '';
! 551: if ($target eq 'web') {
! 552: $currentstring .= $token->[4];
! 553: } elsif ($target eq 'tex') {
! 554: $currentstring .= "\\chapter{ ";
! 555: }
! 556: return $currentstring;
! 557: }
! 558: sub end_h1 {
! 559: my ($target,$token) = @_;
! 560: my $currentstring = '';
! 561: if ($target eq 'web') {
! 562: $currentstring .= $token->[2];
! 563: } elsif ($target eq 'tex') {
! 564: $currentstring .= "}";
! 565: }
! 566: return $currentstring;
! 567: }
! 568: #---------------------------------------------------------------------------- <h2> tag
! 569: sub start_h2 {
! 570: my ($target,$token) = @_;
! 571: my $currentstring = '';
! 572: if ($target eq 'web') {
! 573: $currentstring .= $token->[4];
! 574: } elsif ($target eq 'tex') {
! 575: $currentstring .= "\\section{ ";
! 576: }
! 577: return $currentstring;
! 578: }
! 579: sub end_h2 {
! 580: my ($target,$token) = @_;
! 581: my $currentstring = '';
! 582: if ($target eq 'web') {
! 583: $currentstring .= $token->[2];
! 584: } elsif ($target eq 'tex') {
! 585: $currentstring .= "}";
! 586: }
! 587: return $currentstring;
! 588: }
! 589: #---------------------------------------------------------------------------- <h3> tag
! 590: sub start_h3 {
! 591: my ($target,$token) = @_;
! 592: my $currentstring = '';
! 593: if ($target eq 'web') {
! 594: $currentstring .= $token->[4];
! 595: } elsif ($target eq 'tex') {
! 596: $currentstring .= "\\subsection{ ";
! 597: }
! 598: return $currentstring;
! 599: }
! 600: sub end_h3 {
! 601: my ($target,$token) = @_;
! 602: my $currentstring = '';
! 603: if ($target eq 'web') {
! 604: $currentstring .= $token->[2];
! 605: } elsif ($target eq 'tex') {
! 606: $currentstring .= "}";
! 607: }
! 608: return $currentstring;
! 609: }
! 610: #---------------------------------------------------------------------------- <h4> tag
! 611: sub start_h4 {
! 612: my ($target,$token) = @_;
! 613: my $currentstring = '';
! 614: if ($target eq 'web') {
! 615: $currentstring .= $token->[4];
! 616: } elsif ($target eq 'tex') {
! 617: $currentstring .= "\\subsubsection{ ";
! 618: }
! 619: return $currentstring;
! 620: }
! 621: sub end_h4 {
! 622: my ($target,$token) = @_;
! 623: my $currentstring = '';
! 624: if ($target eq 'web') {
! 625: $currentstring .= $token->[2];
! 626: } elsif ($target eq 'tex') {
! 627: $currentstring .= "}";
! 628: }
! 629: return $currentstring;
! 630: }
! 631: #---------------------------------------------------------------------------- <h5> tag
! 632: sub start_h5 {
! 633: my ($target,$token) = @_;
! 634: my $currentstring = '';
! 635: if ($target eq 'web') {
! 636: $currentstring .= $token->[4];
! 637: } elsif ($target eq 'tex') {
! 638: $currentstring .= "\\paragraph{ ";
! 639: }
! 640: return $currentstring;
! 641: }
! 642: sub end_h5 {
! 643: my ($target,$token) = @_;
! 644: my $currentstring = '';
! 645: if ($target eq 'web') {
! 646: $currentstring .= $token->[2];
! 647: } elsif ($target eq 'tex') {
! 648: $currentstring .= "}";
! 649: }
! 650: return $currentstring;
! 651: }
! 652: #---------------------------------------------------------------------------- <h6> tag
! 653: sub start_h6 {
! 654: my ($target,$token) = @_;
! 655: my $currentstring = '';
! 656: if ($target eq 'web') {
! 657: $currentstring .= $token->[4];
! 658: } elsif ($target eq 'tex') {
! 659: $currentstring .= "\\subparagraph{ ";
! 660: }
! 661: return $currentstring;
! 662: }
! 663: sub end_h6 {
! 664: my ($target,$token) = @_;
! 665: my $currentstring = '';
! 666: if ($target eq 'web') {
! 667: $currentstring .= $token->[2];
! 668: } elsif ($target eq 'tex') {
! 669: $currentstring .= "}";
! 670: }
! 671: return $currentstring;
! 672: }
! 673: #-------------------------------------------------------------------------- <cite> tag
! 674: sub start_cite {
! 675: my ($target,$token) = @_;
! 676: my $currentstring = '';
! 677: if ($target eq 'web') {
! 678: $currentstring .= $token->[4];
! 679: } elsif ($target eq 'tex') {
! 680: $currentstring .= "{ \\it ";
! 681: }
! 682: return $currentstring;
! 683: }
! 684: sub end_cite {
! 685: my ($target,$token) = @_;
! 686: my $currentstring = '';
! 687: if ($target eq 'web') {
! 688: $currentstring .= $token->[2];
! 689: } elsif ($target eq 'tex') {
! 690: $currentstring .= "}";
! 691: }
! 692: return $currentstring;
! 693: }
! 694: #----------------------------------------------------------------------------- <i> tag
! 695: sub start_i {
! 696: my ($target,$token) = @_;
! 697: my $currentstring = '';
! 698: if ($target eq 'web') {
! 699: $currentstring .= $token->[4];
! 700: } elsif ($target eq 'tex') {
! 701: $currentstring .= "{ \\it ";
! 702: }
! 703: return $currentstring;
! 704: }
! 705: sub end_i {
! 706: my ($target,$token) = @_;
! 707: my $currentstring = '';
! 708: if ($target eq 'web') {
! 709: $currentstring .= $token->[2];
! 710: } elsif ($target eq 'tex') {
! 711: $currentstring .= "}";
! 712: }
! 713: return $currentstring;
! 714: }
! 715: #----------------------------------------------------------------------- <address> tag
! 716: sub start_address {
! 717: my ($target,$token) = @_;
! 718: my $currentstring = '';
! 719: if ($target eq 'web') {
! 720: $currentstring .= $token->[4];
! 721: } elsif ($target eq 'tex') {
! 722: $currentstring .= "{ \\it ";
! 723: }
! 724: return $currentstring;
! 725: }
! 726: sub end_address {
! 727: my ($target,$token) = @_;
! 728: my $currentstring = '';
! 729: if ($target eq 'web') {
! 730: $currentstring .= $token->[2];
! 731: } elsif ($target eq 'tex') {
! 732: $currentstring .= "}";
! 733: }
! 734: return $currentstring;
! 735: }
! 736: #--------------------------------------------------------------------------- <dfn> tag
! 737: sub start_dfn {
! 738: my ($target,$token) = @_;
! 739: my $currentstring = '';
! 740: if ($target eq 'web') {
! 741: $currentstring .= $token->[4];
! 742: } elsif ($target eq 'tex') {
! 743: $currentstring .= "{ \\it ";
! 744: }
! 745: return $currentstring;
! 746: }
! 747: sub end_dfn {
! 748: my ($target,$token) = @_;
! 749: my $currentstring = '';
! 750: if ($target eq 'web') {
! 751: $currentstring .= $token->[2];
! 752: } elsif ($target eq 'tex') {
! 753: $currentstring .= "}";
! 754: }
! 755: return $currentstring;
! 756: }
! 757: #---------------------------------------------------------------------------- <tt> tag
! 758: sub start_tt {
! 759: my ($target,$token) = @_;
! 760: my $currentstring = '';
! 761: if ($target eq 'web') {
! 762: $currentstring .= $token->[4];
! 763: } elsif ($target eq 'tex') {
! 764: $currentstring .= "{ \\tt ";
! 765: }
! 766: return $currentstring;
! 767: }
! 768: sub end_tt {
! 769: my ($target,$token) = @_;
! 770: my $currentstring = '';
! 771: if ($target eq 'web') {
! 772: $currentstring .= $token->[2];
! 773: } elsif ($target eq 'tex') {
! 774: $currentstring .= "}";
! 775: }
! 776: return $currentstring;
! 777: }
! 778: #---------------------------------------------------------------------------- <kbd> tag
! 779: sub start_kbd {
! 780: my ($target,$token) = @_;
! 781: my $currentstring = '';
! 782: if ($target eq 'web') {
! 783: $currentstring .= $token->[4];
! 784: } elsif ($target eq 'tex') {
! 785: $currentstring .= "{ \\tt ";
! 786: }
! 787: return $currentstring;
! 788: }
! 789: sub end_kbd {
! 790: my ($target,$token) = @_;
! 791: my $currentstring = '';
! 792: if ($target eq 'web') {
! 793: $currentstring .= $token->[2];
! 794: } elsif ($target eq 'tex') {
! 795: $currentstring .= "}";
! 796: }
! 797: return $currentstring;
! 798: }
! 799: #-------------------------------------------------------------------------- <code> tag
! 800: sub start_code {
! 801: my ($target,$token) = @_;
! 802: my $currentstring = '';
! 803: if ($target eq 'web') {
! 804: $currentstring .= $token->[4];
! 805: } elsif ($target eq 'tex') {
! 806: $currentstring .= "{ \\tt ";
! 807: }
! 808: return $currentstring;
! 809: }
! 810: sub end_code {
! 811: my ($target,$token) = @_;
! 812: my $currentstring = '';
! 813: if ($target eq 'web') {
! 814: $currentstring .= $token->[2];
! 815: } elsif ($target eq 'tex') {
! 816: $currentstring .= "}";
! 817: }
! 818: return $currentstring;
! 819: }
! 820: #---------------------------------------------------------------------------- <em> tag
! 821: sub start_em {
! 822: my ($target,$token) = @_;
! 823: my $currentstring = '';
! 824: if ($target eq 'web') {
! 825: $currentstring .= $token->[4];
! 826: } elsif ($target eq 'tex') {
! 827: $currentstring .= "{ \\emph ";
! 828: }
! 829: return $currentstring;
! 830: }
! 831: sub end_em {
! 832: my ($target,$token) = @_;
! 833: my $currentstring = '';
! 834: if ($target eq 'web') {
! 835: $currentstring .= $token->[2];
! 836: } elsif ($target eq 'tex') {
! 837: $currentstring .= "}";
! 838: }
! 839: return $currentstring;
! 840: }
! 841: #----------------------------------------------------------------------------- <q> tag
! 842: sub start_q {
! 843: my ($target,$token) = @_;
! 844: my $currentstring = '';
! 845: if ($target eq 'web') {
! 846: $currentstring .= $token->[4];
! 847: } elsif ($target eq 'tex') {
! 848: $currentstring .= "{ \\emph ";
! 849: }
! 850: return $currentstring;
! 851: }
! 852: sub end_q {
! 853: my ($target,$token) = @_;
! 854: my $currentstring = '';
! 855: if ($target eq 'web') {
! 856: $currentstring .= $token->[2];
! 857: } elsif ($target eq 'tex') {
! 858: $currentstring .= "}";
! 859: }
! 860: return $currentstring;
! 861: }
! 862: #----------------------------------------------------------------------------- <p> tag
! 863: sub start_p {
! 864: my ($target,$token) = @_;
! 865: my $currentstring = '';
! 866: if ($target eq 'web') {
! 867: $currentstring .= $token->[4];
! 868: } elsif ($target eq 'tex') {
! 869: $currentstring .= "{\\par ";
! 870: }
! 871: return $currentstring;
! 872: }
! 873: sub end_p {
! 874: my ($target,$token) = @_;
! 875: my $currentstring = '';
! 876: if ($target eq 'web') {
! 877: $currentstring .= $token->[2];
! 878: } elsif ($target eq 'tex') {
! 879: $currentstring .= " }";
! 880: }
! 881: return $currentstring;
! 882: }
! 883: #---------------------------------------------------------------------------- <br> tag
! 884: sub start_br {
! 885: my ($target,$token) = @_;
! 886: my $currentstring = '';
! 887: if ($target eq 'web') {
! 888: $currentstring .= $token->[4];
! 889: } elsif ($target eq 'tex') {
! 890: $currentstring .= "\\\\";
! 891: }
! 892: return $currentstring;
! 893: }
! 894: sub end_br {
! 895: my ($target,$token) = @_;
! 896: my $currentstring = '';
! 897: if ($target eq 'web') {
! 898: $currentstring .= $token->[2];
! 899: }
! 900: return $currentstring;
! 901: }
! 902: #--------------------------------------------------------------------------- <big> tag
! 903: sub start_big {
! 904: my ($target,$token) = @_;
! 905: my $currentstring = '';
! 906: if ($target eq 'web') {
! 907: $currentstring .= $token->[4];
! 908: } elsif ($target eq 'tex') {
! 909: $currentstring .= "{\\large ";
! 910: }
! 911: return $currentstring;
! 912: }
! 913: sub end_big {
! 914: my ($target,$token) = @_;
! 915: my $currentstring = '';
! 916: if ($target eq 'web') {
! 917: $currentstring .= $token->[2];
! 918: } elsif ($target eq 'tex') {
! 919: $currentstring .= " }";
! 920: }
! 921: return $currentstring;
! 922: }
! 923: #------------------------------------------------------------------------- <small> tag
! 924: sub start_small {
! 925: my ($target,$token) = @_;
! 926: my $currentstring = '';
! 927: if ($target eq 'web') {
! 928: $currentstring .= $token->[4];
! 929: } elsif ($target eq 'tex') {
! 930: $currentstring .= "{\\footnotesize ";
! 931: }
! 932: return $currentstring;
! 933: }
! 934: sub end_small {
! 935: my ($target,$token) = @_;
! 936: my $currentstring = '';
! 937: if ($target eq 'web') {
! 938: $currentstring .= $token->[2];
! 939: } elsif ($target eq 'tex') {
! 940: $currentstring .= " }";
! 941: }
! 942: return $currentstring;
! 943: }
! 944: #---------------------------------------------------------------------- <basefont> tag
! 945: sub start_basefont {
! 946: my ($target,$token) = @_;
! 947: my $currentstring = '';
! 948: if ($target eq 'web') {
! 949: $currentstring = $token->[4];
! 950: }
! 951: return $currentstring;
! 952: }
! 953: #-------------------------------------------------------------------------- <font> tag
! 954: sub start_font {
! 955: my ($target,$token) = @_;
! 956: my $currentstring = '';
! 957: if ($target eq 'web') {
! 958: $currentstring = $token->[4];
! 959: }
! 960: return $currentstring;
! 961: }
! 962: sub end_font {
! 963: my ($target,$token) = @_;
! 964: my $currentstring = '';
! 965: if ($target eq 'web') {
! 966: $currentstring = $token->[2];
! 967: }
! 968: return $currentstring;
! 969: }
! 970: #------------------------------------------------------------------------ <strike> tag
! 971: sub start_strike {
! 972: my ($target,$token) = @_;
! 973: my $currentstring = '';
! 974: if ($target eq 'web') {
! 975: $currentstring .= $token->[4];
! 976: } elsif ($target eq 'tex') {
! 977: $currentstring .= "{\\underline ";
! 978: }
! 979: return $currentstring;
! 980: }
! 981: sub end_strike {
! 982: my ($target,$token) = @_;
! 983: my $currentstring = '';
! 984: if ($target eq 'web') {
! 985: $currentstring .= $token->[2];
! 986: } elsif ($target eq 'tex') {
! 987: $currentstring .= " }";
! 988: }
! 989: return $currentstring;
! 990: }
! 991: #----------------------------------------------------------------------------- <s> tag
! 992: sub start_s {
! 993: my ($target,$token) = @_;
! 994: my $currentstring = '';
! 995: if ($target eq 'web') {
! 996: $currentstring .= $token->[4];
! 997: } elsif ($target eq 'tex') {
! 998: $currentstring .= "{\\underline ";
! 999: }
! 1000: return $currentstring;
! 1001: }
! 1002: sub end_s {
! 1003: my ($target,$token) = @_;
! 1004: my $currentstring = '';
! 1005: if ($target eq 'web') {
! 1006: $currentstring .= $token->[2];
! 1007: } elsif ($target eq 'tex') {
! 1008: $currentstring .= " }";
! 1009: }
! 1010: return $currentstring;
! 1011: }
! 1012: #--------------------------------------------------------------------------- <sub> tag
! 1013: sub start_sub {
! 1014: my ($target,$token) = @_;
! 1015: my $currentstring = '';
! 1016: if ($target eq 'web') {
! 1017: $currentstring .= $token->[4];
! 1018: } elsif ($target eq 'tex') {
! 1019: $currentstring .= "\$_{ ";
! 1020: }
! 1021: return $currentstring;
! 1022: }
! 1023: sub end_sub {
! 1024: my ($target,$token) = @_;
! 1025: my $currentstring = '';
! 1026: if ($target eq 'web') {
! 1027: $currentstring .= $token->[2];
! 1028: } elsif ($target eq 'tex') {
! 1029: $currentstring .= " }\$";
! 1030: }
! 1031: return $currentstring;
! 1032: }
! 1033: #--------------------------------------------------------------------------- <sup> tag
! 1034: sub start_sup {
! 1035: my ($target,$token) = @_;
! 1036: my $currentstring = '';
! 1037: if ($target eq 'web') {
! 1038: $currentstring .= $token->[4];
! 1039: } elsif ($target eq 'tex') {
! 1040: $currentstring .= "\$^{ ";
! 1041: }
! 1042: return $currentstring;
! 1043: }
! 1044: sub end_sup {
! 1045: my ($target,$token) = @_;
! 1046: my $currentstring = '';
! 1047: if ($target eq 'web') {
! 1048: $currentstring .= $token->[2];
! 1049: } elsif ($target eq 'tex') {
! 1050: $currentstring .= " }\$";
! 1051: }
! 1052: return $currentstring;
! 1053: }
! 1054: #---------------------------------------------------------------------------- <hr> tag
! 1055: sub start_hr {
! 1056: my ($target,$token) = @_;
! 1057: my $currentstring = '';
! 1058: if ($target eq 'web') {
! 1059: $currentstring .= $token->[4];
! 1060: } elsif ($target eq 'tex') {
! 1061: $currentstring .= "\\hline ";
! 1062: }
! 1063: return $currentstring;
! 1064: }
! 1065: #----------------------------------------------------------------------------- <a> tag
! 1066: sub start_a {
! 1067: my ($target,$token) = @_;
! 1068: my $currentstring = '';
! 1069: if ($target eq 'web') {
! 1070: $currentstring .= $token->[4];
! 1071: } elsif ($target eq 'tex') {
! 1072: }
! 1073: return $currentstring;
! 1074: }
! 1075: sub end_a {
! 1076: my ($target,$token,$stackref) = @_;
! 1077: my $currentstring = '';
! 1078: if ($target eq 'web') {
! 1079: $currentstring .= $token->[2];
! 1080: } elsif ($target eq 'tex') {
! 1081: my $tempor_var = $stackref->[$#$stackref];
! 1082: if (index($tempor_var,'name') != -1 ) {
! 1083: $tempor_var =~ s/name=([^,]*),/$1/g;
! 1084: $currentstring .= " \\label{$tempor_var}";
! 1085: } elsif (index($tempor_var,'href') != -1 ) {
! 1086: $tempor_var =~ s/href=([^,]*),/$1/g;
! 1087: $currentstring .= " \\ref{$tempor_var}";
! 1088: }
! 1089: }
! 1090: return $currentstring;
! 1091: }
! 1092: #---------------------------------------------------------------------------- <li> tag
! 1093: sub start_li {
! 1094: my ($target,$token,$stackref) = @_;
! 1095: my $currentstring = '';
! 1096: if ($target eq 'web') {
! 1097: $currentstring = $token->[4];
! 1098: } elsif ($target eq 'tex') {
! 1099: my $tempor_var = $stackref->[$#$stackref-1];
! 1100: if (index($tempor_var,'circle') != -1 ) {
! 1101: $currentstring .= " \\item[o] ";
! 1102: } elsif (index($tempor_var,'square') != -1 ) {
! 1103: $currentstring .= " \\item[$\Box$] ";
! 1104: } else {
! 1105: $currentstring .= " \\item ";
! 1106: }
! 1107: }
! 1108: return $currentstring;
! 1109: }
! 1110: sub end_li {
! 1111: my ($target,$token) = @_;
! 1112: my $currentstring = '';
! 1113: if ($target eq 'web') {
! 1114: $currentstring = $token->[2];
! 1115: }
! 1116: return $currentstring;
! 1117: }
! 1118: #----------------------------------------------------------------------------- <u> tag
! 1119: sub start_u {
! 1120: my ($target,$token) = @_;
! 1121: my $currentstring = '';
! 1122: if ($target eq 'web') {
! 1123: $currentstring .= $token->[4];
! 1124: } elsif ($target eq 'tex') {
! 1125: $currentstring .= "{\\underline ";
! 1126: }
! 1127: return $currentstring;
! 1128: }
! 1129: sub end_u {
! 1130: my ($target,$token) = @_;
! 1131: my $currentstring = '';
! 1132: if ($target eq 'web') {
! 1133: $currentstring .= $token->[2];
! 1134: } elsif ($target eq 'tex') {
! 1135: $currentstring .= " }";
! 1136: }
! 1137: return $currentstring;
! 1138: }
! 1139: #---------------------------------------------------------------------------- <ul> tag
! 1140: sub start_ul {
! 1141: my ($target,$token) = @_;
! 1142: my $currentstring = '';
! 1143: if ($target eq 'web') {
! 1144: $currentstring = $token->[4];
! 1145: } elsif ($target eq 'tex') {
! 1146: $currentstring = " \\begin{itemize} ";
! 1147: }
! 1148: return $currentstring;
! 1149: }
! 1150: sub end_ul {
! 1151: my ($target,$token) = @_;
! 1152: my $currentstring = '';
! 1153: if ($target eq 'web') {
! 1154: $currentstring = $token->[2];
! 1155: } elsif ($target eq 'tex') {
! 1156: $currentstring = " \\end{itemize}";
! 1157: }
! 1158: return $currentstring;
! 1159: }
! 1160: #-------------------------------------------------------------------------- <menu> tag
! 1161: sub start_menu {
! 1162: my ($target,$token) = @_;
! 1163: my $currentstring = '';
! 1164: if ($target eq 'web') {
! 1165: $currentstring = $token->[4];
! 1166: } elsif ($target eq 'tex') {
! 1167: $currentstring = " \\begin{itemize} ";
! 1168: }
! 1169: return $currentstring;
! 1170: }
! 1171: sub end_menu {
! 1172: my ($target,$token) = @_;
! 1173: my $currentstring = '';
! 1174: if ($target eq 'web') {
! 1175: $currentstring = $token->[2];
! 1176: } elsif ($target eq 'tex') {
! 1177: $currentstring = " \\end{itemize}";
! 1178: }
! 1179: return $currentstring;
! 1180: }
! 1181: #--------------------------------------------------------------------------- <dir> tag
! 1182: sub start_dir {
! 1183: my ($target,$token) = @_;
! 1184: my $currentstring = '';
! 1185: if ($target eq 'web') {
! 1186: $currentstring = $token->[4];
! 1187: } elsif ($target eq 'tex') {
! 1188: $currentstring = " \\begin{itemize} ";
! 1189: }
! 1190: return $currentstring;
! 1191: }
! 1192: sub end_dir {
! 1193: my ($target,$token) = @_;
! 1194: my $currentstring = '';
! 1195: if ($target eq 'web') {
! 1196: $currentstring = $token->[2];
! 1197: } elsif ($target eq 'tex') {
! 1198: $currentstring = " \\end{itemize}";
! 1199: }
! 1200: return $currentstring;
! 1201: }
! 1202: #---------------------------------------------------------------------------- <ol> tag
! 1203: sub start_ol {
! 1204: my ($target,$token) = @_;
! 1205: my $currentstring = '';
! 1206: if ($target eq 'web') {
! 1207: $currentstring = $token->[4];
! 1208: } elsif ($target eq 'tex') {
! 1209: $currentstring = " \\begin{enumerate} ";
! 1210: }
! 1211: return $currentstring;
! 1212: }
! 1213: sub end_ol {
! 1214: my ($target,$token) = @_;
! 1215: my $currentstring = '';
! 1216: if ($target eq 'web') {
! 1217: $currentstring = $token->[2];
! 1218: } elsif ($target eq 'tex') {
! 1219: $currentstring = " \\end{enumerate}";
! 1220: }
! 1221: return $currentstring;
! 1222: }
! 1223: #---------------------------------------------------------------------------- <dl> tag
! 1224: sub start_dl {
! 1225: my ($target,$token) = @_;
! 1226: my $currentstring = '';
! 1227: if ($target eq 'web') {
! 1228: $currentstring = $token->[4];
! 1229: } elsif ($target eq 'tex') {
! 1230: $currentstring = " \\begin{description} ";
! 1231: }
! 1232: return $currentstring;
! 1233: }
! 1234: sub end_dl {
! 1235: my ($target,$token) = @_;
! 1236: my $currentstring = '';
! 1237: if ($target eq 'web') {
! 1238: $currentstring = $token->[2];
! 1239: } elsif ($target eq 'tex') {
! 1240: $currentstring = " \\end{description}";
! 1241: }
! 1242: return $currentstring;
! 1243: }
! 1244: #---------------------------------------------------------------------------- <dt> tag
! 1245: sub start_dt {
! 1246: my ($target,$token) = @_;
! 1247: my $currentstring = '';
! 1248: if ($target eq 'web') {
! 1249: $currentstring = $token->[4];
! 1250: } elsif ($target eq 'tex') {
! 1251: $currentstring = "\\item[ ";
! 1252: }
! 1253: return $currentstring;
! 1254: }
! 1255: sub end_dt {
! 1256: my ($target,$token) = @_;
! 1257: my $currentstring = '';
! 1258: if ($target eq 'web') {
! 1259: $currentstring = $token->[2];
! 1260: } elsif ($target eq 'tex') {
! 1261: $currentstring = "]";
! 1262: }
! 1263: return $currentstring;
! 1264: }
! 1265: #---------------------------------------------------------------------------- <dd> tag
! 1266: sub start_dd {
! 1267: my ($target,$token) = @_;
! 1268: my $currentstring = '';
! 1269: if ($target eq 'web') {
! 1270: $currentstring = $token->[4];
! 1271: }
! 1272: return $currentstring;
! 1273: }
! 1274: sub end_dd {
! 1275: my ($target,$token) = @_;
! 1276: my $currentstring = '';
! 1277: if ($target eq 'web') {
! 1278: $currentstring = $token->[2];
! 1279: }
! 1280: return $currentstring;
! 1281: }
! 1282: #------------------------------------------------------------------------- <table> tag
! 1283: sub start_table {
! 1284: my ($target,$token) = @_;
! 1285: my $currentstring = '';
! 1286: if ($target eq 'web') {
! 1287: $currentstring = $token->[4];
! 1288: } elsif ($target eq 'tex') {
! 1289: $currentstring = " \\begin{tabular} ";
! 1290: }
! 1291: return $currentstring;
! 1292: }
! 1293: sub end_table {
! 1294: my ($target,$token) = @_;
! 1295: my $currentstring = '';
! 1296: if ($target eq 'web') {
! 1297: $currentstring = $token->[2];
! 1298: } elsif ($target eq 'tex') {
! 1299: $currentstring = " \\end{tabular}";
! 1300: }
! 1301: return $currentstring;
! 1302: }
! 1303:
! 1304: 1;
! 1305: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>