]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blob - doc/plugins/headinganchors/discussion.mdwn
cross-reference i18nheadinganchors
[git.ikiwiki.info.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/headinganchors]]'s functionality and the TOC generation itself. That will bring more order into the code and the set of available plugins. --Ivan Z.
3 > Indeed it is. Except [[plugins/toc]] generates headings differently - and independently of this. *Even* if [[toc]]'s functionality would be split, you'd probably want to retain backwards compatibility there, so it's unlikely that this will happen... Also see [[todo/toc-with-human-readable-anchors]]. --[[anarcat]]
5 ---
7 A patch to make it more like MediaWiki:
9 <pre>--- headinganchors.pm
10 +++ headinganchors.pm
11 @@ -5,6 +5,7 @@
12  use warnings;
13  use strict;
14  use IkiWiki 2.00;
15 +use URI::Escape;
16  
17  sub import {
18          hook(type => "sanitize", id => "headinganchors", call => \&headinganchors);
19 @@ -14,9 +15,11 @@
20          my $str = shift;
21          $str =~ s/^\s+//;
22          $str =~ s/\s+$//;
23 -        $str = lc($str);
24 -        $str =~ s/[&\?"\'\.,\(\)!]//mig;
25 -        $str =~ s/[^a-z]/_/mig;
26 +        $str =~ s/\s/_/g;
27 +        $str =~ s/"//g;
28 +        $str =~ s/^[^a-zA-Z]/z-/; # must start with an alphabetical character
29 +        $str = uri_escape_utf8($str);
30 +        $str =~ s/%/./g;
31          return $str;
32  }
33  </pre>
35 --Changaco
37 > This was applied in 3.20110608 --[[smcv]]
39 ----
41 I think using this below would let the source html clear for the browser
42 without changing the render:
44         #use URI::Escape
45         .
46         .
48         #$str = uri_escape_utf8($str);
49         $str = Encode::decode_utf8($str);
50         #$str =~ s/%/./g;
52 Don't you think ?
53 [[mathdesc]]
55 > Older HTML and URI specifications didn't allow Unicode in IDs or fragments,
56 > but HTML5 and IRIs do. See also [[plugins/contrib/i18nheadinganchors]]
57 > and its [[plugins/contrib/i18nheadinganchors/discussion]] page.
58 >
59 > I think we should probably try to make these autogenerated IDs
60 > punctuation-independent by stripping most non-word characters, like
61 > Pandoc does: I would not expect changing
62 > `## Headings, maybe with punctuation` to
63 > `## Headings (maybe with punctuation)` to have any effect on the
64 > generated "slug" `headings-maybe-with-punctuation`. --[[smcv]]