X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=pod%2Fpod2latex.PL;h=9838edc889d7a02dc2068064fdb7dffe8f0448db;hb=9f621bb00a11fa3741b155ff668ae147fed95cf0;hp=002f06dca1cb49254c6cbe56fdb670a1f22ce390;hpb=1826411a4d1d01fc62c0c7f61ae006f489a962fc;p=p5sagit%2Fp5-mst-13.2.git diff --git a/pod/pod2latex.PL b/pod/pod2latex.PL index 002f06d..9838edc 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 is a program to convert POD format documentation @@ -260,7 +294,7 @@ combined output file. =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 @@ -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 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 =head1 AUTHOR -Tim Jenness Et.jenness@jach.hawaii.eduE +Tim Jenness Etjenness@cpan.orgE 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