Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Format POD as XHTML with embedded stylesheet

by TGI (Parson)
on Jun 09, 2006 at 20:39 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: sourcecode [id://554548]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (3)
As of 2026-01-20 15:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your view on AI coding assistants?





    Results (125 votes). Check out past polls.

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.