From d9f1b1214926832793103adef926c0bccc833b48 Mon Sep 17 00:00:00 2001 From: joey Date: Tue, 28 Mar 2006 23:31:53 +0000 Subject: [PATCH] support [[linktext|pagename]] links --- IkiWiki/Render.pm | 5 +++-- doc/todo/{ => done}/wikilinkfeatures.mdwn | 0 doc/wikilink.mdwn | 4 ++++ ikiwiki | 7 ++++--- 4 files changed, 11 insertions(+), 5 deletions(-) rename doc/todo/{ => done}/wikilinkfeatures.mdwn (100%) 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 =~ /(? 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; -- 2.26.2