-
-sub linkify ($$$) { #{{{
- my $lpage=shift;
- my $page=shift;
- my $content=shift;
-
- $content =~ s{(\\?)$config{wiki_link_regexp}}{
- $2 ? ( $1 ? "[[$2|$3]]" : htmllink($lpage, $page, titlepage($3), 0, 0, pagetitle($2)))
- : ( $1 ? "[[$3]]" : htmllink($lpage, $page, titlepage($3)))
- }eg;
-
- return $content;
-} #}}}
-
-sub htmlize ($$) { #{{{
- my $type=shift;
- my $content=shift;
-
- if (! $INC{"/usr/bin/markdown"}) {
- no warnings 'once';
- $blosxom::version="is a proper perl module too much to ask?";
- use warnings 'all';
- do "/usr/bin/markdown";
- use Encode;
- }
-
- if ($type eq '.mdwn') {
- # XXX explanation of this insanity wating on perl bug number
- $content=Encode::encode_utf8($content);
- $content=Encode::encode_utf8($content);
- $content=Markdown::Markdown($content);
- $content=Encode::decode_utf8($content);
- $content=Encode::decode_utf8($content);
- }
- else {
- error("htmlization of $type not supported");
- }
-
- if (exists $hooks{sanitize}) {
- foreach my $id (keys %{$hooks{sanitize}}) {
- $content=$hooks{sanitize}{$id}{call}->($content);
+use Encode;
+
+my %backlinks;
+my $backlinks_calculated=0;
+
+sub calculate_backlinks () { #{{{
+ return if $backlinks_calculated;
+ %backlinks=();
+ foreach my $page (keys %links) {
+ foreach my $link (@{$links{$page}}) {
+ my $bestlink=bestlink($page, $link);
+ if (length $bestlink && $bestlink ne $page) {
+ $backlinks{$bestlink}{$page}=1;
+ }