EBook-Tools

 view release on metacpan or  search on metacpan

scripts/ebook.pl  view on Meta::CPAN


The first non-option argument is taken to be the input file.  The
second non-option argument is taken to be the basename of the output
files.

=cut

sub splitpre
{
    my ($infile,$outfilebase) = @_;
    if(!$infile)
    {
        print {*STDERR} "You must specify a file to parse.\n";
        exit(EXIT_BADOPTION);
    }
    split_pre($infile,$outfilebase);
    return 0;
}


=head2 C<stripscript>

Strips <script>...</script> blocks out of a HTML file.

The first non-option argument is taken to be the input file.  The
second non-option argument is taken to be the output file.  If the
latter is not specified, the input file will be overwritten.

=head3 Options

=over

=item * C<--noscript>

Strips <noscript>...</noscript> blocks as well.

=back

=cut

sub stripscript
{
    my ($infile,$outfile) = @_;

    if(!$infile)
    {
        print "You must specify an input file.\n";
        exit(EXIT_BADOPTION);
    }
    my %args;
    $args{infile} = $infile;
    $args{outfile} = $outfile;
    $args{noscript} = $opt{noscript};

    strip_script(%args);
    return 0;
}

=head2 C<tidyxhtml>

Run tidy on a HTML file to enforce valid XHTML output (required by the
OPF 2.0 specification).

=cut

sub tidyxhtml
{
    my ($inputfile,$tidyfile) = @_;
    my $retval;

    if(!$inputfile)
    {
        print "You must specify an input file to tidy.\n";
        exit(EXIT_BADOPTION);
    }

    if($tidyfile) { $retval = system_tidy_xhtml($inputfile,$tidyfile); }
    else { $retval = system_tidy_xhtml($inputfile); }
    exit($retval);
}


=head2 C<tidyxml>

Run tidy an a XML file (for neatness).

=cut

sub tidyxml
{
    my ($inputfile,$tidyfile) = @_;
    my $retval;

    if(!$inputfile)
    {
        print "You must specify an input file to tidy.\n";
        exit(EXIT_BADOPTION);
    }

    if($tidyfile) { $retval = system_tidy_xml($inputfile,$tidyfile); }
    else { $retval = system_tidy_xml($inputfile); }
    exit($retval);
}


=head2 C<unpack_ebook>

Unpacks an ebook into its component parts, creating an OPF for them if
necessary.

=head3 Options

=over

=item C<--input>
=item C<-i>

The filename of the ebook to unpack.  This can also be specified as
the first non-option argument, in which case it will override the
option if it exists.



( run in 0.677 second using v1.01-cache-2.11-cpan-7e98afdb40f )