my $page=shift;
$content =~ s{(\\?)$config{wiki_link_regexp}}{
- $1 ? "[[$2]]" : htmllink($page, $2)
+ $2 ? ( $1 ? "[[$2|$3]]" : htmllink($page, $3, 0, 0, pagetitle($2)))
+ : ( $1 ? "[[$3]]" : htmllink($page, $3))
}eg;
return $content;
my @links;
while ($content =~ /(?<!\\)$config{wiki_link_regexp}/g) {
- push @links, lc($1);
+ push @links, lc($2);
}
# Discussion links are a special case since they're not in the text
# of the page, but on its template.
Note that if the file linked to by a WikiLink looks like an image, it will
be displayed inline on the page.
+
+It's also possible to write a WikiLink that uses something other than the
+page name as the link text. For example "\[[foo|SandBox]]" links to the
+SandBox page, but the link will appear like this: [[foo|SandBox]]
if (! exists $ENV{WRAPPED_OPTIONS}) {
%config=(
wiki_file_prune_regexp => qr{((^|/).svn/|\.\.|^\.|\/\.|\.html?$)},
- wiki_link_regexp => qr/\[\[([^\s\]]+)\]\]/,
+ wiki_link_regexp => qr/\[\[(?:([^\s\]\|]+)\|)?([^\s\]]+)\]\]/,
wiki_processor_regexp => qr/\[\[(\w+)\s+([^\]]+)\]\]/,
wiki_file_regexp => qr/(^[-A-Za-z0-9_.:\/+]+$)/,
verbose => 0,
return $page;
} #}}}
-sub htmllink ($$;$$) { #{{{
+sub htmllink ($$;$$$) { #{{{
my $page=shift;
my $link=shift;
my $noimageinline=shift; # don't turn links into inline html images
my $forcesubpage=shift; # force a link to a subpage
+ my $linktext=shift; # set to force the link text to something
my $bestlink;
if (! $forcesubpage) {
$bestlink="$page/".lc($link);
}
- my $linktext=pagetitle(basename($link));
+ $linktext=pagetitle(basename($link)) unless defined $linktext;
return $linktext if length $bestlink && $page eq $bestlink;