File:  [LON-CAPA] / loncom / xml / lonxml.pm
Revision 1.114: download - view: text, annotated - select for diffs
Wed Aug 15 15:49:14 2001 UTC (22 years, 9 months ago) by www
Branches: MAIN
CVS tags: HEAD
More checkout - stores token with exam

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

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