aboutsummaryrefslogtreecommitdiff
path: root/IkiWiki
diff options
context:
space:
mode:
authorSimon McVittie <smcv@debian.org>2014-09-12 21:57:04 +0100
committerSimon McVittie <smcv@debian.org>2014-09-12 21:57:04 +0100
commit669a5f5ecc0d50daf96d8dc2af219c94c8625fb4 (patch)
tree453e8b743d6af2ea17fbce47246458323ad4ed90 /IkiWiki
parent390f12a845e65e30ce3c189d62dc4ca8c637e3f0 (diff)
parentefbb1121ffdc146f5c9a481a51f23ad151b9f240 (diff)
downloadikiwiki-669a5f5ecc0d50daf96d8dc2af219c94c8625fb4.tar
ikiwiki-669a5f5ecc0d50daf96d8dc2af219c94c8625fb4.tar.gz
Merge branch 'ready/chrysn/linkmapenhancement'
Diffstat (limited to 'IkiWiki')
-rw-r--r--IkiWiki/Plugin/linkmap.pm17
1 files changed, 15 insertions, 2 deletions
diff --git a/IkiWiki/Plugin/linkmap.pm b/IkiWiki/Plugin/linkmap.pm
index ac26e072e..b5ef1a137 100644
--- a/IkiWiki/Plugin/linkmap.pm
+++ b/IkiWiki/Plugin/linkmap.pm
@@ -5,6 +5,7 @@ use warnings;
use strict;
use IkiWiki 3.00;
use IPC::Open2;
+use HTML::Entities;
sub import {
hook(type => "getsetup", id => "linkmap", call => \&getsetup);
@@ -22,6 +23,18 @@ sub getsetup () {
my $mapnum=0;
+sub pageescape {
+ my $item = shift;
+ # encoding explicitly in case ikiwiki is configured to accept <> or &
+ # in file names
+ my $title = pagetitle($item, 1);
+ # it would not be necessary to encode *all* the html entities (<> would
+ # be sufficient, &" probably a good idea), as dot accepts utf8, but it
+ # isn't bad either
+ $title = encode_entities($title);
+ return("<$title>");
+}
+
sub preprocess (@) {
my %params=@_;
@@ -63,7 +76,7 @@ sub preprocess (@) {
my $show=sub {
my $item=shift;
if (! $shown{$item}) {
- print OUT "\"$item\" [shape=box,href=\"$mapitems{$item}\"];\n";
+ print OUT pageescape($item)." [shape=box,href=\"$mapitems{$item}\"];\n";
$shown{$item}=1;
}
};
@@ -74,7 +87,7 @@ sub preprocess (@) {
foreach my $endpoint ($item, $link) {
$show->($endpoint);
}
- print OUT "\"$item\" -> \"$link\";\n";
+ print OUT pageescape($item)." -> ".pageescape($link).";\n";
}
}
print OUT "}\n";