=head1 NAME B - Moveable Type plugin to provides a source codes of the Vim color syntax =head1 SYNOPSIS Once installed in your Movable Type plugins directory, the following new attribute will be available for use within templates: <$MTEntryBody vimcolor="perl"$> =head1 REQUIRES Movable Type L =head1 DESCRIPTION See the url: http://blog.drry.jp/2005/02/27/0009 Original version is antipop L by kentaro. =cut package MT::Plugin::VimColor; use strict; use Text::VimColor; use MT; use MT::Template::Context; use vars qw($VERSION); $VERSION = "0.2.20050316.drry"; if (MT->version_number >= 3) { use MT::Plugin; my $plugin = new MT::Plugin(); $plugin->name("VimColor"); # $plugin->config_link(""); $plugin->description("Adds span tags to source codes with the Vim color syntax. (Version $VERSION)"); $plugin->doc_link("http://blog.drry.jp/2005/02/27/0009"); MT->add_plugin($plugin); } MT::Template::Context->add_global_filter(vim_color => \&syntax_mark); sub syntax_mark { my @strings = split /(.+?<\/code><\/pre>)/s, shift; my $filetype = shift; my $string = shift @strings; foreach (@strings) { my $syntax = Text::VimColor->new(filetype => s|(]*>]*?) class="(\w*)"([^>]*>.+?)|$1.$3|se ? $2: $filetype); s|(]*?>]*?>\s*)(.+?)(\s*)|$1.$syntax->syntax_mark_string(unescape($2))->html.$3|se; $string .= $_; } return $string; } sub unescape { my $string = shift; $string =~ s/"/"/g; $string =~ s/<//g; $string =~ s/&/&/g; return $string; } 1; __END__ =head1 SEE ALSO L L L =head1 KNOWN BUGS None. =head1 TODO None. =head1 LICENSE ? =head1 AUTHOR kentaro L drry L =cut