# pod2latex conversion program
+use strict;
use Pod::LaTeX;
use Pod::Find qw/ pod_find /;
use Pod::Usage;
use Getopt::Long;
use File::Basename;
+use Symbol;
+
+my $VERSION = "1.01";
+
+# return the entire contents of a text file
+# whose name is given as argument
+sub _get {
+ my $fn = shift;
+ my $infh = gensym;
+ open $infh, $fn
+ or die "Could not open file $fn: $!\n";
+ local $/;
+ return <$infh>;
+}
# Read command line arguments
"out" => undef,
"verbose" => 0,
"modify" => 0,
+ "h1level" => 1, # section is equivalent to H1
+ "preamble" => [],
+ "postamble" => [],
);
+# "prefile" is just like "preamble", but the argument
+# comes from the file named by the argument
+$options{"prefile"} = sub { shift; push @{$options{"preamble"}}, _get(shift) };
+# the same between "postfile" and "postamble"
+$options{"postfile"} = sub { shift; push @{$options{"postamble"}}, _get(shift) };
GetOptions(\%options,
"help",
"sections=s@",
"out=s",
"modify",
+ "h1level=i",
+ "preamble=s@",
+ "postamble=s@",
+ "prefile=s",
+ "postfile=s"
) || pod2usage(2);
pod2usage(1) if ($options{help});
exit;
}
+# Only want to override the preamble and postamble if we have
+# been given values.
+my %User;
+$User{UserPreamble} = join("\n", @{$options{'preamble'}})
+ if ($options{preamble} && @{$options{preamble}});
+$User{UserPostamble} = join("\n", @{$options{'postamble'}})
+ if ($options{postamble} && @{$options{postamble}});
+
# If $options{'out'} is set we are processing to a single output file
TableOfContents => $options{'full'},
ReplaceNAMEwithSection => $options{'modify'},
UniqueLabels => $options{'modify'},
+ Head1Level => $options{'h1level'},
+ LevelNoNum => $options{'h1level'} + 1,
+ %User,
);
# Select sections if supplied
}
} else {
-
+
# Case where we want everything to be in a single document
# Need to open the output file ourselves
$output .= '.tex' unless $output =~ /\.tex$/;
# Use auto-vivified file handle in perl 5.6
- use Symbol;
my $outfh = gensym;
open ($outfh, ">$output") || die "Could not open output file: $!\n";
# if this is the first file to be converted we may want to add
# a preamble (controlled by command line option)
- if ($converted == 0 && $options{'full'}) {
- $preamble = 1;
- } else {
- $preamble = 0;
- }
+ my $preamble = 0;
+ $preamble = 1 if ($converted == 0 && $options{'full'});
# if this is the last file to be converted may want to add
# a postamble (controlled by command line option)
StartWithNewPage => $options{'full'},
AddPreamble => $preamble,
AddPostamble => $postamble,
+ Head1Level => $options{'h1level'},
+ LevelNoNum => $options{'h1level'} + 1,
+ %User
);
# Store the file name for error messages
pod2latex -full -sections 'DESCRIPTION|NAME' SomeDir
+ pod2latex -prefile h.tex -postfile t.tex my.pod
+
=head1 DESCRIPTION
C<pod2latex> is a program to convert POD format documentation
=head1 OPTIONS AND ARGUMENTS
-This section describes the supported command line options. Minium
+This section describes the supported command line options. Minimum
matching is supported.
=over 4
Also forces C<latex> label and index entries to be prefixed by the
name of the module.
+=item B<-h1level>
+
+Specifies the C<latex> section that is equivalent to a C<H1> pod
+directive. This is an integer between 0 and 5 with 0 equivalent to a
+C<latex> chapter, 1 equivalent to a C<latex> section etc. The default
+is 1 (C<H1> equivalent to a latex section).
+
=item B<-help>
Print a brief help message and exit.
Print information messages as each document is processed.
+=item B<-preamble>
+
+A user-supplied preamble for the LaTeX code. Multiple values
+are supported and appended in order separated by "\n".
+See B<-prefile> for reading the preamble from a file.
+
+=item B<-postamble>
+
+A user supplied postamble for the LaTeX code. Multiple values
+are supported and appended in order separated by "\n".
+See B<-postfile> for reading the postamble from a file.
+
+=item B<-prefile>
+
+A user-supplied preamble for the LaTeX code to be read from the
+named file. Multiple values are supported and appended in
+order. See B<-preamble>.
+
+=item B<-postfile>
+
+A user-supplied postamble for the LaTeX code to be read from the
+named file. Multiple values are supported and appended in
+order. See B<-postamble>.
+
=back
=head1 BUGS
=over 4
-=item *
+=item *
Cross references between documents are not resolved when multiple
pod documents are converted into a single output C<latex> file.
-=item *
+=item *
-Functions and variables are not automatically recognized
+Functions and variables are not automatically recognized
and they will therefore not be marked up in any special way
unless instructed by an explicit pod command.
=head1 AUTHOR
-Tim Jenness E<lt>t.jenness@jach.hawaii.eduE<gt>
+Tim Jenness E<lt>tjenness@cpan.orgE<gt>
This program is free software; you can redistribute it
and/or modify it under the same terms as Perl itself.
-Copyright (C) 2000 Tim Jenness.
+Copyright (C) 2000, 2003, 2004 Tim Jenness. All Rights Reserved.
=cut