]> scripts.mit.edu Git - www/ikiwiki.git/blob - doc/plugins/headinganchors/discussion.mdwn
Sugesstion usgin decode_utf8 instead of escaping them
[www/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
34
35 ----
36
37 I think using this below would let the source html clear for the browser
38 without changing the render:
39
40         #use URI::Escape
41         .
42         .
43
44         #$str = uri_escape_utf8($str);
45         $str = Encode::decode_utf8($str);
46         #$str =~ s/%/./g;
47
48 Don't you think ?
49 [[mathdesc]]