summaryrefslogtreecommitdiff
path: root/pod/pod2latex.PL
diff options
context:
space:
mode:
authorRafael Garcia-Suarez <rgarciasuarez@gmail.com>2004-06-08 18:51:03 +0000
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2004-06-08 18:51:03 +0000
commit72e5dea67722deb16f01b7f031b918a1919efc18 (patch)
tree5bb05854970d90cc7a11a0750c5d2f5e97f74fde /pod/pod2latex.PL
parenta092bcfd0f738c1ea0511ee4fa058ee96e488fcb (diff)
downloadperl-72e5dea67722deb16f01b7f031b918a1919efc18.tar.gz
Upgrade to Pod::LaTeX 0.57
p4raw-id: //depot/perl@22912
Diffstat (limited to 'pod/pod2latex.PL')
-rw-r--r--pod/pod2latex.PL76
1 files changed, 67 insertions, 9 deletions
diff --git a/pod/pod2latex.PL b/pod/pod2latex.PL
index 6b4dc4c86e..9838edc889 100644
--- a/pod/pod2latex.PL
+++ b/pod/pod2latex.PL
@@ -43,8 +43,20 @@ use Pod::Find qw/ pod_find /;
use Pod::Usage;
use Getopt::Long;
use File::Basename;
-
-my $VERSION = "1.00";
+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
@@ -57,7 +69,14 @@ my %options = (
"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",
@@ -68,6 +87,10 @@ GetOptions(\%options,
"out=s",
"modify",
"h1level=i",
+ "preamble=s@",
+ "postamble=s@",
+ "prefile=s",
+ "postfile=s"
) || pod2usage(2);
pod2usage(1) if ($options{help});
@@ -98,6 +121,14 @@ if ($#pods == -1) {
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
@@ -133,6 +164,7 @@ if ($multi_documents) {
UniqueLabels => $options{'modify'},
Head1Level => $options{'h1level'},
LevelNoNum => $options{'h1level'} + 1,
+ %User,
);
# Select sections if supplied
@@ -150,7 +182,7 @@ if ($multi_documents) {
}
} else {
-
+
# Case where we want everything to be in a single document
# Need to open the output file ourselves
@@ -158,7 +190,6 @@ if ($multi_documents) {
$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";
@@ -202,6 +233,7 @@ if ($multi_documents) {
AddPostamble => $postamble,
Head1Level => $options{'h1level'},
LevelNoNum => $options{'h1level'} + 1,
+ %User
);
# Store the file name for error messages
@@ -251,6 +283,8 @@ pod2latex - convert pod documentation to latex format
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
@@ -319,6 +353,30 @@ Print the manual page 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
@@ -327,14 +385,14 @@ Known bugs are:
=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.
@@ -346,12 +404,12 @@ L<Pod::LaTeX>
=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, 2003 Tim Jenness. All Rights Reserved.
+Copyright (C) 2000, 2003, 2004 Tim Jenness. All Rights Reserved.
=cut