use strict; use HTML::TreeBuilder; use Template; use Syntax::Highlight::Perl; use HTML::Entities; # Rechtstreeks uit http://tnx.nl/scribble.plp sub tidy { require Syntax::Highlight::Perl; my ($data) = @_; $data = decode_entities($data); my $hl = Syntax::Highlight::Perl->new; $hl->define_substitution( '<' => '<', '>' => '>', '&' => '&', "\t" => '        ', ' ' => ' ', ); $hl->set_format( $_ => [ "", "" ] ) for qw/Comment Directive Label Quote String Subroutine Variable Keyword Builtin Operator Package Number CodeTerm Symbol DATA/; return $hl->format_string($data); } my $tree = HTML::TreeBuilder->new; $tree->parse_file('slides.html'); my $i = 0; my $sf = 'slide%d.html'; my $tt = Template->new({INCLUDE_PATH => '.'}); my @slides = $tree->look_down(_tag => 'div'); my $index = '
'; $tt->process( 'slide.html', { title => 'Index', slide => $index, index => 0, total => scalar @slides, first => sprintf($sf, 1), }, sprintf($sf, 0) ) or die $tt->error;