apply Changaco's patch to make headinganchors more like mediawiki's

master
Joey Hess 2011-06-21 15:20:57 -04:00
parent b5a669f34b
commit ee8ff9d1c7
1 changed files with 7 additions and 4 deletions

View File

@ -5,6 +5,7 @@ package IkiWiki::Plugin::headinganchors;
use warnings;
use strict;
use IkiWiki 3.00;
use URI::Escape;
sub import {
hook(type => "getsetup", id => "headinganchors", call => \&getsetup);
@ -24,9 +25,11 @@ sub text_to_anchor {
my $str = shift;
$str =~ s/^\s+//;
$str =~ s/\s+$//;
$str = lc($str);
$str =~ s/[&\?"\'\.,\(\)!]//mig;
$str =~ s/[^a-z]/_/mig;
$str =~ s/\s/_/g;
$str =~ s/"//g;
$str =~ s/^[^a-zA-Z]/z-/; # must start with an alphabetical character
$str = uri_escape_utf8($str);
$str =~ s/%/./g;
return $str;
}