| Kwiki-VimMode documentation | Contained in the Kwiki-VimMode distribution. |
Kwiki::VimMode - VimMode preformatted forms of text
$ cpan Kwiki::VimMode $ cd /path/to/kwiki $ echo "Kwiki::VimMode" >> plugins $ kwiki -update
This module allows you to hilight the syntax of any text mode that the Vim editor recognizes:
Here's some *HTML* and *Perl* for you to grok:
.vim
<html>
<head>
<title>Highlighted stuff!</title>
</head>
<body>
<em>Check</em> <strong>this</strong>
<code>out!</code>
</body>
</html>
.vim
.vim
#!/usr/bin/perl
# sample perl
$name = 'Kwiki';
print "Check out $name!\n";
.vim
Text::VimColor/Vim should hopefully pick up the correct syntax automatically. If it doesn't, precede your text in the .vim block with filetype: name, where name is a valid Vim syntax name. For example:
.vim
filetype: apache
<VirtualHost>
ServerName www.me.org
# ...
</VirtualHost>
.vim
It doesn't work on Mac OS X! Check out https://rt.cpan.org/NoAuth/Bug.html?id=7316
Ian Langworth <ian@cpan.org>
Copyright (C) 2004 by Ian Langworth
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
| Kwiki-VimMode documentation | Contained in the Kwiki-VimMode distribution. |
package Kwiki::VimMode; use strict; use warnings; use Kwiki::Plugin -Base; use Kwiki::Installer -base; our $VERSION = 0.05; const class_title => 'color hiliting using Vim'; const class_id => 'vim_mode'; const css_file => 'vim_mode.css'; sub register { my $registry = shift; $registry->add( wafl => vim => 'Kwiki::VimMode::Wafl' ); } package Kwiki::VimMode::Wafl; use base 'Spoon::Formatter::WaflBlock'; sub to_html { require Text::VimColor; my $string = $self->block_text; chomp $string; $ENV{PATH} = "/usr/local/bin:$ENV{PATH}"; $string =~ s/^ filetype: \s* (\w+) \s* \n+//sx; my @filetype = $1 ? ( filetype => $1 ) : (); my $vim = Text::VimColor->new( string => $string, @filetype, vim_options => [ qw( -RXZ -i NONE -u NONE -N ), "+set nomodeline" ] ); return '<pre class="vim">' . $vim->html . "</pre>\n"; } package Kwiki::VimMode; __DATA__
__css/vim_mode.css__ pre.vim { margin-left: 1em } .synComment { color: #0000FF } .synConstant { color: #FF00FF } .synIdentifier { color: #008B8B } .synStatement { color: #A52A2A ; font-weight: bold } .synPreProc { color: #A020F0 } .synType { color: #2E8B57 ; font-weight: bold } .synSpecial { color: #6A5ACD } .synUnderlined { color: #000000 ; text-decoration: underline } .synError { color: #FFFFFF ; background: #FF0000 none } .synTodo { color: #0000FF ; background: #FFFF00 none }