Ran across this little vim gem:
:runtime! syntax/2html.vim
Basically it writes out the buffer as html with your syntax highlighting. I modified the script to not include the html headers and instead wrap the whole thing in my stylesheet class for code. I also modified the script to change tabs to a few spaces so that my code fits better on a web page.
:help 2html
for details on the function. If you’d like my modified version, lemme know. Here’s what it looks like when I paste the script’s output to a story:
#!/usr/bin/perl -lw
# Authors: Jamin P. Gray <jamin@pubcrawler.org>
# Purpose: Convenience script to send a cluepacket to Dashboard from
# the command line
use Getopt::Long;
use Dashboard;
Getopt::Long::Configure("bundling");
my @clues = ();
GetOptions("frontend|f=s" => \$frontend,
"context|x=s" => \$context,
"focused|F" => \$focused,
"clue|c=s" => \@clues,
"help|?" => \$help);
&print_usage if (defined($help));
$frontend = "dashboard-send" unless defined $frontend;
$context = "dashboard-send" unless defined $context;
$focused = 0 unless defined $focused;
my @Clues;
for (@clues) {
my ($type, $relevance, $text);
if (/(\w+) (\w+) (.+)/) {
$type = $1;
$relevance = $2;
$text = $3;
} else {
&print_usage;
}
push @Clues,
{
'data' => $text,
'type' => $type,
'relevance' => $relevance
};
}
my $dash = new Dashboard($frontend);
$dash->send_cluepacket($context, $focused, \@Clues);
sub print_usage {
print qq{
Usage: dashboard-send [OPTIONS]
Sends a cluepacket to Dashboard
-f, --frontend=WORD frontend is WORD
-x, --context=WORD context is WORD
-F, --focused frontend is focused
-c, --clue="TYPE RELEVANCE TEXT" --clue can be repeated for
a cluepacket with multiple
clues. TYPE is cluetype.
RELEVANCE is integer 1-10.
--help display this help and exit
Example:
dashboard-send --frontend myfrontend --context mycontext -F
--clue "textblock 10 testing script"
--clue "textblock 9 test2"
};
exit 0;
}
Tags: Meta










March 15th, 2005 at 8:22 pm
note: when I converted the blog from movable type to wordpress, the colors were lost. it really does work, though.