Perl / perl5

🐪 The Perl programming language
https://dev.perl.org/perl5/
Other
1.99k stars 557 forks source link

podcheck.t: Fix multiple link targets bug #22771

Closed khwilliamson closed 5 days ago

khwilliamson commented 1 week ago

podcheck.t would wrongly warn about duplicate link targets. It is ambiguous if you have, say

=head1 foo ... =item foo

and then try to create a link to 'foo'. Which 'foo' should it go to? So podcheck looks for such ambiguous links. However, it was incorrectly warning on

=head1 foo ... =item * foo

The latter is a bullet list, which is not an appropriate link target. The logic was flawed in the node() method, when it encountered the second foo, it didn't realize it was for a bullet list, and pushed it onto a list which caused the count to be larger than 1, which caused it later to think there were two link targets with the same name.

The solution here is to instead note that linkable targets are only in =headN or definition lists. The acquisition of the names of them are moved to the methods that get called upon the termination of each of these by the parsing routines. The count is incremented at that point. This means the node() method extension no longer does anything useful and is removed; as well as an auxiliary field, linkable_item. We no longer need to distinguish between =headN and =item.