diff options
Diffstat (limited to 'IkiWiki')
-rw-r--r-- | IkiWiki/Plugin/link.pm | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/IkiWiki/Plugin/link.pm b/IkiWiki/Plugin/link.pm index 24579057c..51afaec9e 100644 --- a/IkiWiki/Plugin/link.pm +++ b/IkiWiki/Plugin/link.pm @@ -80,4 +80,28 @@ sub scan (@) { #{{{ } } # }}} +sub renamepage (@) { #{{{ + my %params=@_; + my $page=$params{page}; + my $old=$params{oldpage}; + my $new=$params{newpage}; + + $params{content} =~ s{(?<!\\)$link_regexp}{ + my $link=$2; + if (bestlink($page, $2) eq $old) { + if (index($2, "/") == 0) { + $link="/$new"; + } + else { + $link=$new; + } + } + defined $1 + ? ( "[[$1|$link".($3 ? "#$3" : "")."]]" ) + : ( "[[$link". ($3 ? "#$3" : "")."]]" ) + }eg; + + return $params{content}; +} #}}} + 1 |