Annotation of loncom/xml/lonxml.pm, revision 1.103

1.2       sakharuk    1: # The LearningOnline Network with CAPA
1.3       sakharuk    2: # XML Parser Module 
1.2       sakharuk    3: #
1.3       sakharuk    4: # last modified 06/26/00 by Alexander Sakharuk
1.33      www         5: # 11/6 Gerd Kortemeyer
1.45      www         6: # 6/1/1 Gerd Kortemeyer
1.56      albertel    7: # 2/21,3/13 Guy
1.68      www         8: # 3/29,5/4 Gerd Kortemeyer
1.73      harris41    9: # 5/10 Scott Harrison
1.78      www        10: # 5/26 Gerd Kortemeyer
1.80      harris41   11: # 5/27 H. K. Ng
1.89      www        12: # 6/2,6/3,6/8,6/9 Gerd Kortemeyer
1.93      ng         13: # 6/12,6/13 H. K. Ng
1.95      www        14: # 6/16 Gerd Kortemeyer
1.2       sakharuk   15: 
1.4       albertel   16: package Apache::lonxml; 
1.33      www        17: use vars 
1.76      albertel   18: qw(@pwd @outputstack $redirection $import @extlinks $metamode $evaluate %insertlist @namespace);
1.1       sakharuk   19: use strict;
                     20: use HTML::TokeParser;
1.3       sakharuk   21: use Safe;
1.40      albertel   22: use Safe::Hole;
1.81      ng         23: use Math::Cephes qw(:trigs :hypers :bessels erf erfc);
1.91      ng         24: use Math::Random qw(:all);
1.13      albertel   25: use Opcode;
1.72      albertel   26: 
                     27: sub register {
                     28:   my $space;
                     29:   my @taglist;
                     30:   my $temptag;
                     31:   ($space,@taglist) = @_;
                     32:   foreach $temptag (@taglist) {
                     33:     $Apache::lonxml::alltags{$temptag}=$space;
                     34:   }
                     35: }
                     36: 
1.46      www        37: use Apache::Constants qw(:common);
1.71      www        38: use Apache::lontexconvert;
1.72      albertel   39: use Apache::style;
                     40: use Apache::run;
                     41: use Apache::londefdef;
                     42: use Apache::scripttag;
                     43: use Apache::edit;
1.79      www        44: use Apache::lonnet;
                     45: use Apache::File;
                     46: 
1.72      albertel   47: #==================================================   Main subroutine: xmlparse  
                     48: #debugging control, to turn on debugging modify the correct handler
                     49: $Apache::lonxml::debug=0;
                     50: 
                     51: #path to the directory containing the file currently being processed
                     52: @pwd=();
                     53: 
                     54: #these two are used for capturing a subset of the output for later processing,
                     55: #don't touch them directly use &startredirection and &endredirection
                     56: @outputstack = ();
                     57: $redirection = 0;
                     58: 
                     59: #controls wheter the <import> tag actually does
                     60: $import = 1;
                     61: @extlinks=();
                     62: 
                     63: # meta mode is a bit weird only some output is to be turned off
                     64: #<output> tag turns metamode off (defined in londefdef.pm)
                     65: $metamode = 0;
                     66: 
                     67: # turns on and of run::evaluate actually derefencing var refs
                     68: $evaluate = 1;
1.7       albertel   69: 
1.74      albertel   70: # data structure for eidt mode, determines what tags can go into what other tags
                     71: %insertlist=();
1.68      www        72: 
1.99      albertel   73: # stores the list of active tag namespaces
1.76      albertel   74: @namespace=();
                     75: 
1.99      albertel   76: # has the dynamic menu been updated to know about this resource
                     77: $Apache::lonxml::registered=0;
                     78: 
