X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/b973ed82699903c23b3feeb5e73e1ebd6f587f43..c24be1b752c2b9a0067eddd911b8cee2808ac766:/IkiWiki/Plugin/shortcut.pm?ds=sidebyside diff --git a/IkiWiki/Plugin/shortcut.pm b/IkiWiki/Plugin/shortcut.pm index d09d5879d..e4a9ab1a6 100644 --- a/IkiWiki/Plugin/shortcut.pm +++ b/IkiWiki/Plugin/shortcut.pm @@ -25,14 +25,14 @@ sub preprocess_shortcut (@) { #{{{ } hook(type => "preprocess", no_override => 1, id => $params{name}, - call => sub { shortcut_expand($params{name}, $params{url}, @_) }); + call => sub { shortcut_expand($params{url}, $params{desc}, @_) }); return "shortcut $params{name} points to $params{url}"; } # }}} sub shortcut_expand ($$@) { #{{{ - my $name=shift; my $url=shift; + my $desc=shift; my %params=@_; # Get params in original order. @@ -51,8 +51,15 @@ sub shortcut_expand ($$@) { #{{{ my $encoded_text=$text; $encoded_text=~s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg; + if (defined $desc) { + $desc=~s/\%s/$text/g; + } + else { + $desc=$text; + } + $url=~s/\%s/$encoded_text/g; - return "$text"; + return "$desc"; } #}}} 1