--- loncom/xml/lonxml.pm 2001/06/16 18:34:31 1.96 +++ loncom/xml/lonxml.pm 2001/06/26 21:45:28 1.97 @@ -278,7 +278,7 @@ sub xmlparse { #clear out any tags that didn't end while ($token->[1] ne $stack[$#stack] && ($#stack > -1)) { &Apache::lonxml::warning("Unbalanced tags in resource $stack['-1']"); - pop @stack;pop @parstack;&decreasedepth($token); + &end_tag(\@stack,\@parstack,$token); } if (exists $style_for_target{'/'."$token->[1]"}) { @@ -315,7 +315,7 @@ sub xmlparse { $result = ''; } if ($token->[0] eq 'E') { - pop @stack;pop @parstack;&decreasedepth($token); + &end_tag(\@stack,\@parstack,$token); } } pop @pars; @@ -363,7 +363,7 @@ sub recurse { while ($tokenpat->[1] ne $innerstack[$#innerstack] && ($#innerstack > -1)) { &Apache::lonxml::warning("Unbalanced tags in resource $innerstack['-1']"); - pop @innerstack;pop @innerparstack;&decreasedepth($tokenpat); + &end_tag(\@innerstack,\@innerparstack,$tokenpat); } $partstring = &callsub("end_$tokenpat->[1]", $target, $tokenpat, \@innerstack, \@innerparstack, \@pat, @@ -413,38 +413,47 @@ sub callsub { $sub=~tr/A-Z/a-z/; $space=$Apache::lonxml::alltags{$tag} } - if ($space) { - #&Apache::lonxml::debug("Calling sub $sub in $space $metamode
\n"); - $sub1="$space\:\:$sub"; - $Apache::lonxml::curdepth=join('_',@Apache::lonxml::depthcounter); - ($currentstring,$nodefault) = &$sub1($target,$token,$tagstack, - $parstack,$parser,$safeeval, - $style); - } else { - #&Apache::lonxml::debug("NOT Calling sub $sub in $space $metamode
\n"); - if ($metamode <1) { - if (defined($token->[4]) && ($metamode < 1)) { - $currentstring = $token->[4]; - } else { - $currentstring = $token->[2]; - } - } + + my $deleted=0; + $Apache::lonxml::curdepth=join('_',@Apache::lonxml::depthcounter); + if (($token->[0] eq 'S') && ($target eq 'modified')) { + $deleted=&Apache::edit::handle_delete($space,$target,$token,$tagstack, + $parstack,$parser,$safeeval, + $style); } -# &Apache::lonxml::debug("nodefalt:$nodefault:"); - if ($currentstring eq '' && $nodefault eq '') { - if ($target eq 'edit') { - &Apache::lonxml::debug("doing default edit for $token->[1]"); - if ($token->[0] eq 'S') { - $currentstring = &Apache::edit::tag_start($target,$token); - } elsif ($token->[0] eq 'E') { - $currentstring = &Apache::edit::tag_end($target,$token); + if (!$deleted) { + if ($space) { + #&Apache::lonxml::debug("Calling sub $sub in $space $metamode
\n"); + $sub1="$space\:\:$sub"; + ($currentstring,$nodefault) = &$sub1($target,$token,$tagstack, + $parstack,$parser,$safeeval, + $style); + } else { + #&Apache::lonxml::debug("NOT Calling sub $sub in $space $metamode
\n"); + if ($metamode <1) { + if (defined($token->[4]) && ($metamode < 1)) { + $currentstring = $token->[4]; + } else { + $currentstring = $token->[2]; + } } - } elsif ($target eq 'modified') { - if ($token->[0] eq 'S') { - $currentstring = $token->[4]; - $currentstring.=&Apache::edit::handle_insert(); - } else { - $currentstring = $token->[2]; + } + # &Apache::lonxml::debug("nodefalt:$nodefault:"); + if ($currentstring eq '' && $nodefault eq '') { + if ($target eq 'edit') { + &Apache::lonxml::debug("doing default edit for $token->[1]"); + if ($token->[0] eq 'S') { + $currentstring = &Apache::edit::tag_start($target,$token); + } elsif ($token->[0] eq 'E') { + $currentstring = &Apache::edit::tag_end($target,$token); + } + } elsif ($target eq 'modified') { + if ($token->[0] eq 'S') { + $currentstring = $token->[4]; + $currentstring.=&Apache::edit::handle_insert(); + } else { + $currentstring = $token->[2]; + } } } } @@ -553,6 +562,13 @@ sub endredirection { pop @Apache::lonxml::outputstack; } +sub end_tag { + my ($tagstack,$parstack,$token)=@_; + pop(@$tagstack); + pop(@$parstack); + &decreasedepth($token); +} + sub initdepth { @Apache::lonxml::depthcounter=(); $Apache::lonxml::depth=-1;