2 # Provides a list of broken links.
3 package IkiWiki::Plugin::brokenlinks;
9 IkiWiki::register_plugin("preprocess", "brokenlinks", \&preprocess);
12 sub preprocess (@) { #{{{
14 $params{pages}="*" unless defined $params{pages};
16 # Needs to update whenever a page is added or removed, so
17 # register a dependency.
18 IkiWiki::add_depends($params{page}, $params{pages});
21 foreach my $page (%IkiWiki::links) {
22 if (IkiWiki::globlist_match($page, $params{pages})) {
23 foreach my $link (@{$IkiWiki::links{$page}}) {
24 next if $link =~ /.*\/discussion/i;
25 my $bestlink=IkiWiki::bestlink($page, $link);
26 next if length $bestlink;
28 IkiWiki::htmllink($page, $link, 1).
30 IkiWiki::htmllink($params{page}, $page, 1);
35 return "There are no broken links!" unless @broken;
36 return "<ul>\n".join("\n", map { "<li>$_</li>" } sort @broken)."</ul>\n";