Category: HTML Utility
Author/Contact Info mark.swayne --- AT --- charter.net
Description: A simple script to convert pod into xhtml with an embedded stylesheet. I tend to write most of my notes in pod instead of using MS Word or similar tools, and I often need to provide a self contained html file to coworkers so that they can read my notes.

Call the script with a list of file names to process.

If a file named 'podder.css' is present in the current directory, it will be embedded in a style section of the the resulting html document. If no css file is present and you are using a perlapp executable with a podder file bound in, the bound file will be used instead.

Example:

    podder ApplicationNotes.pod  MyClass.pm

The above invocation will generate two html files: ApplicationNotes.xhtml and MyClass.xhtml.

Perl source:

use warnings;
use strict;

use Pod::Xhtml;
use File::Basename;

my $stylesheet = '';
if ( open( STYLE, '<', 'podder.css' ) ) {

    $stylesheet = join '', <STYLE>;

} elsif ( defined $PerlApp::VERSION ) {

    $stylesheet = PerlApp::get_bound_file('podder.css');

}

my $style = <<"END_XHTML";
<style type="text/css">
$stylesheet
</style>
END_XHTML

foreach my $file ( @ARGV ) {

    my $base = basename( $file, '.pod', '.pm', '.pl');

    my $p = Pod::Xhtml->new;

    $p->addHeadText( $style );
    $p->parse_from_file( $file, "$base.xhtml" );

}

Here's the perlapp prject file to generate an executable:

PAP-Version: 1.0
Packer: C:\Program Files\ActiveState Perl Dev Kit 6.0 Deployment\bin\p
+erlapp.exe
Bind: podder.css[file=podder.css,text,mode=666]
Clean: 
Exe: podder.exe
Script: podder.pl
Shared: none