]> sipb.mit.edu Git - ikiwiki.git/blob - IkiWiki/Plugin/camelcase.pm
* Support for looking in multiple directories for underlay files.
[ikiwiki.git] / IkiWiki / Plugin / camelcase.pm
1 #!/usr/bin/perl
2 # CamelCase links
3 package IkiWiki::Plugin::camelcase;
4
5 use warnings;
6 use strict;
7 use IkiWiki 2.00;
8
9 sub import { #{{{
10         hook(type => "filter", id => "camelcase", call => \&filter);
11 } # }}}
12
13 sub filter (@) { #{{{
14         my %params=@_;
15
16         # Make CamelCase links work by promoting them to fullfledged
17         # WikiLinks. This regexp is based on the one in Text::WikiFormat.
18         $params{content}=~s{
19                 (?<![[|"/>=])   # try to avoid expanding non-links
20                                 # with a zero width negative lookbehind for
21                                 # characters that suggest it's not a link
22                 \b              # word boundry
23                 (
24                         (?:
25                                 [A-Z]           # Uppercase start
26                                 [a-z0-9]        # followed by lowercase
27                                 \w*             # and rest of word
28                         )
29                         {2,}                    # repeated twice
30                 )
31         }{[[$1]]}gx;
32
33         return $params{content};
34 } #}}}
35
36 1