# some comment
for (@array) {
... # showing incredible loop usage example!
}
<" and & chars in your code?$inline @variables and Module::Names that
you want to stand out from the rest of the line?
gvim -n -c ':so $VIMRUNTIME/syntax/2html.vim' -c ':wqa' script.pl
gvim installed.gvim rather than vim due to gvim outputting, IMHO, nicer colors.gvim -h for explanations of command line arguments.gvim solution not so good...pre tags) into
your presentation source.For example this: <font color="#a52a2a"><b>my</b></font> Creates this: my
perl -ane'$sum=$F[0]+$F[1];print"$sum\n"'Yuck! No real highlighting there!
Text::VimColor to the rescueText::VimColor Usage$code scalar:
my $syntax = Text::VimColor->new( vim_command => '/bin/vim', string => $code, filetype => 'perl', ); my $html = $syntax->html;
Text::VimColor installation directory.<pre class="perlcode">...code here...</pre># place all content into the $content var, then: $content =~ s/(<pre class="perlcode">)(.+?)(<\/pre>)/ "$1\n" . code2html($2) . "\n$3" /gse; sub code2html { my $code = shift; my $syntax = Text::VimColor->new( vim_command => '/bin/vim', string => $code, filetype => 'perl', ); my $html = $syntax->html; for ($html) { s/^\s+//s; s/\s+$//s; } return $html; }
$content =~ s/(<pre class="perl-e-code">)(.+?)(<\/pre>)/ "$1\n" . code2html2($2) . "\n$3" /gse; sub code2html2 { my $code = shift; $code =~ s/'(.+?)'/"'".code2html($1)."'"/gse; return $code; }
perl -ane'$sum=$F[0]+$F[1];print"$sum\n"'
Vim based method has some disadvantages: slow, requires that Vim be installed.my $syntax = Text::VimColor->new( vim_command => '/bin/vim', string => $code, filetype => 'perl', ); my $html = $syntax->html;
Offer Kaye.
Slides automatically generated by tmpl2slides.pl. Last updated on Sun Dec 5 01:43:31 2004