2 package IkiWiki::Plugin::link;
11 hook(type => "checkconfig", id => "link", call => \&checkconfig);
12 hook(type => "linkify", id => "link", call => \&linkify);
13 hook(type => "scan", id => "link", call => \&scan);
16 sub checkconfig () { #{{{
17 if ($config{prefix_directives}) {
19 \[\[(?=[^!]) # beginning of link
21 ([^\]\|]+) # 1: link text
25 ([^\n\r\]#]+) # 2: page to link to
27 \# # '#', beginning of anchor
28 ([^\s\]]+) # 3: anchor text
36 \[\[ # beginning of link
38 ([^\]\|\n\s]+) # 1: link text
42 ([^\s\]#]+) # 2: page to link to
44 \# # '#', beginning of anchor
45 ([^\s\]]+) # 3: anchor text
53 sub linkify (@) { #{{{
55 my $page=$params{page};
56 my $destpage=$params{destpage};
58 $params{content} =~ s{(\\?)$link_regexp}{
61 ? "[[$2|$3".($4 ? "#$4" : "")."]]"
62 : htmllink($page, $destpage, IkiWiki::linkpage($3),
63 anchor => $4, linktext => IkiWiki::pagetitle($2)))
65 ? "[[$3".($4 ? "#$4" : "")."]]"
66 : htmllink($page, $destpage, IkiWiki::linkpage($3),
70 return $params{content};
75 my $page=$params{page};
76 my $content=$params{content};
78 while ($content =~ /(?<!\\)$link_regexp/g) {
79 push @{$links{$page}}, IkiWiki::linkpage($2);