- foreach my $page (%IkiWiki::links) {
- if (IkiWiki::globlist_match($page, $params{pages})) {
- foreach my $link (@{$IkiWiki::links{$page}}) {
- next if $link =~ /.*\/discussion/i;
- my $bestlink=IkiWiki::bestlink($page, $link);
- next if length $bestlink;
- push @broken,
- IkiWiki::htmllink($page, $link, 1).
- " in ".
- IkiWiki::htmllink($params{page}, $page, 1);
- }
- }
+ foreach my $link (keys %IkiWiki::brokenlinks) {
+ next if $link =~ /.*\/\Q$config{discussionpage}\E/i && $config{discussion};
+
+ my @pages=pagespec_match_list($params{page}, $params{pages},
+ list => $IkiWiki::brokenlinks{$link},
+ # needs to update when links on a page change
+ deptype => deptype("links")
+ );
+ next unless @pages;
+
+ my $page=$IkiWiki::brokenlinks{$link}->[0];
+ push @broken, sprintf(gettext("%s from %s"),
+ htmllink($page, $params{destpage}, $link, noimageinline => 1),
+ join(", ", map {
+ htmllink($params{page}, $params{destpage}, $_, noimageinline => 1)
+ } @pages)
+ );