### Wikipedia へのリンクプラグイン
# usage: {{wikipedia('word','country')}}
sub wikipedia {
my $default = 'ja';
my ($str,$country) = @_;
if (!defined($country)){
$country = $default;
}
my $prefix = qq(http://$country.wikipedia.org/wiki);
my $enc = Jcode->new($str)->utf8;
$enc =~ s/([^0-9a-z_ ])/'%'.unpack('H2', $1)/gei;
$enc =~ s/\s/+/g;
return qq(<a href="$prefix/$enc" title="Wikipedia ($country) - $str">Wikipedia - $str</a>);
}
旧
### Wikipedia へのリンクプラグイン
# usage: {{wikipedia('word')}}
sub wikipedia {
my ($str) = @_;
my $prefix = q(http://ja.wikipedia.org/wiki);
my $enc = Jcode->new($str)->utf8;
$enc =~ s/([^0-9a-z_ ])/'%'.unpack('H2', $1)/gei;
$enc =~ s/\s/+/g;
return qq(<a href="$prefix/$enc" title="Wikipedia - $str">Wikipedia - $str</a>);
}