2006-07-26 23:54:44 +02:00
|
|
|
#!/usr/bin/perl
|
|
|
|
# CamelCase links
|
|
|
|
package IkiWiki::Plugin::camelcase;
|
|
|
|
|
|
|
|
use warnings;
|
|
|
|
use strict;
|
2007-04-27 04:55:52 +02:00
|
|
|
use IkiWiki 2.00;
|
2006-07-26 23:54:44 +02:00
|
|
|
|
|
|
|
sub import { #{{{
|
2006-09-10 00:50:27 +02:00
|
|
|
hook(type => "filter", id => "camelcase", call => \&filter);
|
2006-07-26 23:54:44 +02:00
|
|
|
} # }}}
|
|
|
|
|
|
|
|
sub filter (@) { #{{{
|
|
|
|
my %params=@_;
|
|
|
|
|
|
|
|
# Make CamelCase links work by promoting them to fullfledged
|
|
|
|
# WikiLinks. This regexp is based on the one in Text::WikiFormat.
|
2007-06-02 01:40:43 +02:00
|
|
|
$params{content}=~s{
|
|
|
|
(?<![[|"/>=]) # try to avoid expanding non-links
|
|
|
|
# with a zero width negative lookbehind for
|
|
|
|
# characters that suggest it's not a link
|
|
|
|
\b # word boundry
|
|
|
|
(
|
|
|
|
(?:
|
|
|
|
[A-Z] # Uppercase start
|
|
|
|
[a-z0-9] # followed by lowercase
|
|
|
|
\w* # and rest of word
|
|
|
|
)
|
|
|
|
{2,} # repeated twice
|
|
|
|
)
|
|
|
|
}{[[$1]]}gx;
|
2006-07-26 23:54:44 +02:00
|
|
|
|
|
|
|
return $params{content};
|
|
|
|
} #}}}
|
|
|
|
|
|
|
|
1
|