]> sipb.mit.edu Git - ikiwiki.git/blob - doc/plugins/headinganchors/discussion.mdwn
151af8d92b31b827836b4d12a7063ca440654162
[ikiwiki.git] / doc / plugins / headinganchors / discussion.mdwn
1 Isn't this functionality a part of what [[plugins/toc]] needs and does? Then probably the [[plugins/toc]] plugin's code could be split into the part that implements the [[plugins/contrib/headinganchors]]'s functionality and the TOC generation itself. That will bring more order into the code and the set of available plugins. --Ivan Z.
2
3 ---
4
5 A patch to make it more like MediaWiki:
6
7 <pre>--- headinganchors.pm
8 +++ headinganchors.pm
9 @@ -5,6 +5,7 @@
10  use warnings;
11  use strict;
12  use IkiWiki 2.00;
13 +use URI::Escape;
14  
15  sub import {
16          hook(type => "sanitize", id => "headinganchors", call => \&headinganchors);
17 @@ -14,9 +15,11 @@
18          my $str = shift;
19          $str =~ s/^\s+//;
20          $str =~ s/\s+$//;
21 -        $str = lc($str);
22 -        $str =~ s/[&\?"\'\.,\(\)!]//mig;
23 -        $str =~ s/[^a-z]/_/mig;
24 +        $str =~ s/\s/_/g;
25 +        $str =~ s/"//g;
26 +        $str =~ s/^[^a-zA-Z]/z-/; # must start with an alphabetical character
27 +        $str = uri_escape_utf8($str);
28 +        $str =~ s/%/./g;
29          return $str;
30  }
31  </pre>
32
33 --Changaco