Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Format POD as XHTML with embedded stylesheet

by TGI (Parson)
on Jun 09, 2006 at 20:39 UTC ( #554548=sourcecode: print w/replies, xml ) Need Help??
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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: sourcecode [id://554548]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (8)
As of 2020-09-25 08:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If at first I donít succeed, I Ö










    Results (136 votes). Check out past polls.

    Notices?