1.68      www        79: sub xmlbegin {
                     80:   my $output='';
                     81:   if ($ENV{'browser.mathml'}) {
                     82:       $output='<?xml version="1.0"?>'
                     83:             .'<?xml-stylesheet type="text/css" href="/adm/MathML/mathml.css"?>'
                     84:             .'<!DOCTYPE html SYSTEM "/adm/MathML/mathml.dtd" '
                     85:             .'[<!ENTITY mathns "http://www.w3.org/1998/Math/MathML">]>'
                     86:             .'<html xmlns:math="http://www.w3.org/1998/Math/MathML" ' 
                     87: 		.'xmlns="http://www.w3.org/TR/REC-html40">';
                     88:   } else {
                     89:       $output='<html>';
                     90:   }
                     91:   return $output;
                     92: }
                     93: 
                     94: sub xmlend {
1.103   ! www        95:     my $discussion='';
        !            96:     if ($ENV{'request.course.id'}) {
        !            97:        my $symb=&Apache::lonnet::symbread();
        !            98:        if ($symb) {
        !            99:           my %contrib=&Apache::lonnet::restore($symb,$ENV{'request.course.id'},
        !           100:                      $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
        !           101: 		     $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
        !           102:           if ($contrib{'version'}) {
        !           103:               $discussion.=
        !           104:                   '<address><hr /><h2>Course Discussion of Resource</h2>';
        !           105:               my $idx;
        !           106:               for ($idx=1;$idx<=$contrib{'version'};$idx++) {
        !           107:                   my $message=$contrib{$idx.':message'};
        !           108:                   $message=~s/\n/\<br \/\>/g;
        !           109: 		  $discussion.='<p><b>'.$contrib{$idx.':sendername'}.' at '.
        !           110: 		      $contrib{$idx.':senderdomain'}.'</b> ('.
        !           111:                       localtime($contrib{$idx.':timestamp'}).
        !           112:                       '):<blockquote>'.$message.
        !           113:                       '</blockquote></p>'; 
        !           114:               }
        !           115:               $discussion.='</address>';
        !           116:           }
        !           117:        }
        !           118:     }
        !           119:     return $discussion.'</html>';
1.68      www       120: }
                    121: 
1.70      www       122: sub fontsettings() {
                    123:     my $headerstring='';
                    124:     if (($ENV{'browser.os'} eq 'mac') && (!$ENV{'browser.mathml'})) { 
                    125:          $headerstring.=
                    126:              '<meta Content-Type="text/html; charset=x-mac-roman">';
                    127:     }
                    128:     return $headerstring;
                    129: }
                    130: 
1.68      www       131: sub registerurl {
1.100     www       132:     my $forcereg=shift;
1.99      albertel  133:     if ($Apache::lonxml::registered) { return ''; }
1.100     www       134:     if (($ENV{'REQUEST_URI'}!~/^\/(res\/)*adm\//) || ($forcereg)) {
1.87      www       135:         my $hwkadd='';
                    136:         if ($ENV{'REQUEST_URI'}=~/\.(problem|exam|quiz|assess|survey|form)$/) {
                    137: 	    if (&Apache::lonnet::allowed('vgr',$ENV{'request.course.id'})) {
                    138: 		$hwkadd.=(<<ENDSUBM);
                    139:                      menu.switchbutton
                    140:            (7,1,'subm.gif','view sub','missions',
1.88      www       141:                 'gocmd("/adm/grades","submission")');
1.87      www       142: ENDSUBM
                    143:             }
                    144: 	    if (&Apache::lonnet::allowed('mgr',$ENV{'request.course.id'})) {
                    145: 		$hwkadd.=(<<ENDGRDS);
                    146:                      menu.switchbutton
                    147:            (7,2,'pgrd.gif','problem','grades',
1.88      www       148:                 'gocmd("/adm/grades","viewgrades")');
1.87      www       149: ENDGRDS
                    150:             }
                    151: 	    if (&Apache::lonnet::allowed('opa',$ENV{'request.course.id'})) {
                    152: 		$hwkadd.=(<<ENDPARM);
                    153:                      menu.switchbutton
                    154:            (7,3,'pparm.gif','problem','parms',
1.88      www       155:                 'gocmd("/adm/parmset","set")');
1.87      www       156: ENDPARM
                    157:             }
                    158: 	}
1.86      www       159: 	return (<<ENDREGTHIS);
1.87      www       160:      
1.68      www       161: <script language="JavaScript">
1.71      www       162: // BEGIN LON-CAPA Internal
1.86      www       163: 
1.69      www       164:     function LONCAPAreg() {
                    165: 	  menu=window.open("","LONCAPAmenu");
1.86      www       166:           menu.clearTimeout(menu.menucltim);
1.69      www       167: 	  menu.currentURL=window.location.pathname;
                    168:           menu.currentStale=0;
1.85      www       169:           menu.clearbut(3,1);
                    170:           menu.switchbutton
                    171:        (8,1,'eval.gif','evaluate','this','gopost("/adm/evaluate",currentURL)');
                    172:           menu.switchbutton
                    173:     (8,2,'fdbk.gif','feedback','on this','gopost("/adm/feedback",currentURL)');
                    174:           menu.switchbutton
                    175:      (8,3,'prt.gif','prepare','printout','gopost("/adm/printout",currentURL)');
                    176:           menu.switchbutton
                    177:        (2,1,'back.gif','backward','','gopost("/adm/flip","back:"+currentURL)');
                    178:           menu.switchbutton
                    179:      (2,3,'forw.gif','forward','','gopost("/adm/flip","forward:"+currentURL)');
1.94      www       180:           menu.switchbutton
                    181:                             (9,1,'sbkm.gif','set','bookmark','set_bookmark()');
                    182:           menu.switchbutton
                    183:                          (9,2,'vbkm.gif','view','bookmark','edit_bookmarks()');
                    184:           menu.switchbutton
1.95      www       185:                                (9,3,'anot.gif','anno-','tations','annotate()');
1.87      www       186:           $hwkadd
1.69      www       187:     }
1.86      www       188: 
1.69      www       189:     function LONCAPAstale() {
1.86      www       190: 	  menu=window.open("","LONCAPAmenu");
                    191:           menu.currentStale=1;
                    192:           menu.switchbutton
                    193:             (3,1,'reload.gif','return','location','go(currentURL)');
1.90      www       194:           menu.clearbut(7,1);
                    195:           menu.clearbut(7,2);
                    196:           menu.clearbut(7,3);
1.86      www       197:           menu.menucltim=menu.setTimeout(
1.94      www       198:  'clearbut(2,1);clearbut(2,3);clearbut(8,1);clearbut(8,2);clearbut(8,3);'+
                    199:  'clearbut(9,1);clearbut(9,2);clearbut(9,3);',
1.86      www       200: 			  2000);
                    201: 
1.87      www       202:       }
1.86      www       203: 
                    204: // END LON-CAPA Internal
                    205: </script>
                    206: ENDREGTHIS
                    207: 
                    208:     } else {
                    209:         return (<<ENDDONOTREGTHIS);
                    210: 
                    211: <script language="JavaScript">
                    212: // BEGIN LON-CAPA Internal
                    213: 
                    214:     function LONCAPAreg() {
1.69      www       215: 	  menu=window.open("","LONCAPAmenu");
                    216:           menu.currentStale=1;
1.85      www       217:           menu.clearbut(2,1);
                    218:           menu.clearbut(2,3);
                    219:           menu.clearbut(8,1);
                    220:           menu.clearbut(8,2);
                    221:           menu.clearbut(8,3);
1.86      www       222:           if (menu.currentURL) {
                    223:              menu.switchbutton
                    224:               (3,1,'reload.gif','return','location','go(currentURL)');
                    225:  	  } else {
                    226: 	      menu.clearbut(3,1);
                    227:           }
                    228:     }
                    229: 
                    230:     function LONCAPAstale() {
1.68      www       231:     }
1.86      www       232: 
1.71      www       233: // END LON-CAPA Internal
1.68      www       234: </script>
1.86      www       235: ENDDONOTREGTHIS
                    236: 
                    237:     }
1.69      www       238: }
                    239: 
                    240: sub loadevents() {
                    241:     return 'LONCAPAreg();';
                    242: }
                    243: 
                    244: sub unloadevents() {
                    245:     return 'LONCAPAstale();';
1.68      www       246: }
                    247: 
1.48      albertel  248: sub printalltags {
                    249:   my $temp;
                    250:   foreach $temp (sort keys %Apache::lonxml::alltags) {
1.64      albertel  251:     &Apache::lonxml::debug("$temp -- $Apache::lonxml::alltags{$temp}");
1.48      albertel  252:   }
                    253: }
1.31      sakharuk  254: 
1.3       sakharuk  255: sub xmlparse {
1.18      albertel  256:  my ($target,$content_file_string,$safeinit,%style_for_target) = @_;
1.96      albertel  257: 
                    258:  &setup_globals($target);
1.48      albertel  259:  #&printalltags();
1.16      albertel  260:  my @pars = ();
1.23      albertel  261:  my $pwd=$ENV{'request.filename'};
                    262:  $pwd =~ s:/[^/]*$::;
                    263:  &newparser(\@pars,\$content_file_string,$pwd);
1.24      sakharuk  264: 
1.3       sakharuk  265:  my $safeeval = new Safe;
1.40      albertel  266:  my $safehole = new Safe::Hole;
1.82      ng        267:  &init_safespace($target,$safeeval,$safehole,$safeinit);
1.3       sakharuk  268: #-------------------- Redefinition of the target in the case of compound target
                    269: 
                    270:  ($target, my @tenta) = split('&&',$target);
                    271: 
                    272:  my @stack = (); 
                    273:  my @parstack = ();
1.17      albertel  274:  &initdepth;
1.67      www       275: 
1.101     albertel  276:  my $finaloutput = &inner_xmlparse($target,\@stack,\@parstack,\@pars,
                    277: 				   $safeeval,\%style_for_target);
1.67      www       278: 
1.3       sakharuk  279:  return $finaloutput;
1.15      albertel  280: }
                    281: 
1.101     albertel  282: sub inner_xmlparse {
                    283:   my ($target,$stack,$parstack,$pars,$safeeval,$style_for_target)=@_;
                    284:   &Apache::lonxml::debug('Reentrant parser starting, again?');
                    285:   my $finaloutput = '';
                    286:   my $result;
                    287:   my $token;
                    288:   while ( $#$pars > -1 ) {
                    289:     while ($token = $$pars['-1']->get_token) {
                    290:       if (($token->[0] eq 'T') || ($token->[0] eq 'C') || ($token->[0] eq 'D') ) {
                    291: 	if ($metamode<1) {
                    292: 	  $result=$token->[1];
                    293: 	}
                    294:       } elsif ($token->[0] eq 'PI') {
                    295: 	if ($metamode<1) {
                    296: 	  $result=$token->[2];
                    297: 	}
                    298:       } elsif ($token->[0] eq 'S') {
                    299: 	# add tag to stack 	    
                    300: 	push (@$stack,$token->[1]);
                    301: 	# add parameters list to another stack
                    302: 	push (@$parstack,&parstring($token));
                    303: 	&increasedepth($token);       
                    304: 	if (exists $$style_for_target{$token->[1]}) {
                    305: 	  if ($Apache::lonxml::redirection) {
                    306: 	    $Apache::lonxml::outputstack['-1'] .=  
                    307: 	      &recurse($$style_for_target{$token->[1]},$target,$safeeval,
                    308: 		       $style_for_target,@$parstack);
                    309: 	  } else {
                    310: 	    $finaloutput .= &recurse($$style_for_target{$token->[1]},$target,
                    311: 				     $safeeval,$style_for_target,@$parstack);
                    312: 	  }
                    313: 	} else {
                    314: 	  $result = &callsub("start_$token->[1]", $target, $token, $stack,
                    315: 			     $parstack, $pars, $safeeval, $style_for_target);
                    316: 	}              
                    317:       } elsif ($token->[0] eq 'E') {
                    318: 	#clear out any tags that didn't end
                    319: 	while ($token->[1] ne $$stack['-1'] && ($#$stack > -1)) {
                    320: 	  &Apache::lonxml::warning("Unbalanced tags in resource $$stack['-1']");
                    321: 	  &end_tag($stack,$parstack,$token);
                    322: 	}
                    323: 		
                    324: 	if (exists $$style_for_target{'/'."$token->[1]"}) {
                    325: 	  if ($Apache::lonxml::redirection) {
                    326: 	    $Apache::lonxml::outputstack['-1'] .=  
                    327: 	      &recurse($$style_for_target{'/'."$token->[1]"},
                    328: 		       $target,$safeeval,$style_for_target,@$parstack);
                    329: 	  } else {
                    330: 	    $finaloutput .= &recurse($$style_for_target{'/'."$token->[1]"},
                    331: 				     $target,$safeeval,$style_for_target,
                    332: 				     @$parstack);
                    333: 	  }
                    334: 		    
                    335: 	} else {
                    336: 	  $result = &callsub("end_$token->[1]", $target, $token, $stack,
                    337: 			     $parstack, $pars,$safeeval, $style_for_target);
                    338: 	}
                    339:       } else {
                    340: 	&Apache::lonxml::error("Unknown token event :$token->[0]:$token->[1]:");
                    341:       }
                    342:       #evaluate variable refs in result
                    343:       if ($result ne "") {
                    344: 	if ( $#$parstack > -1 ) {
                    345: 	  if ($Apache::lonxml::redirection) {
                    346: 	    $Apache::lonxml::outputstack['-1'] .= 
                    347: 	      &Apache::run::evaluate($result,$safeeval,$$parstack['-1']);
                    348: 	  } else {
                    349: 	    $finaloutput .= &Apache::run::evaluate($result,$safeeval,
                    350: 						   $$parstack['-1']);
                    351: 	  }
                    352: 	} else {
                    353: 	  $finaloutput .= &Apache::run::evaluate($result,$safeeval,'');
                    354: 	}
                    355: 	$result = '';
                    356:       } 
                    357:       if ($token->[0] eq 'E') { 
                    358: 	&end_tag($stack,$parstack,$token);
                    359:       }
                    360:     }
                    361:     pop @$pars;
                    362:     pop @Apache::lonxml::pwd;
                    363:   }
                    364: 
                    365:   # if ($target eq 'meta') {
                    366:   #   $finaloutput.=&endredirection;
                    367:   # }
                    368: 
                    369:   if (($ENV{'QUERY_STRING'}) && ($target eq 'web')) {
                    370:     $finaloutput=&afterburn($finaloutput);
                    371:   }
                    372:   return $finaloutput;
                    373: }
1.67      www       374: 
1.15      albertel  375: sub recurse {
                    376:   my @innerstack = (); 
                    377:   my @innerparstack = ();
                    378:   my ($newarg,$target,$safeeval,$style_for_target,@parstack) = @_;
1.16      albertel  379:   my @pat = ();
1.23      albertel  380:   &newparser(\@pat,\$newarg);
1.15      albertel  381:   my $tokenpat;
                    382:   my $partstring = '';
                    383:   my $output='';
1.16      albertel  384:   my $decls='';
                    385:   while ( $#pat > -1 ) {
                    386:     while  ($tokenpat = $pat[$#pat]->get_token) {
1.57      albertel  387:       if (($tokenpat->[0] eq 'T') || ($tokenpat->[0] eq 'C') || ($tokenpat->[0] eq 'D') ) {
1.61      albertel  388: 	if ($metamode<1) { $partstring=$tokenpat->[1]; }
1.57      albertel  389:       } elsif ($tokenpat->[0] eq 'PI') {
1.61      albertel  390: 	if ($metamode<1) { $partstring=$tokenpat->[2]; }
1.16      albertel  391:       } elsif ($tokenpat->[0] eq 'S') {
                    392: 	push (@innerstack,$tokenpat->[1]);
                    393: 	push (@innerparstack,&parstring($tokenpat));
1.19      albertel  394: 	&increasedepth($tokenpat);
1.84      albertel  395: 	$partstring = &callsub("start_$tokenpat->[1]", $target, $tokenpat,
                    396: 			       \@innerstack, \@innerparstack, \@pat,
                    397: 			       $safeeval, $style_for_target);
1.16      albertel  398:       } elsif ($tokenpat->[0] eq 'E') {
                    399: 	#clear out any tags that didn't end
                    400: 	while ($tokenpat->[1] ne $innerstack[$#innerstack] 
1.43      albertel  401: 	       && ($#innerstack > -1)) {
1.49      albertel  402: 	  &Apache::lonxml::warning("Unbalanced tags in resource $innerstack['-1']");
1.97      albertel  403: 	  &end_tag(\@innerstack,\@innerparstack,$tokenpat);
1.43      albertel  404: 	}
1.84      albertel  405: 	$partstring = &callsub("end_$tokenpat->[1]", $target, $tokenpat,
                    406: 			       \@innerstack, \@innerparstack, \@pat,
                    407: 			       $safeeval, $style_for_target);
1.57      albertel  408:       } else {
                    409: 	&Apache::lonxml::error("Unknown token event :$tokenpat->[0]:$tokenpat->[1]:");
1.16      albertel  410:       }
                    411:       #pass both the variable to the style tag, and the tag we 
                    412:       #are processing inside the <definedtag>
                    413:       if ( $partstring ne "" ) {
                    414: 	if ( $#parstack > -1 ) { 
                    415: 	  if ( $#innerparstack > -1 ) { 
                    416: 	    $decls= $parstack[$#parstack].$innerparstack[$#innerparstack];
                    417: 	  } else {
                    418: 	    $decls= $parstack[$#parstack];
                    419: 	  }
                    420: 	} else {
                    421: 	  if ( $#innerparstack > -1 ) { 
                    422: 	    $decls=$innerparstack[$#innerparstack];
                    423: 	  } else {
                    424: 	    $decls='';
                    425: 	  }
                    426: 	}
                    427: 	$output .= &Apache::run::evaluate($partstring,$safeeval,$decls);
                    428: 	$partstring = '';
                    429:       }
1.17      albertel  430:       if ($tokenpat->[0] eq 'E') { pop @innerstack;pop @innerparstack;
1.19      albertel  431: 				 &decreasedepth($tokenpat);}
1.15      albertel  432:     }
1.16      albertel  433:     pop @pat;
1.23      albertel  434:     pop @Apache::lonxml::pwd;
1.15      albertel  435:   }
                    436:   return $output;
1.7       albertel  437: }
                    438: 
                    439: sub callsub {
1.84      albertel  440:   my ($sub,$target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
1.7       albertel  441:   my $currentstring='';
1.72      albertel  442:   my $nodefault;
1.7       albertel  443:   {
1.59      albertel  444:     my $sub1;
1.7       albertel  445:     no strict 'refs';
1.68      www       446:     my $tag=$token->[1];
                    447:     my $space=$Apache::lonxml::alltags{$tag};
                    448:     if (!$space) {
                    449: 	$tag=~tr/A-Z/a-z/;
                    450: 	$sub=~tr/A-Z/a-z/;
                    451: 	$space=$Apache::lonxml::alltags{$tag}
                    452:     }
1.97      albertel  453: 
                    454:     my $deleted=0;
                    455:     $Apache::lonxml::curdepth=join('_',@Apache::lonxml::depthcounter);
                    456:     if (($token->[0] eq 'S') && ($target eq 'modified')) {
                    457:       $deleted=&Apache::edit::handle_delete($space,$target,$token,$tagstack,
                    458: 					     $parstack,$parser,$safeeval,
                    459: 					     $style);
                    460:     }
                    461:     if (!$deleted) {
                    462:       if ($space) {
                    463: 	#&Apache::lonxml::debug("Calling sub $sub in $space $metamode<br />\n");
                    464: 	$sub1="$space\:\:$sub";
                    465: 	($currentstring,$nodefault) = &$sub1($target,$token,$tagstack,
                    466: 					     $parstack,$parser,$safeeval,
                    467: 					     $style);
                    468:       } else {
                    469: 	#&Apache::lonxml::debug("NOT Calling sub $sub in $space $metamode<br />\n");
                    470: 	if ($metamode <1) {
                    471: 	  if (defined($token->[4]) && ($metamode < 1)) {
                    472: 	    $currentstring = $token->[4];
                    473: 	  } else {
                    474: 	    $currentstring = $token->[2];
                    475: 	  }
1.62      sakharuk  476: 	}
1.7       albertel  477:       }
1.97      albertel  478:       #    &Apache::lonxml::debug("nodefalt:$nodefault:");
                    479:       if ($currentstring eq '' && $nodefault eq '') {
                    480: 	if ($target eq 'edit') {
                    481: 	  &Apache::lonxml::debug("doing default edit for $token->[1]");
                    482: 	  if ($token->[0] eq 'S') {
                    483: 	    $currentstring = &Apache::edit::tag_start($target,$token);
                    484: 	  } elsif ($token->[0] eq 'E') {
                    485: 	    $currentstring = &Apache::edit::tag_end($target,$token);
                    486: 	  }
                    487: 	} elsif ($target eq 'modified') {
                    488: 	  if ($token->[0] eq 'S') {
                    489: 	    $currentstring = $token->[4];
                    490: 	    $currentstring.=&Apache::edit::handle_insert();
                    491: 	  } else {
                    492: 	    $currentstring = $token->[2];
                    493: 	  }
1.72      albertel  494: 	}
                    495:       }
1.7       albertel  496:     }
                    497:     use strict 'refs';
                    498:   }
                    499:   return $currentstring;
1.82      ng        500: }
                    501: 
1.96      albertel  502: sub setup_globals {
                    503:   my ($target)=@_;
1.99      albertel  504:   $Apache::lonxml::registered = 0;
1.101     albertel  505:   @Apache::lonxml::pwd=();
1.96      albertel  506:   if ($target eq 'meta') {
                    507:     $Apache::lonxml::redirection = 0;
                    508:     $Apache::lonxml::metamode = 1;
                    509:     $Apache::lonxml::evaluate = 1;
                    510:     $Apache::lonxml::import = 0;
                    511:   } elsif ($target eq 'grade') {
                    512:     &startredirection;
                    513:     $Apache::lonxml::metamode = 0;
                    514:     $Apache::lonxml::evaluate = 1;
                    515:     $Apache::lonxml::import = 1;
                    516:   } elsif ($target eq 'modified') {
                    517:     $Apache::lonxml::redirection = 0;
                    518:     $Apache::lonxml::metamode = 0;
                    519:     $Apache::lonxml::evaluate = 0;
                    520:     $Apache::lonxml::import = 0;
                    521:   } elsif ($target eq 'edit') {
                    522:     $Apache::lonxml::redirection = 0;
                    523:     $Apache::lonxml::metamode = 0;
                    524:     $Apache::lonxml::evaluate = 0;
                    525:     $Apache::lonxml::import = 0;
                    526:   } else {
                    527:     $Apache::lonxml::redirection = 0;
                    528:     $Apache::lonxml::metamode = 0;
                    529:     $Apache::lonxml::evaluate = 1;
                    530:     $Apache::lonxml::import = 1;
                    531:   }
                    532: }
                    533: 
1.82      ng        534: sub init_safespace {
                    535:   my ($target,$safeeval,$safehole,$safeinit) = @_;
                    536:   $safeeval->permit("entereval");
                    537:   $safeeval->permit(":base_math");
                    538:   $safeeval->permit("sort");
                    539:   $safeeval->deny(":base_io");
1.102     albertel  540:   $safehole->wrap(\&Apache::scripttag::xmlparse,$safeeval,'&xmlparse');
1.82      ng        541:   $safehole->wrap(\&Apache::lonnet::EXT,$safeeval,'&EXT');
                    542:   
                    543:   $safehole->wrap(\&Math::Cephes::asin,$safeeval,'&asin');
                    544:   $safehole->wrap(\&Math::Cephes::acos,$safeeval,'&acos');
                    545:   $safehole->wrap(\&Math::Cephes::atan,$safeeval,'&atan');
                    546:   $safehole->wrap(\&Math::Cephes::sinh,$safeeval,'&sinh');
                    547:   $safehole->wrap(\&Math::Cephes::cosh,$safeeval,'&cosh');
                    548:   $safehole->wrap(\&Math::Cephes::tanh,$safeeval,'&tanh');
                    549:   $safehole->wrap(\&Math::Cephes::asinh,$safeeval,'&asinh');
                    550:   $safehole->wrap(\&Math::Cephes::acosh,$safeeval,'&acosh');
                    551:   $safehole->wrap(\&Math::Cephes::atanh,$safeeval,'&atanh');
                    552:   $safehole->wrap(\&Math::Cephes::erf,$safeeval,'&erf');
                    553:   $safehole->wrap(\&Math::Cephes::erfc,$safeeval,'&erfc');
                    554:   $safehole->wrap(\&Math::Cephes::j0,$safeeval,'&j0');
                    555:   $safehole->wrap(\&Math::Cephes::j1,$safeeval,'&j1');
                    556:   $safehole->wrap(\&Math::Cephes::jn,$safeeval,'&jn');
                    557:   $safehole->wrap(\&Math::Cephes::jv,$safeeval,'&jv');
                    558:   $safehole->wrap(\&Math::Cephes::y0,$safeeval,'&y0');
                    559:   $safehole->wrap(\&Math::Cephes::y1,$safeeval,'&y1');
                    560:   $safehole->wrap(\&Math::Cephes::yn,$safeeval,'&yn');
                    561:   $safehole->wrap(\&Math::Cephes::yv,$safeeval,'&yv');
1.91      ng        562:   $safehole->wrap(\&Math::Random::random_beta,$safeeval,'&math_random_beta');
                    563:   $safehole->wrap(\&Math::Random::random_chi_square,$safeeval,'&math_random_chi_square');
                    564:   $safehole->wrap(\&Math::Random::random_exponential,$safeeval,'&math_random_exponential');
                    565:   $safehole->wrap(\&Math::Random::random_f,$safeeval,'&math_random_f');
                    566:   $safehole->wrap(\&Math::Random::random_gamma,$safeeval,'&math_random_gamma');
                    567:   $safehole->wrap(\&Math::Random::random_multivariate_normal,$safeeval,'&math_random_multivariate_normal');
                    568:   $safehole->wrap(\&Math::Random::random_multinomial,$safeeval,'&math_random_multinomial');
                    569:   $safehole->wrap(\&Math::Random::random_noncentral_chi_square,$safeeval,'&math_random_noncentral_chi_square');
                    570:   $safehole->wrap(\&Math::Random::random_noncentral_f,$safeeval,'&math_random_noncentral_f');
                    571:   $safehole->wrap(\&Math::Random::random_normal,$safeeval,'&math_random_normal');
                    572:   $safehole->wrap(\&Math::Random::random_permutation,$safeeval,'&math_random_permutation');
1.93      ng        573:   $safehole->wrap(\&Math::Random::random_permuted_index,$safeeval,'&math_random_permuted_index');
1.91      ng        574:   $safehole->wrap(\&Math::Random::random_uniform,$safeeval,'&math_random_uniform');
                    575:   $safehole->wrap(\&Math::Random::random_poisson,$safeeval,'&math_random_poisson');
                    576:   $safehole->wrap(\&Math::Random::random_uniform_integer,$safeeval,'&math_random_uniform_integer');
                    577:   $safehole->wrap(\&Math::Random::random_negative_binomial,$safeeval,'&math_random_negative_binomial');
                    578:   $safehole->wrap(\&Math::Random::random_binomial,$safeeval,'&math_random_binomial');
                    579:   $safehole->wrap(\&Math::Random::random_seed_from_phrase,$safeeval,'&random_seed_from_phrase');
                    580:   $safehole->wrap(\&Math::Random::random_set_seed_from_phrase,$safeeval,'&random_set_seed_from_phrase');
                    581:   $safehole->wrap(\&Math::Random::random_get_seed,$safeeval,'&random_get_seed');
                    582:   $safehole->wrap(\&Math::Random::random_set_seed,$safeeval,'&random_set_seed');
                    583: 
1.82      ng        584: #need to inspect this class of ops
                    585: # $safeeval->deny(":base_orig");
1.91      ng        586:   $safeinit .= ';$external::target="'.$target.'";';
1.82      ng        587:   $safeinit .= ';$external::randomseed='.&Apache::lonnet::rndseed().';';
                    588:   &Apache::run::run($safeinit,$safeeval);
1.17      albertel  589: }
                    590: 
1.55      albertel  591: sub startredirection {
                    592:   $Apache::lonxml::redirection++;
                    593:   push (@Apache::lonxml::outputstack, '');
                    594: }
                    595: 
                    596: sub endredirection {
                    597:   if (!$Apache::lonxml::redirection) {
1.72      albertel  598:     &Apache::lonxml::error("Endredirection was called, before a startredirection, perhaps you have unbalanced tags. Some debuging information:".join ":",caller);
1.55      albertel  599:     return '';
                    600:   }
                    601:   $Apache::lonxml::redirection--;
                    602:   pop @Apache::lonxml::outputstack;
1.97      albertel  603: }
                    604: 
                    605: sub end_tag {
                    606:   my ($tagstack,$parstack,$token)=@_;
                    607:   pop(@$tagstack);
                    608:   pop(@$parstack);
                    609:   &decreasedepth($token);
1.55      albertel  610: }
                    611: 
1.17      albertel  612: sub initdepth {
                    613:   @Apache::lonxml::depthcounter=();
                    614:   $Apache::lonxml::depth=-1;
                    615:   $Apache::lonxml::olddepth=-1;
                    616: }
                    617: 
                    618: sub increasedepth {
1.19      albertel  619:   my ($token) = @_;
1.17      albertel  620:   $Apache::lonxml::depth++;
                    621:   $Apache::lonxml::depthcounter[$Apache::lonxml::depth]++;
                    622:   if ($Apache::lonxml::depthcounter[$Apache::lonxml::depth]==1) {
                    623:     $Apache::lonxml::olddepth=$Apache::lonxml::depth;
                    624:   }
1.42      albertel  625:   my $curdepth=join('_',@Apache::lonxml::depthcounter);
1.64      albertel  626:   &Apache::lonxml::debug("s $Apache::lonxml::depth : $Apache::lonxml::olddepth : $curdepth : $token->[1]\n");
1.54      albertel  627: #print "<br />s $Apache::lonxml::depth : $Apache::lonxml::olddepth : $curdepth : $token->[1]\n";
1.17      albertel  628: }
                    629: 
                    630: sub decreasedepth {
1.19      albertel  631:   my ($token) = @_;
1.17      albertel  632:   $Apache::lonxml::depth--;
1.36      albertel  633:   if ($Apache::lonxml::depth<$Apache::lonxml::olddepth-1) {
                    634:     $#Apache::lonxml::depthcounter--;
                    635:     $Apache::lonxml::olddepth=$Apache::lonxml::depth+1;
                    636:   }
1.43      albertel  637:   if (  $Apache::lonxml::depth < -1) {
1.49      albertel  638:     &Apache::lonxml::warning("Unbalanced tags in resource");   
1.43      albertel  639:     $Apache::lonxml::depth='-1';
                    640:   }
1.42      albertel  641:   my $curdepth=join('_',@Apache::lonxml::depthcounter);
1.64      albertel  642:   &Apache::lonxml::debug("e $Apache::lonxml::depth : $Apache::lonxml::olddepth : $token->[1] : $curdepth\n");
1.54      albertel  643: #print "<br />e $Apache::lonxml::depth : $Apache::lonxml::olddepth : $token->[1] : $curdepth\n";
1.1       sakharuk  644: }
1.19      albertel  645: 
                    646: sub get_all_text {
                    647: 
                    648:  my($tag,$pars)= @_;
                    649:  my $depth=0;
                    650:  my $token;
                    651:  my $result='';
1.57      albertel  652:  if ( $tag =~ m:^/: ) { 
                    653:    my $tag=substr($tag,1); 
                    654: #   &Apache::lonxml::debug("have:$tag:");
                    655:    while (($depth >=0) && ($token = $pars->get_token)) {
                    656: #     &Apache::lonxml::debug("e token:$token->[0]:$depth:$token->[1]");
                    657:      if (($token->[0] eq 'T')||($token->[0] eq 'C')||($token->[0] eq 'D')) {
                    658:        $result.=$token->[1];
                    659:      } elsif ($token->[0] eq 'PI') {
                    660:        $result.=$token->[2];
                    661:      } elsif ($token->[0] eq 'S') {
                    662:        if ($token->[1] eq $tag) { $depth++; }
                    663:        $result.=$token->[4];
                    664:      } elsif ($token->[0] eq 'E')  {
                    665:        if ( $token->[1] eq $tag) { $depth--; }
                    666:        #skip sending back the last end tag
                    667:        if ($depth > -1) { $result.=$token->[2]; } else {
                    668: 	 $pars->unget_token($token);
                    669:        }
                    670:      }
                    671:    }
                    672:  } else {
                    673:    while ($token = $pars->get_token) {
                    674: #     &Apache::lonxml::debug("s token:$token->[0]:$depth:$token->[1]");
                    675:      if (($token->[0] eq 'T')||($token->[0] eq 'C')||($token->[0] eq 'D')) {
                    676:        $result.=$token->[1];
                    677:      } elsif ($token->[0] eq 'PI') {
                    678:        $result.=$token->[2];
                    679:      } elsif ($token->[0] eq 'S') {
                    680:        if ( $token->[1] eq $tag) { 
                    681: 	 $pars->unget_token($token); last;
                    682:        } else {
                    683: 	 $result.=$token->[4];
                    684:        }
                    685:      } elsif ($token->[0] eq 'E')  {
                    686:        $result.=$token->[2];
1.36      albertel  687:      }
1.19      albertel  688:    }
                    689:  }
1.49      albertel  690: # &Apache::lonxml::debug("Exit:$result:");
1.19      albertel  691:  return $result
                    692: }
                    693: 
1.23      albertel  694: sub newparser {
                    695:   my ($parser,$contentref,$dir) = @_;
                    696:   push (@$parser,HTML::TokeParser->new($contentref));
1.56      albertel  697:   $$parser['-1']->xml_mode('1');
1.23      albertel  698:   if ( $dir eq '' ) {
                    699:     push (@Apache::lonxml::pwd, $Apache::lonxml::pwd[$#Apache::lonxml::pwd]);
                    700:   } else {
                    701:     push (@Apache::lonxml::pwd, $dir);
                    702:   } 
                    703: #  &Apache::lonxml::debug("pwd:$#Apache::lonxml::pwd");
                    704: #  &Apache::lonxml::debug("pwd:$Apache::lonxml::pwd[$#Apache::lonxml::pwd]");
                    705: }
1.1       sakharuk  706: 
1.8       albertel  707: sub parstring {
                    708:   my ($token) = @_;
                    709:   my $temp='';
1.20      albertel  710:   map {
1.35      www       711:     unless ($_=~/\W/) {
1.42      albertel  712:       my $val=$token->[2]->{$_};
1.53      albertel  713:       $val =~ s/([\%\@\\])/\\$1/g;
1.51      albertel  714:       #if ($val =~ m/^[\%\@]/) { $val="\\".$val; }
1.42      albertel  715:       $temp .= "my \$$_=\"$val\";"
1.20      albertel  716:     }
                    717:   } @{$token->[3]};
1.8       albertel  718:   return $temp;
                    719: }
1.22      albertel  720: 
1.34      www       721: sub writeallows {
                    722:     my $thisurl='/res/'.&Apache::lonnet::declutter(shift);
                    723:     my $thisdir=$thisurl;
                    724:     $thisdir=~s/\/[^\/]+$//;
                    725:     my %httpref=();
                    726:     map {
                    727:        $httpref{'httpref.'.
                    728:  	        &Apache::lonnet::hreflocation($thisdir,$_)}=$thisurl;              } @extlinks;
                    729:     &Apache::lonnet::appenv(%httpref);
                    730: }
                    731: 
1.66      www       732: #
                    733: # Afterburner handles anchors, highlights and links
                    734: #
                    735: sub afterburn {
                    736:     my $result=shift;
                    737:     map {
                    738:        my ($name, $value) = split(/=/,$_);
                    739:        $value =~ tr/+/ /;
                    740:        $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
                    741:        if (($name eq 'highlight')||($name eq 'anchor')||($name eq 'link')) {
                    742:            unless ($ENV{'form.'.$name}) {
                    743:               $ENV{'form.'.$name}=$value;
                    744: 	   }
                    745:        }
                    746:     } (split(/&/,$ENV{'QUERY_STRING'}));
                    747:     if ($ENV{'form.highlight'}) {
                    748:         map {
                    749:            my $anchorname=$_;
                    750: 	   my $matchthis=$anchorname;
                    751:            $matchthis=~s/\_+/\\s\+/g;
                    752:            $result=~s/($matchthis)/\<font color=\"red\"\>$1\<\/font\>/gs;
                    753:        } split(/\,/,$ENV{'form.highlight'});
                    754:     }
                    755:     if ($ENV{'form.link'}) {
                    756:         map {
                    757:            my ($anchorname,$linkurl)=split(/\>/,$_);
                    758: 	   my $matchthis=$anchorname;
                    759:            $matchthis=~s/\_+/\\s\+/g;
                    760:            $result=~s/($matchthis)/\<a href=\"$linkurl\"\>$1\<\/a\>/gs;
                    761:        } split(/\,/,$ENV{'form.link'});
                    762:     }
                    763:     if ($ENV{'form.anchor'}) {
                    764:         my $anchorname=$ENV{'form.anchor'};
                    765: 	my $matchthis=$anchorname;
                    766:         $matchthis=~s/\_+/\\s\+/g;
                    767:         $result=~s/($matchthis)/\<a name=\"$anchorname\"\>$1\<\/a\>/s;
                    768:         $result.=(<<"ENDSCRIPT");
                    769: <script>
                    770:     document.location.hash='$anchorname';
                    771: </script>
                    772: ENDSCRIPT
                    773:     }
                    774:     return $result;
                    775: }
                    776: 
1.79      www       777: sub storefile {
                    778:     my ($file,$contents)=@_;
                    779:     if (my $fh=Apache::File->new('>'.$file)) {
                    780: 	print $fh $contents;
                    781:         $fh->close();
                    782:     }
                    783: }
                    784: 
1.78      www       785: sub inserteditinfo {
                    786:       my ($result,$filecontents)=@_;
                    787:       unless ($filecontents) {
                    788: 	  $filecontents=(<<SIMPLECONTENT);
                    789: <html>
                    790: <head>
                    791: <title>
                    792:                            Title of Document Goes Here
                    793: </title>
                    794: </head>
                    795: <body bgcolor="#FFFFFF">
                    796: 
                    797:                            Body of Document Goes Here
                    798: 
                    799: </body>
                    800: </html>
                    801: SIMPLECONTENT
                    802:       }
                    803:       my $editheader='<a href="#editsection">Edit below</a><hr />';
                    804:       my $editfooter=(<<ENDFOOTER);
                    805: <hr />
                    806: <a name="editsection" />
                    807: <form method="post">
                    808: <textarea cols="80" rows="40" name="filecont">$filecontents</textarea>
                    809: <br />
                    810: <input type="submit" name="savethisfile" value="Save this file" />
                    811: </form>
                    812: ENDFOOTER
                    813:       $result=~s/(\<body[^\>]*\>)/$1$editheader/is;
                    814:       $result=~s/(\<\/body\>)/$editfooter/is;
                    815:       return $result;
                    816: }
                    817: 
1.24      sakharuk  818: sub handler {
                    819:   my $request=shift;
1.68      www       820: 
1.64      albertel  821:   my $target='web';
1.68      www       822: 
1.65      albertel  823:   $Apache::lonxml::debug=0;
1.68      www       824: 
1.25      sakharuk  825:   if ($ENV{'browser.mathml'}) {
1.27      albertel  826:     $request->content_type('text/xml');
                    827:   } else {
                    828:     $request->content_type('text/html');
1.25      sakharuk  829:   }
1.64      albertel  830:   
1.27      albertel  831:   $request->send_http_header;
1.64      albertel  832:   
1.45      www       833:   return OK if $request->header_only;
1.27      albertel  834: 
1.79      www       835: 
                    836:   my $file=&Apache::lonnet::filelocation("",$request->uri);
1.78      www       837: #
                    838: # Edit action? Save file.
                    839: #
                    840:   unless ($ENV{'request.state'} eq 'published') {
                    841:       if ($ENV{'form.savethisfile'}) {
1.79      www       842: 	  &storefile($file,$ENV{'form.filecont'});
1.78      www       843:       }
                    844:   }
1.24      sakharuk  845:   my %mystyle;
1.50      albertel  846:   my $result = ''; 
                    847:   my $filecontents=&Apache::lonnet::getfile($file);
                    848:   if ($filecontents == -1) {
1.78      www       849:     $result=(<<ENDNOTFOUND);
                    850: <html>
                    851: <head>
                    852: <title>File not found</title>
                    853: </head>
                    854: <body bgcolor="#FFFFFF">
                    855: <b>File not found: $file</b>
                    856: </body>
                    857: </html>
                    858: ENDNOTFOUND
1.50      albertel  859:     $filecontents='';
                    860:   } else {
                    861:     $result = &Apache::lonxml::xmlparse($target,$filecontents,'',%mystyle);
1.78      www       862:   }
                    863: 
                    864: #
                    865: # Edit action? Insert editing commands
                    866: #
                    867:   unless ($ENV{'request.state'} eq 'published') {
                    868:       $result=&inserteditinfo($result,$filecontents);
1.66      www       869:   }
1.50      albertel  870: 
1.67      www       871:   $request->print($result);
1.64      albertel  872: 
1.34      www       873:   writeallows($request->uri);
1.45      www       874:   return OK;
1.24      sakharuk  875: }
                    876:  
1.22      albertel  877: sub debug {
                    878:   if ($Apache::lonxml::debug eq 1) {
1.96      albertel  879:     print("DEBUG:".$_[0]."<br />\n");
1.22      albertel  880:   }
                    881: }
1.49      albertel  882: 
1.22      albertel  883: sub error {
1.74      albertel  884:   if (($Apache::lonxml::debug eq 1) || ($ENV{'request.state'} eq 'construct') ) {
1.55      albertel  885:     print "<b>ERROR:</b>".$_[0]."<br />\n";
1.52      albertel  886:   } else {
                    887:     print "<b>An Error occured while processing this resource. The instructor has been notified.</b> <br />";
                    888:     #notify author
                    889:     &Apache::lonmsg::author_res_msg($ENV{'request.filename'},$_[0]);
                    890:     #notify course
                    891:     if ( $ENV{'request.course.id'} ) {
                    892:       my $users=$ENV{'course.'.$ENV{'request.course.id'}.'.comment.email'};
                    893:       foreach my $user (split /\,/, $users) {
                    894: 	($user,my $domain) = split /:/, $user;
1.54      albertel  895: 	&Apache::lonmsg::user_normal_msg($user,$domain,"Error in $ENV{'request.filename'}",$_[0]);
1.52      albertel  896:       }
                    897:     }
1.74      albertel  898: 
1.52      albertel  899:     #FIXME probably shouldn't have me get everything forever.
1.54      albertel  900:     &Apache::lonmsg::user_normal_msg('albertel','msu',"Error in $ENV{'request.filename'}",$_[0]);
1.74      albertel  901:     #&Apache::lonmsg::user_normal_msg('albertel','103',"Error in $ENV{'request.filename'}",$_[0]);
1.52      albertel  902:   }
1.22      albertel  903: }
1.49      albertel  904: 
1.22      albertel  905: sub warning {
1.73      harris41  906:   if ($ENV{'request.state'} eq 'construct') {
1.55      albertel  907:     print "<b>W</b>ARNING<b>:</b>".$_[0]."<br />\n";
1.73      harris41  908:   }
1.83      albertel  909: }
                    910: 
                    911: sub get_param {
                    912:   my ($param,$parstack,$safeeval,$context) = @_;
                    913:   if ( ! $context ) { $context = -1; }
                    914:   my $args ='';
                    915:   if ( $#$parstack > (-2-$context) ) { $args=$$parstack[$context]; }
                    916:   return &Apache::run::run("{$args;".'return $'.$param.'}',$safeeval); #'
1.22      albertel  917: }
                    918: 
1.74      albertel  919: sub register_insert {
1.75      albertel  920:   my @data = split /\n/, &Apache::lonnet::getfile('/home/httpd/lonTabs/insertlist.tab');
1.74      albertel  921:   my $i;
1.76      albertel  922:   my $tagnum=0;
1.74      albertel  923:   my @order;
                    924:   for ($i=0;$i < $#data; $i++) {
                    925:     my $line = $data[$i];
                    926:     if ( $line =~ /^\#/ || $line =~ /^\s*\n/) { next; }
                    927:     if ( $line =~ /TABLE/ ) { last; }
1.92      albertel  928:     my ($tag,$descrip,$color,$function,$show) = split(/,/, $line);
1.76      albertel  929:     $insertlist{"$tagnum.tag"} = $tag;
                    930:     $insertlist{"$tagnum.description"} = $descrip;
1.92      albertel  931:     $insertlist{"$tagnum.color"} = $color;
1.76      albertel  932:     $insertlist{"$tagnum.function"} = $function;
                    933:     $insertlist{"$tagnum.show"}= $show;
1.92      albertel  934:     $insertlist{"$tag.num"}=$tagnum;
1.76      albertel  935:     $tagnum++;
1.74      albertel  936:   }
1.76      albertel  937:   $i++; #skipping TABLE line
                    938:   $tagnum = 0;
1.74      albertel  939:   for (;$i < $#data;$i++) {
                    940:     my $line = $data[$i];
1.76      albertel  941:     my ($mnemonic,@which) = split(/ +/,$line);
                    942:     my $tag = $insertlist{"$tagnum.tag"};
1.74      albertel  943:     for (my $j=0;$j <$#which;$j++) {
                    944:       if ( $which[$j] eq 'Y' ) {
1.76      albertel  945: 	if ($insertlist{"$j.show"} ne 'no') {
                    946: 	  push(@{ $insertlist{"$tag.which"} },$j);
                    947: 	}
1.74      albertel  948:       }
                    949:     }
1.76      albertel  950:     $tagnum++;
1.74      albertel  951:   }
                    952: }
1.98      albertel  953: 
                    954: sub description {
                    955:   my ($token)=@_;
                    956:   return $insertlist{$insertlist{"$token->[1].num"}.'.description'};
                    957: }
1.1       sakharuk  958: 1;
                    959: __END__
1.68      www       960: 
                    961: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>