blob: 2bb203f51b6c3f5bfd8fd289331af3cae4bd56b9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
Here's an attempt to make `htmllink` "do the right thing" with in-page anchors:
<pre>
Index: IkiWiki.pm
===================================================================
--- IkiWiki.pm (revision 2657)
+++ IkiWiki.pm (working copy)
@@ -426,6 +426,8 @@
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 $anchor = ($link =~ s/#(.+)$// ? $1 : undef);
my $bestlink;
if (! $forcesubpage) {
@@ -455,7 +457,10 @@
if (! $noimageinline && isinlinableimage($bestlink)) {
return "<img src=\"$bestlink\" alt=\"$linktext\" />";
}
- return "<a href=\"$bestlink\">$linktext</a>";
+
+ $bestlink .= "#$anchor" if $anchor;
+
+ return "<a href=\"$bestlink\">$linktext</a>";
} #}}}
sub htmlize ($$$) { #{{{
</pre>
|