Diff for /loncom/xml/lonxml.pm between versions 1.139 and 1.140

version 1.139, 2001/11/29 19:03:58 version 1.140, 2001/11/29 21:38:17
Line 463  sub htmlclean { Line 463  sub htmlclean {
   
     my $tree = HTML::TreeBuilder->new;      my $tree = HTML::TreeBuilder->new;
     $tree->ignore_unknown(0);      $tree->ignore_unknown(0);
       
     $tree->parse($raw);      $tree->parse($raw);
   
     my $output= $tree->as_HTML(undef,' ');      my $output= $tree->as_HTML(undef,' ');
        
     $output=~s/\<(br|hr|img|meta|allow)([^\>\/]*)\>/\<$1$2 \/\>/gis;      $output=~s/\<(br|hr|img|meta|allow)([^\>\/]*)\>/\<$1$2 \/\>/gis;
     $output=~s/\<\/(br|hr|img|meta|allow)\>//gis;      $output=~s/\<\/(br|hr|img|meta|allow)\>//gis;
     unless ($full) {      unless ($full) {
Line 495  sub inner_xmlparse { Line 495  sub inner_xmlparse {
   $result=$token->[2];    $result=$token->[2];
  }   }
       } elsif ($token->[0] eq 'S') {        } elsif ($token->[0] eq 'S') {
  # add tag to stack       # add tag to stack
  push (@$stack,$token->[1]);   push (@$stack,$token->[1]);
  # add parameters list to another stack   # add parameters list to another stack
  push (@$parstack,&parstring($token));   push (@$parstack,&parstring($token));
  &increasedepth($token);          &increasedepth($token);
  if (exists $$style_for_target{$token->[1]}) {   if (exists $$style_for_target{$token->[1]}) {
   if ($Apache::lonxml::redirection) {    if ($Apache::lonxml::redirection) {
     $Apache::lonxml::outputstack['-1'] .=        $Apache::lonxml::outputstack['-1'] .=
       &recurse($$style_for_target{$token->[1]},$target,$safeeval,        &recurse($$style_for_target{$token->[1]},$target,$safeeval,
        $style_for_target,@$parstack);         $style_for_target,@$parstack);
   } else {    } else {
Line 512  sub inner_xmlparse { Line 512  sub inner_xmlparse {
  } else {   } else {
   $result = &callsub("start_$token->[1]", $target, $token, $stack,    $result = &callsub("start_$token->[1]", $target, $token, $stack,
      $parstack, $pars, $safeeval, $style_for_target);       $parstack, $pars, $safeeval, $style_for_target);
  }                 }
       } elsif ($token->[0] eq 'E') {        } elsif ($token->[0] eq 'E') {
  #clear out any tags that didn't end   #clear out any tags that didn't end
  while ($token->[1] ne $$stack['-1'] && ($#$stack > -1)) {   while ($token->[1] ne $$stack['-1'] && ($#$stack > -1)) {
   &Apache::lonxml::warning("Unbalanced tags in resource $$stack['-1']");    &Apache::lonxml::warning('Missing tag &lt;/'.$$stack['-1'].'&gt; in file');
   &end_tag($stack,$parstack,$token);    &end_tag($stack,$parstack,$token);
  }   }
   
  if (exists $$style_for_target{'/'."$token->[1]"}) {   if (exists($$style_for_target{'/'."$token->[1]"})) {
   if ($Apache::lonxml::redirection) {    if ($Apache::lonxml::redirection) {
     $Apache::lonxml::outputstack['-1'] .=        $Apache::lonxml::outputstack['-1'] .=  
       &recurse($$style_for_target{'/'."$token->[1]"},        &recurse($$style_for_target{'/'."$token->[1]"},
Line 530  sub inner_xmlparse { Line 530  sub inner_xmlparse {
      $target,$safeeval,$style_for_target,       $target,$safeeval,$style_for_target,
      @$parstack);       @$parstack);
   }    }
       
  } else {   } else {
   $result = &callsub("end_$token->[1]", $target, $token, $stack,    $result = &callsub("end_$token->[1]", $target, $token, $stack,
      $parstack, $pars,$safeeval, $style_for_target);       $parstack, $pars,$safeeval, $style_for_target);
Line 581  sub recurse { Line 580  sub recurse {
   my $partstring = '';    my $partstring = '';
   my $output='';    my $output='';
   my $decls='';    my $decls='';
     &Apache::lonxml::debug("Recursing");
   while ( $#pat > -1 ) {    while ( $#pat > -1 ) {
     while  ($tokenpat = $pat[$#pat]->get_token) {      while  ($tokenpat = $pat[$#pat]->get_token) {
       if (($tokenpat->[0] eq 'T') || ($tokenpat->[0] eq 'C') || ($tokenpat->[0] eq 'D') ) {        if (($tokenpat->[0] eq 'T') || ($tokenpat->[0] eq 'C') || ($tokenpat->[0] eq 'D') ) {
Line 598  sub recurse { Line 598  sub recurse {
  #clear out any tags that didn't end   #clear out any tags that didn't end
  while ($tokenpat->[1] ne $innerstack[$#innerstack]    while ($tokenpat->[1] ne $innerstack[$#innerstack] 
        && ($#innerstack > -1)) {         && ($#innerstack > -1)) {
   &Apache::lonxml::warning("Unbalanced tags in resource $innerstack['-1']");    &Apache::lonxml::warning('Missing tag &lt;/'.$innerstack['-1'].'&gt; in style');
   &end_tag(\@innerstack,\@innerparstack,$tokenpat);    &end_tag(\@innerstack,\@innerparstack,$tokenpat);
  }   }
  $partstring = &callsub("end_$tokenpat->[1]", $target, $tokenpat,   $partstring = &callsub("end_$tokenpat->[1]", $target, $tokenpat,
Line 632  sub recurse { Line 632  sub recurse {
     pop @pat;      pop @pat;
     pop @Apache::lonxml::pwd;      pop @Apache::lonxml::pwd;
   }    }
     &Apache::lonxml::debug("Exiting Recursing");
   return $output;    return $output;
 }  }
   
Line 843  sub decreasedepth { Line 844  sub decreasedepth {
     $Apache::lonxml::olddepth=$Apache::lonxml::depth+1;      $Apache::lonxml::olddepth=$Apache::lonxml::depth+1;
   }    }
   if (  $Apache::lonxml::depth < -1) {    if (  $Apache::lonxml::depth < -1) {
     &Apache::lonxml::warning("Unbalanced tags in resource");         &Apache::lonxml::warning("Missing tags, unable to properly run file.");
     $Apache::lonxml::depth='-1';      $Apache::lonxml::depth='-1';
   }    }
   my $curdepth=join('_',@Apache::lonxml::depthcounter);    my $curdepth=join('_',@Apache::lonxml::depthcounter);

Removed from v.1.139  
changed lines
  Added in v.1.140


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