[Doc-SIG] broken \ref links

Fred L. Drake, Jr. fdrake@acm.org
Fri, 18 Oct 2002 11:59:02 -0400


Trent Mick writes:
 > I'll give a quick try by documenting the code in question:

Thanks, this really helps!

 > # One pass for each element ($node) of parts.
 > 
 >           $node =~ s/[\#\"\'].*$//g;
 > 
 > # After this:
 > #   node = 'HREF'
 > #   node = 'node87.html'
 > #   node = 'href'
 > #   node = 'node77.html\n'
 > 
 >           chop($node);    # Neal was right, the bug is here. (See WRONG
 >                           # below)
 > 
 > # Just want the foo.html part (strip newlines and anything from " or '
 > # or # on.
 > #   node = 'HRE'
 > #   node = 'node87.htm'   <---- WRONG
 > #   node = 'hre'
 > #   node = 'node77.html'

This makes me think the first transform after the split is wrong;
should we just change that and drop the chomp() altogether?  So the
result would be:

    ...
    @parts = split(/(HREF|href)\=[\"\']/);
    shift @parts;
    for $node (@parts) {
      $node =~ s/[\#\"\'].*\n?//g;
      if (defined($nodes{$node})) {
	$label = $nodes{$node};
	if (s/(HREF|href)=([\"\'])$node([\#\"\'])/href=$2$label.html$3/g) {
	  s/(HREF|href)=([\"\'])$label.html/href=$2$label.html/g;
	  $newnames{$node} = "$label.html";
	}
      }
    }
    ...

I'll give this a try.


  -Fred

-- 
Fred L. Drake, Jr.  <fdrake at acm.org>
PythonLabs at Zope Corporation