apply Changaco's patch to make headinganchors more like mediawiki's
parent
b5a669f34b
commit
ee8ff9d1c7
|
@ -5,6 +5,7 @@ package IkiWiki::Plugin::headinganchors;
|
||||||
use warnings;
|
use warnings;
|
||||||
use strict;
|
use strict;
|
||||||
use IkiWiki 3.00;
|
use IkiWiki 3.00;
|
||||||
|
use URI::Escape;
|
||||||
|
|
||||||
sub import {
|
sub import {
|
||||||
hook(type => "getsetup", id => "headinganchors", call => \&getsetup);
|
hook(type => "getsetup", id => "headinganchors", call => \&getsetup);
|
||||||
|
@ -12,7 +13,7 @@ sub import {
|
||||||
}
|
}
|
||||||
|
|
||||||
sub getsetup () {
|
sub getsetup () {
|
||||||
return
|
return
|
||||||
plugin => {
|
plugin => {
|
||||||
safe => 1,
|
safe => 1,
|
||||||
rebuild => undef,
|
rebuild => undef,
|
||||||
|
@ -24,9 +25,11 @@ sub text_to_anchor {
|
||||||
my $str = shift;
|
my $str = shift;
|
||||||
$str =~ s/^\s+//;
|
$str =~ s/^\s+//;
|
||||||
$str =~ s/\s+$//;
|
$str =~ s/\s+$//;
|
||||||
$str = lc($str);
|
$str =~ s/\s/_/g;
|
||||||
$str =~ s/[&\?"\'\.,\(\)!]//mig;
|
$str =~ s/"//g;
|
||||||
$str =~ s/[^a-z]/_/mig;
|
$str =~ s/^[^a-zA-Z]/z-/; # must start with an alphabetical character
|
||||||
|
$str = uri_escape_utf8($str);
|
||||||
|
$str =~ s/%/./g;
|
||||||
return $str;
|
return $str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue