1N/A#!/usr/local/bin/perl
1N/A
1N/Ause Config;
1N/Ause File::Basename qw(&basename &dirname);
1N/Ause Cwd;
1N/A
1N/A# List explicitly here the variables you want Configure to
1N/A# generate. Metaconfig only looks for shell variables, so you
1N/A# have to mention them as if they were shell variables, not
1N/A# %Config entries. Thus you write
1N/A# $startperl
1N/A# to ensure Configure will look for $Config{startperl}.
1N/A
1N/A# This forces PL files to create target in same directory as PL file.
1N/A# This is so that make depend always knows where to find PL derivatives.
1N/A$origdir = cwd;
1N/Achdir dirname($0);
1N/A$file = basename($0, '.PL');
1N/A$file .= '.com' if $^O eq 'VMS';
1N/A
1N/Aopen OUT,">$file" or die "Can't create $file: $!";
1N/A
1N/Aprint "Extracting $file (with variable substitutions)\n";
1N/A
1N/A# In this section, perl variables will be expanded during extraction.
1N/A# You can use $Config{...} to use Configure variables.
1N/A
1N/Aprint OUT <<"!GROK!THIS!";
1N/A$Config{startperl}
1N/A eval 'exec $Config{perlpath} -S \$0 \${1+"\$@"}'
1N/A if \$running_under_some_shell;
1N/A!GROK!THIS!
1N/A
1N/A# In the following, perl variables are not expanded during extraction.
1N/A
1N/Aprint OUT <<'!NO!SUBS!';
1N/A
1N/A# pod2text -- Convert POD data to formatted ASCII text.
1N/A#
1N/A# Copyright 1999, 2000, 2001 by Russ Allbery <rra@stanford.edu>
1N/A#
1N/A# This program is free software; you may redistribute it and/or modify it
1N/A# under the same terms as Perl itself.
1N/A#
1N/A# The driver script for Pod::Text, Pod::Text::Termcap, and Pod::Text::Color,
1N/A# invoked by perldoc -t among other things.
1N/A
1N/Arequire 5.004;
1N/A
1N/Ause Getopt::Long qw(GetOptions);
1N/Ause Pod::Text ();
1N/Ause Pod::Usage qw(pod2usage);
1N/A
1N/Ause strict;
1N/A
1N/A# Silence -w warnings.
1N/Ause vars qw($running_under_some_shell);
1N/A
1N/A# Take an initial pass through our options, looking for one of the form
1N/A# -<number>. We turn that into -w <number> for compatibility with the
1N/A# original pod2text script.
1N/Afor (my $i = 0; $i < @ARGV; $i++) {
1N/A last if $ARGV[$i] =~ /^--$/;
1N/A if ($ARGV[$i] =~ /^-(\d+)$/) {
1N/A splice (@ARGV, $i++, 1, '-w', $1);
1N/A }
1N/A}
1N/A
1N/A# Insert -- into @ARGV before any single dash argument to hide it from
1N/A# Getopt::Long; we want to interpret it as meaning stdin (which Pod::Parser
1N/A# does correctly).
1N/Amy $stdin;
1N/A@ARGV = map { $_ eq '-' && !$stdin++ ? ('--', $_) : $_ } @ARGV;
1N/A
1N/A# Parse our options. Use the same names as Pod::Text for simplicity, and
1N/A# default to sentence boundaries turned off for compatibility.
1N/Amy %options;
1N/A$options{sentence} = 0;
1N/AGetopt::Long::config ('bundling');
1N/AGetOptions (\%options, 'alt|a', 'code', 'color|c', 'help|h', 'indent|i=i',
1N/A 'loose|l', 'margin|left-margin|m=i', 'overstrike|o',
1N/A 'quotes|q=s', 'sentence|s', 'termcap|t', 'width|w=i') or exit 1;
1N/Apod2usage (1) if $options{help};
1N/A
1N/A# Figure out what formatter we're going to use. -c overrides -t.
1N/Amy $formatter = 'Pod::Text';
1N/Aif ($options{color}) {
1N/A $formatter = 'Pod::Text::Color';
1N/A eval { require Term::ANSIColor };
1N/A if ($@) { die "-c (--color) requires Term::ANSIColor be installed\n" }
1N/A require Pod::Text::Color;
1N/A} elsif ($options{termcap}) {
1N/A $formatter = 'Pod::Text::Termcap';
1N/A require Pod::Text::Termcap;
1N/A} elsif ($options{overstrike}) {
1N/A $formatter = 'Pod::Text::Overstrike';
1N/A require Pod::Text::Overstrike;
1N/A}
1N/Adelete @options{'color', 'termcap', 'overstrike'};
1N/A
1N/A# Initialize and run the formatter.
1N/Amy $parser = $formatter->new (%options);
1N/A$parser->parse_from_file (@ARGV);
1N/A
1N/A__END__
1N/A
1N/A=head1 NAME
1N/A
1N/Apod2text - Convert POD data to formatted ASCII text
1N/A
1N/A=head1 SYNOPSIS
1N/A
1N/Apod2text [B<-aclost>] [B<--code>] [B<-i> I<indent>] S<[B<-q> I<quotes>]>
1N/AS<[B<-w> I<width>]> [I<input> [I<output>]]
1N/A
1N/Apod2text B<-h>
1N/A
1N/A=head1 DESCRIPTION
1N/A
1N/AB<pod2text> is a front-end for Pod::Text and its subclasses. It uses them
1N/Ato generate formatted ASCII text from POD source. It can optionally use
1N/Aeither termcap sequences or ANSI color escape sequences to format the text.
1N/A
1N/AI<input> is the file to read for POD source (the POD can be embedded in
1N/Acode). If I<input> isn't given, it defaults to STDIN. I<output>, if given,
1N/Ais the file to which to write the formatted output. If I<output> isn't
1N/Agiven, the formatted output is written to STDOUT.
1N/A
1N/A=head1 OPTIONS
1N/A
1N/A=over 4
1N/A
1N/A=item B<-a>, B<--alt>
1N/A
1N/AUse an alternate output format that, among other things, uses a different
1N/Aheading style and marks C<=item> entries with a colon in the left margin.
1N/A
1N/A=item B<--code>
1N/A
1N/AInclude any non-POD text from the input file in the output as well. Useful
1N/Afor viewing code documented with POD blocks with the POD rendered and the
1N/Acode left intact.
1N/A
1N/A=item B<-c>, B<--color>
1N/A
1N/AFormat the output with ANSI color escape sequences. Using this option
1N/Arequires that Term::ANSIColor be installed on your system.
1N/A
1N/A=item B<-i> I<indent>, B<--indent=>I<indent>
1N/A
1N/ASet the number of spaces to indent regular text, and the default indentation
1N/Afor C<=over> blocks. Defaults to 4 spaces if this option isn't given.
1N/A
1N/A=item B<-h>, B<--help>
1N/A
1N/APrint out usage information and exit.
1N/A
1N/A=item B<-l>, B<--loose>
1N/A
1N/APrint a blank line after a C<=head1> heading. Normally, no blank line is
1N/Aprinted after C<=head1>, although one is still printed after C<=head2>,
1N/Abecause this is the expected formatting for manual pages; if you're
1N/Aformatting arbitrary text documents, using this option is recommended.
1N/A
1N/A=item B<-m> I<width>, B<--left-margin>=I<width>, B<--margin>=I<width>
1N/A
1N/AThe width of the left margin in spaces. Defaults to 0. This is the margin
1N/Afor all text, including headings, not the amount by which regular text is
1N/Aindented; for the latter, see B<-i> option.
1N/A
1N/A=item B<-o>, B<--overstrike>
1N/A
1N/AFormat the output with overstruck printing. Bold text is rendered as
1N/Acharacter, backspace, character. Italics and file names are rendered as
1N/Aunderscore, backspace, character. Many pagers, such as B<less>, know how
1N/Ato convert this to bold or underlined text.
1N/A
1N/A=item B<-q> I<quotes>, B<--quotes>=I<quotes>
1N/A
1N/ASets the quote marks used to surround CE<lt>> text to I<quotes>. If
1N/AI<quotes> is a single character, it is used as both the left and right
1N/Aquote; if I<quotes> is two characters, the first character is used as the
1N/Aleft quote and the second as the right quoted; and if I<quotes> is four
1N/Acharacters, the first two are used as the left quote and the second two as
1N/Athe right quote.
1N/A
1N/AI<quotes> may also be set to the special value C<none>, in which case no
1N/Aquote marks are added around CE<lt>> text.
1N/A
1N/A=item B<-s>, B<--sentence>
1N/A
1N/AAssume each sentence ends with two spaces and try to preserve that spacing.
1N/AWithout this option, all consecutive whitespace in non-verbatim paragraphs
1N/Ais compressed into a single space.
1N/A
1N/A=item B<-t>, B<--termcap>
1N/A
1N/ATry to determine the width of the screen and the bold and underline
1N/Asequences for the terminal from termcap, and use that information in
1N/Aformatting the output. Output will be wrapped at two columns less than the
1N/Awidth of your terminal device. Using this option requires that your system
1N/Ahave a termcap file somewhere where Term::Cap can find it and requires that
1N/Ayour system support termios. With this option, the output of B<pod2text>
1N/Awill contain terminal control sequences for your current terminal type.
1N/A
1N/A=item B<-w>, B<--width=>I<width>, B<->I<width>
1N/A
1N/AThe column at which to wrap text on the right-hand side. Defaults to 76,
1N/Aunless B<-t> is given, in which case it's two columns less than the width of
1N/Ayour terminal device.
1N/A
1N/A=back
1N/A
1N/A=head1 DIAGNOSTICS
1N/A
1N/AIf B<pod2text> fails with errors, see L<Pod::Text> and L<Pod::Parser> for
1N/Ainformation about what those errors might mean. Internally, it can also
1N/Aproduce the following diagnostics:
1N/A
1N/A=over 4
1N/A
1N/A=item -c (--color) requires Term::ANSIColor be installed
1N/A
1N/A(F) B<-c> or B<--color> were given, but Term::ANSIColor could not be
1N/Aloaded.
1N/A
1N/A=item Unknown option: %s
1N/A
1N/A(F) An unknown command line option was given.
1N/A
1N/A=back
1N/A
1N/AIn addition, other L<Getopt::Long|Getopt::Long> error messages may result
1N/Afrom invalid command-line options.
1N/A
1N/A=head1 ENVIRONMENT
1N/A
1N/A=over 4
1N/A
1N/A=item COLUMNS
1N/A
1N/AIf B<-t> is given, B<pod2text> will take the current width of your screen
1N/Afrom this environment variable, if available. It overrides terminal width
1N/Ainformation in TERMCAP.
1N/A
1N/A=item TERMCAP
1N/A
1N/AIf B<-t> is given, B<pod2text> will use the contents of this environment
1N/Avariable if available to determine the correct formatting sequences for your
1N/Acurrent terminal device.
1N/A
1N/A=back
1N/A
1N/A=head1 SEE ALSO
1N/A
1N/AL<Pod::Text>, L<Pod::Text::Color>, L<Pod::Text::Overstrike>,
1N/AL<Pod::Text::Termcap>, L<Pod::Parser>
1N/A
1N/AThe current version of this script is always available from its web site at
1N/AL<http://www.eyrie.org/~eagle/software/podlators/>. It is also part of the
1N/APerl core distribution as of 5.6.0.
1N/A
1N/A=head1 AUTHOR
1N/A
1N/ARuss Allbery <rra@stanford.edu>.
1N/A
1N/A=head1 COPYRIGHT AND LICENSE
1N/A
1N/ACopyright 1999, 2000, 2001 by Russ Allbery <rra@stanford.edu>.
1N/A
1N/AThis program is free software; you may redistribute it and/or modify it
1N/Aunder the same terms as Perl itself.
1N/A
1N/A=cut
1N/A!NO!SUBS!
1N/A
1N/Aclose OUT or die "Can't close $file: $!";
1N/Achmod 0755, $file or die "Can't reset permissions for $file: $!\n";
1N/Aexec("$Config{'eunicefix'} $file") if $Config{'eunicefix'} ne ':';
1N/Achdir $origdir;