display the pagetitle() in linkmaps
without this patch, linkmaps display underscores and underscore escape sequences in the rendered output. this introduces a pageescape function, which invoces pagetitle() to get rid of underscore escapes and wraps the resulting utf8 string appropriately for inclusion in a dot file (using dot's html encoding because it can represent the '\"' dyad properly, and because it doesn't need special-casing of newlines).master
parent
be6fe03035
commit
efbb1121ff
|
@ -5,6 +5,7 @@ use warnings;
|
||||||
use strict;
|
use strict;
|
||||||
use IkiWiki 3.00;
|
use IkiWiki 3.00;
|
||||||
use IPC::Open2;
|
use IPC::Open2;
|
||||||
|
use HTML::Entities;
|
||||||
|
|
||||||
sub import {
|
sub import {
|
||||||
hook(type => "getsetup", id => "linkmap", call => \&getsetup);
|
hook(type => "getsetup", id => "linkmap", call => \&getsetup);
|
||||||
|
@ -22,6 +23,18 @@ sub getsetup () {
|
||||||
|
|
||||||
my $mapnum=0;
|
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 (@) {
|
sub preprocess (@) {
|
||||||
my %params=@_;
|
my %params=@_;
|
||||||
|
|
||||||
|
@ -63,7 +76,7 @@ sub preprocess (@) {
|
||||||
my $show=sub {
|
my $show=sub {
|
||||||
my $item=shift;
|
my $item=shift;
|
||||||
if (! $shown{$item}) {
|
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;
|
$shown{$item}=1;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -74,7 +87,7 @@ sub preprocess (@) {
|
||||||
foreach my $endpoint ($item, $link) {
|
foreach my $endpoint ($item, $link) {
|
||||||
$show->($endpoint);
|
$show->($endpoint);
|
||||||
}
|
}
|
||||||
print OUT "\"$item\" -> \"$link\";\n";
|
print OUT pageescape($item)." -> ".pageescape($link).";\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
print OUT "}\n";
|
print OUT "}\n";
|
||||||
|
|
Loading…
Reference in New Issue