+@@ -469,6 +469,7 @@
+ my $page=shift; # the page that will contain the link (different for inline)
+ my $link=shift;
+ my %opts=@_;
++ my $type=pagetype($pagesources{$page});
+
+ my $bestlink;
+ if (! $opts{forcesubpage}) {
+@@ -494,12 +495,17 @@
+ }
+ if (! grep { $_ eq $bestlink } map { @{$_} } values %renderedfiles) {
+ return $linktext unless length $config{cgiurl};
+- return "<span><a href=\"".
+- cgiurl(
+- do => "create",
+- page => pagetitle(lc($link), 1),
+- from => $lpage
+- ).
++ my $url = cgiurl(
++ do => "create",
++ page => pagetitle(lc($link), 1),
++ from => $lpage
++ );
++
++ if ($hooks{htmlescapelink}{$type}){
++ return $hooks{htmlescapelink}{$type}->($url, $linktext,
++ broken => 1);
++ }
++ return "<span><a href=\"". $url.
+ "\">?</a>$linktext</span>"
+ }
+
+@@ -514,6 +520,9 @@
+ $bestlink.="#".$opts{anchor};
+ }
+
++ if ($hooks{htmlescapelink}{$type}) {
++ return $hooks{htmlescapelink}{$type}->($bestlink, $linktext);
++ }
+ return "<a href=\"$bestlink\">$linktext</a>";
+ } #}}}
+
+@@ -628,6 +637,14 @@