aboutsummaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin
diff options
context:
space:
mode:
authorJoey Hess <joey@kitenet.net>2011-06-21 15:20:57 -0400
committerJoey Hess <joey@kitenet.net>2011-06-21 15:22:36 -0400
commitee8ff9d1c7e712906985ca7b7df708ac59732724 (patch)
treed7645a2b746f5d96097a8dcf0167c315dad805ca /IkiWiki/Plugin
parentb5a669f34b38da86b1260ac7a5abd7a63cfad4ac (diff)
downloadikiwiki-ee8ff9d1c7e712906985ca7b7df708ac59732724.tar
ikiwiki-ee8ff9d1c7e712906985ca7b7df708ac59732724.tar.gz
apply Changaco's patch to make headinganchors more like mediawiki's
Diffstat (limited to 'IkiWiki/Plugin')
-rw-r--r--IkiWiki/Plugin/headinganchors.pm11
1 files changed, 7 insertions, 4 deletions
diff --git a/IkiWiki/Plugin/headinganchors.pm b/IkiWiki/Plugin/headinganchors.pm
index b29150368..ece6f4eac 100644
--- a/IkiWiki/Plugin/headinganchors.pm
+++ b/IkiWiki/Plugin/headinganchors.pm
@@ -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);
@@ -12,7 +13,7 @@ sub import {
}
sub getsetup () {
- return
+ return
plugin => {
safe => 1,
rebuild => undef,
@@ -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;
}