App-Pod2Epub

 view release on metacpan or  search on metacpan

lib/App/Pod2Epub.pm  view on Meta::CPAN

package App::Pod2Epub;

###############################################################################
#
# App::Pod2Epub - Convert Pod to an ePub eBook.
#
#
# Copyright 2010-2012, John McNamara, jmcnamara@cpan.org
#
# Documentation after __END__
#

use strict;
use warnings;
use Pod::Simple::XHTML;

use vars qw(@ISA $VERSION);

@ISA     = 'Pod::Simple::XHTML';
$VERSION = '0.05';

###############################################################################
#
# new()
#
# Simple constructor inheriting from Pod::Simple::XHTML.
#
sub new {

    my $class = shift;
    my $self  = Pod::Simple::XHTML->new( @_ );

    # Don't generate an XHTML index. We will use the ePub TOC instead.
    $self->index(0);

    # Add the default XHTML headers.
    $self->html_header(

        qq{<?xml version="1.0" encoding="UTF-8"?>\n}
          . qq{<!DOCTYPE html\n}
          . qq{     PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"\n}
          . qq{    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\n}
          . qq{\n}
          . qq{<html xmlns="http://www.w3.org/1999/xhtml">\n}
          . qq{<head>\n}
          . qq{<title></title>\n}
          . qq{<meta http-equiv="Content-Type" }
          . qq{content="text/html; charset=iso-8859-1"/>\n}
          . qq{<link rel="stylesheet" href="../styles/style.css" }
          . qq{type="text/css"/>\n}
          . qq{</head>\n}
          . qq{\n}
          . qq{<body>\n}
    );


    bless $self, $class;
    return $self;
}


1;

__END__

=pod

=head1 NAME

App::Pod2Epub - Convert Pod to an ePub eBook.

=head1 DESCRIPTION

This module is used for converting Pod documents to ePub eBooks. The output eBook can be read on a variety of hardware and software eBook readers.

Pod is Perl's I<Plain Old Documentation> format, see L<http://perldoc.perl.org/perlpod.html>. EPub is an eBook format, see L<http://en.wikipedia.org/wiki/Epub>.

This module comes with a L<pod2epub> utility that will convert Pod to an ePub eBook.


=head1 SYNOPSIS


To create a simple filter to convert Pod to an XHTML format suitable for inclusion in an ePub eBook.

    #!/usr/bin/perl -w

    use strict;
    use App::Pod2Epub;


    my $parser = App::Pod2Epub->new();

    if (defined $ARGV[0]) {
        open IN, $ARGV[0]  or die "Couldn't open $ARGV[0]: $!\n";
    } else {
        *IN = *STDIN;
    }

    if (defined $ARGV[1]) {
        open OUT, ">$ARGV[1]" or die "Couldn't open $ARGV[1]: $!\n";
    } else {
        *OUT = *STDOUT;
    }

    $parser->output_fh(*OUT);
    $parser->parse_file(*IN);



( run in 2.641 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )