| 1 |
#!/usr/bin/perl |
| 2 |
|
| 3 |
use strict; |
| 4 |
use Pod::Xhtml; |
| 5 |
use Pod::Usage; |
| 6 |
use Getopt::Long; |
| 7 |
|
| 8 |
# Default options |
| 9 |
my %opt = (index => 1, toplink => 'Top'); |
| 10 |
GetOptions(\%opt, qw(css=s toplink|backlink=s help index! infile:s outfile:s)) |
| 11 |
|| pod2usage(); |
| 12 |
pod2usage(-verbose => 2) if $opt{help}; |
| 13 |
|
| 14 |
my $toplink = $opt{toplink} ? |
| 15 |
sprintf '<p><a href="#TOP" class="toplink">%s</a></p>', $opt{toplink} : ''; |
| 16 |
|
| 17 |
my $parser = new Pod::Xhtml( |
| 18 |
MakeIndex => $opt{index}, |
| 19 |
TopLinks => $toplink, |
| 20 |
); |
| 21 |
if ($opt{css}) { |
| 22 |
$parser->addHeadText(qq[<link rel="stylesheet" href="$opt{css}"/>]); |
| 23 |
} |
| 24 |
|
| 25 |
$parser->parse_from_file($opt{infile}, $opt{outfile}); |
| 26 |
|
| 27 |
__DATA__ |
| 28 |
|
| 29 |
=pod |
| 30 |
|
| 31 |
=head1 NAME |
| 32 |
|
| 33 |
pod2xhtml - convert .pod files to .xhtml files |
| 34 |
|
| 35 |
=head1 SYNOPSIS |
| 36 |
|
| 37 |
pod2xhtml [--help] [--infile INFILE] [--outfile OUTFILE] [OPTIONS] |
| 38 |
|
| 39 |
=head1 DESCRIPTION |
| 40 |
|
| 41 |
Converts files from pod format (see L<perlpod>) to XHTML format. |
| 42 |
|
| 43 |
=head1 OPTIONS |
| 44 |
|
| 45 |
pod2xhtml takes the following arguments: |
| 46 |
|
| 47 |
=over 4 |
| 48 |
|
| 49 |
=item * |
| 50 |
|
| 51 |
--help - display help |
| 52 |
|
| 53 |
=item * |
| 54 |
|
| 55 |
--infile FILENAME |
| 56 |
- the input filename. STDIN is used otherwise |
| 57 |
|
| 58 |
=item * |
| 59 |
|
| 60 |
--outfile FILENAME |
| 61 |
- the output filename. STDOUT is used otherwise |
| 62 |
|
| 63 |
=item * |
| 64 |
|
| 65 |
--css URL |
| 66 |
- Stylesheet URL |
| 67 |
|
| 68 |
=item * |
| 69 |
|
| 70 |
--index/--noindex |
| 71 |
- generate an index, or not. The default is to create an index. |
| 72 |
|
| 73 |
=item * |
| 74 |
|
| 75 |
--toplink LINK TEXT |
| 76 |
- set text for "back to top" links. The default is 'Top'. |
| 77 |
|
| 78 |
=back |
| 79 |
|
| 80 |
=head1 BUGS |
| 81 |
|
| 82 |
See L<Pod::Xhtml> for a list of known bugs in the translator. |
| 83 |
|
| 84 |
=head1 AUTHOR |
| 85 |
|
| 86 |
P Kent E<lt>cpan _at_ bbc _dot_ co _dot_ ukE<gt> |
| 87 |
|
| 88 |
=head1 COPYRIGHT |
| 89 |
|
| 90 |
(c) BBC 2004. This program is free software; you can redistribute it and/or |
| 91 |
modify it under the GNU GPL. |
| 92 |
|
| 93 |
See the file COPYING in this distribution, or http://www.gnu.org/licenses/gpl.txt |
| 94 |
|
| 95 |
=head1 SEE ALSO |
| 96 |
|
| 97 |
L<perlpod>, L<Pod::Xhtml> |
| 98 |
|
| 99 |
=cut |