aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>2006-03-28 23:31:53 +0000
committerjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>2006-03-28 23:31:53 +0000
commitd9f1b1214926832793103adef926c0bccc833b48 (patch)
treefae805f735637463f3d66f2ac949ab74eb468cc3
parentd73574e19f3544faee8bfaf2d7269b8bc70eca7a (diff)
downloadikiwiki-d9f1b1214926832793103adef926c0bccc833b48.tar
ikiwiki-d9f1b1214926832793103adef926c0bccc833b48.tar.gz
support [[linktext|pagename]] links
-rw-r--r--IkiWiki/Render.pm5
-rw-r--r--doc/todo/done/wikilinkfeatures.mdwn (renamed from doc/todo/wikilinkfeatures.mdwn)0
-rw-r--r--doc/wikilink.mdwn4
-rwxr-xr-xikiwiki7
4 files changed, 11 insertions, 5 deletions
diff --git a/IkiWiki/Render.pm b/IkiWiki/Render.pm
index 5f9de8d26..504edc843 100644
--- a/IkiWiki/Render.pm
+++ b/IkiWiki/Render.pm
@@ -9,7 +9,8 @@ sub linkify ($$) { #{{{
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;
@@ -324,7 +325,7 @@ sub findlinks ($$) { #{{{
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.
diff --git a/doc/todo/wikilinkfeatures.mdwn b/doc/todo/done/wikilinkfeatures.mdwn
index 782acf2af..782acf2af 100644
--- a/doc/todo/wikilinkfeatures.mdwn
+++ b/doc/todo/done/wikilinkfeatures.mdwn
diff --git a/doc/wikilink.mdwn b/doc/wikilink.mdwn
index 4b5c5c1c0..25c758613 100644
--- a/doc/wikilink.mdwn
+++ b/doc/wikilink.mdwn
@@ -23,3 +23,7 @@ charaters, it is possible to create page names containing other characters:
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]]
diff --git a/ikiwiki b/ikiwiki
index f801df29e..9e9c29354 100755
--- a/ikiwiki
+++ b/ikiwiki
@@ -19,7 +19,7 @@ sub getconfig () { #{{{
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,
@@ -252,11 +252,12 @@ sub pagetitle ($) { #{{{
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) {
@@ -266,7 +267,7 @@ sub htmllink ($$;$$) { #{{{
$bestlink="$page/".lc($link);
}
- my $linktext=pagetitle(basename($link));
+ $linktext=pagetitle(basename($link)) unless defined $linktext;
return $linktext if length $bestlink && $page eq $bestlink;