$$self{INDEX} = [];
my $output;
if (@entries) {
- my $output = '.IX Xref "'
+ $output = '.IX Xref "'
. join (' ', map { s/\"/\"\"/; $_ } @entries)
. '"' . "\n";
}
# changes for nroff in =item tags, since they're unnecessary.
$nroff =~ s/\\f\(CW(.*)\\f[PR]/$1/g;
- # Now finally output the command. Only bother with .if if the nroff
+ # Now finally output the command. Only bother with .ie if the nroff
# and troff output isn't the same.
if ($nroff ne $troff) {
- return ".if n $command $nroff\n.el $command $troff\n";
+ return ".ie n $command $nroff\n.el $command $troff\n";
} else {
return "$command $nroff\n";
}
# Pod::Text -- Convert POD data to formatted ASCII text.
-# $Id: Text.pm,v 2.11 2001/07/10 11:08:10 eagle Exp $
+# $Id: Text.pm,v 2.13 2001/10/20 08:07:21 eagle Exp $
#
# Copyright 1999, 2000, 2001 by Russ Allbery <rra@stanford.edu>
#
# Don't use the CVS revision as the version, since this module is also in Perl
# core and too many things could munge CVS magic revision strings. This
# number should ideally be the same as the CVS revision in podlators, however.
-$VERSION = 2.11;
+$VERSION = 2.13;
##############################################################################
$$self{MARGIN} = $$self{indent}; # Current left margin in spaces.
$self->SUPER::initialize;
+
+ # Tell Pod::Parser that we want the non-POD stuff too if code was set.
+ $self->parseopts ('-want_nonPODs' => 1) if $$self{code};
}
local $_ = shift;
return '' if ($command eq 'X' || $command eq 'Z');
- # Expand escapes into the actual character now, carping if invalid.
+ # Expand escapes into the actual character now, warning if invalid.
if ($command eq 'E') {
if (/^\d+$/) {
return chr;
} else {
return $ESCAPES{$_} if defined $ESCAPES{$_};
- carp "Unknown escape: E<$_>";
+ my $seq = shift;
+ my ($file, $line) = $seq->file_line;
+ warn "$file:$line: Unknown escape: E<$_>\n";
return "E<$_>";
}
}
elsif ($command eq 'F') { return $self->seq_f ($_) }
elsif ($command eq 'I') { return $self->seq_i ($_) }
elsif ($command eq 'L') { return $self->seq_l ($_) }
- else { carp "Unknown sequence $command<$_>" }
+ else {
+ my $seq = shift;
+ my ($file, $line) = $seq->file_line;
+ warn "$file:$line: Unknown sequence $command<$_>\n";
+ }
}
# Called for each paragraph that's actually part of the POD. We take
-# advantage of this opportunity to untabify the input.
+# advantage of this opportunity to untabify the input. Also, if given the
+# code option, we may see paragraphs that aren't part of the POD and need to
+# output them directly.
sub preprocess_paragraph {
my $self = shift;
local $_ = shift;
1 while s/^(.*?)(\t+)/$1 . ' ' x (length ($2) * 8 - length ($1) % 8)/me;
+ $self->output_code ($_) if $self->cutting;
$_;
}
# End a list.
sub cmd_back {
- my $self = shift;
+ my ($self, $text, $line, $paragraph) = @_;
$$self{MARGIN} = pop @{ $$self{INDENTS} };
unless (defined $$self{MARGIN}) {
- carp "Unmatched =back";
+ my $file;
+ ($file, $line) = $paragraph->file_line;
+ warn "$file:$line: Unmatched =back\n";
$$self{MARGIN} = $$self{indent};
}
}
local $_ = shift;
my $tag = $$self{ITEM};
unless (defined $tag) {
- carp "item called without tag";
+ carp "Item called without tag";
return;
}
undef $$self{ITEM};
# Output text to the output device.
sub output { $_[1] =~ tr/\01/ /; print { $_[0]->output_handle } $_[1] }
+# Output a block of code (something that isn't part of the POD text). Called
+# by preprocess_paragraph only if we were given the code option. Exists here
+# only so that it can be overridden by subclasses.
+sub output_code { $_[0]->output ($_[1]) }
+
##############################################################################
# Backwards compatibility
things, uses a different heading style and marks C<=item> entries with a
colon in the left margin. Defaults to false.
+=item code
+
+If set to a true value, the non-POD parts of the input file will be included
+in the output. Useful for viewing code documented with POD blocks with the
+POD rendered and the code left intact.
+
=item indent
The number of spaces to indent regular text, and the default indentation for
=item Bizarre space in item
-(W) Something has gone wrong in internal C<=item> processing. This message
-indicates a bug in Pod::Text; you should never see it.
+=item Item called without tag
+
+(W) Something has gone wrong in internal C<=item> processing. These
+messages indicate a bug in Pod::Text; you should never see them.
=item Can't open %s for reading: %s
(W) The POD source contained a non-standard command paragraph (something of
the form C<=command args>) that Pod::Man didn't know about. It was ignored.
-=item Unknown escape: %s
+=item %s:%d: Unknown escape: %s
(W) The POD source contained an C<EE<lt>E<gt>> escape that Pod::Text didn't
know about.
-=item Unknown sequence: %s
+=item %s:%d: Unknown sequence: %s
(W) The POD source contained a non-standard internal sequence (something of
the form C<XE<lt>E<gt>>) that Pod::Text didn't know about.
-=item Unmatched =back
+=item %s:%d: Unmatched =back
(W) Pod::Text encountered a C<=back> command that didn't correspond to an
C<=over> command.
# Pod::Text::Color -- Convert POD data to formatted color ASCII text
-# $Id: Color.pm,v 1.0 2001/07/10 11:03:43 eagle Exp $
+# $Id: Color.pm,v 1.1 2001/10/20 08:08:39 eagle Exp $
#
-# Copyright 1999 by Russ Allbery <rra@stanford.edu>
+# Copyright 1999, 2001 by Russ Allbery <rra@stanford.edu>
#
# This program is free software; you may redistribute it and/or modify it
# under the same terms as Perl itself.
# Don't use the CVS revision as the version, since this module is also in Perl
# core and too many things could munge CVS magic revision strings. This
# number should ideally be the same as the CVS revision in podlators, however.
-$VERSION = 1.00;
+$VERSION = 1.01;
##############################################################################
sub seq_f { return colored ($_[1], 'cyan') }
sub seq_i { return colored ($_[1], 'yellow') }
+# Output any included code in green.
+sub output_code {
+ my ($self, $code) = @_;
+ $code = colored ($code, 'green');
+ $self->output ($code);
+}
+
# We unfortunately have to override the wrapping code here, since the normal
# wrapping code gets really confused by all the escape sequences.
sub wrap {
=head1 COPYRIGHT AND LICENSE
-Copyright 1999 by Russ Allbery <rra@stanford.edu>.
+Copyright 1999, 2001 by Russ Allbery <rra@stanford.edu>.
This program is free software; you may redistribute it and/or modify it
under the same terms as Perl itself.
# Pod::Text::Overstrike -- Convert POD data to formatted overstrike text
-# $Id: Overstrike.pm,v 1.2 2001/07/10 11:04:36 eagle Exp $
+# $Id: Overstrike.pm,v 1.3 2001/10/20 08:11:29 eagle Exp $
#
# Created by Joe Smith <Joe.Smith@inwap.com> 30-Nov-2000
# (based on Pod::Text::Color by Russ Allbery <rra@stanford.edu>)
# Don't use the CVS revision as the version, since this module is also in Perl
# core and too many things could munge CVS magic revision strings. This
# number should ideally be the same as the CVS revision in podlators, however.
-$VERSION = 1.02;
+$VERSION = 1.03;
##############################################################################
sub seq_f { local $_ = $_[1]; s/(.)\cH\1//g; s/_\cH//g; s/(.)/_\b$1/g; $_ }
sub seq_i { local $_ = $_[1]; s/(.)\cH\1//g; s/_\cH//g; s/(.)/_\b$1/g; $_ }
+# Output any included code in bold.
+sub output_code {
+ my ($self, $code) = @_;
+ $code =~ s/(.)/$1\b$1/g;
+ $self->output ($code);
+}
+
# We unfortunately have to override the wrapping code here, since the normal
# wrapping code gets really confused by all the escape sequences.
sub wrap {
my $spaces = ' ' x $$self{MARGIN};
my $width = $$self{width} - $$self{MARGIN};
while (length > $width) {
- if (s/^((?:(?:[^\n]\cH)?[^\n]){0,$width})\s+//
+ if (s/^((?:(?:[^\n]\cH)?[^\n]){0,$width})(\Z|\s+)//
|| s/^((?:(?:[^\n]\cH)?[^\n]){$width})//) {
$output .= $spaces . $1 . "\n";
} else {
=head1 COPYRIGHT AND LICENSE
Copyright 2000 by Joe Smith <Joe.Smith@inwap.com>.
+Copyright 2001 by Russ Allbery <rra@stanford.edu>.
This program is free software; you may redistribute it and/or modify it
under the same terms as Perl itself.
# Pod::Text::Termcap -- Convert POD data to ASCII text with format escapes.
-# $Id: Termcap.pm,v 1.1 2001/07/10 11:04:36 eagle Exp $
+# $Id: Termcap.pm,v 1.2 2001/10/20 08:09:30 eagle Exp $
#
-# Copyright 1999 by Russ Allbery <rra@stanford.edu>
+# Copyright 1999, 2001 by Russ Allbery <rra@stanford.edu>
#
# This program is free software; you may redistribute it and/or modify it
# under the same terms as Perl itself.
# Don't use the CVS revision as the version, since this module is also in Perl
# core and too many things could munge CVS magic revision strings. This
# number should ideally be the same as the CVS revision in podlators, however.
-$VERSION = 1.01;
+$VERSION = 1.02;
##############################################################################
sub seq_b { my $self = shift; return "$$self{BOLD}$_[0]$$self{NORM}" }
sub seq_i { my $self = shift; return "$$self{UNDL}$_[0]$$self{NORM}" }
+# Output any included code in bold.
+sub output_code {
+ my ($self, $code) = @_;
+ $self->output ($$self{BOLD} . $code . $$self{NORM});
+}
+
# Override the wrapping code to igore the special sequences.
sub wrap {
my $self = shift;
=head1 COPYRIGHT AND LICENSE
-Copyright 1999 by Russ Allbery <rra@stanford.edu>.
+Copyright 1999, 2001 by Russ Allbery <rra@stanford.edu>.
This program is free software; you may redistribute it and/or modify it
under the same terms as Perl itself.
print OUT <<'!NO!SUBS!';
# pod2man -- Convert POD data to formatted *roff input.
-# $Id: pod2man.PL,v 1.6 2001/07/10 11:23:46 eagle Exp $
+# $Id: pod2man.PL,v 1.7 2001/10/20 08:24:15 eagle Exp $
#
# Copyright 1999, 2000, 2001 by Russ Allbery <rra@stanford.edu>
#
use strict;
+# Silence -w warnings.
+use vars qw($running_under_some_shell);
+
# Insert -- into @ARGV before any single dash argument to hide it from
# Getopt::Long; we want to interpret it as meaning stdin (which Pod::Parser
# does correctly).
GetOptions (\%options, 'section|s=s', 'release|r=s', 'center|c=s',
'date|d=s', 'fixed=s', 'fixedbold=s', 'fixeditalic=s',
'fixedbolditalic=s', 'official|o', 'quotes|q=s', 'lax|l',
- 'help|h') or exit 1;
+ 'help|h', 'verbose|v') or exit 1;
pod2usage (0) if $options{help};
# Official sets --center, but don't override things explicitly set.
$options{center} = 'Perl Programmers Reference Guide';
}
+# Verbose is only our flag, not a Pod::Man flag.
+my $verbose = $options{verbose};
+delete $options{verbose};
+
# Initialize and run the formatter, pulling a pair of input and output off at
# a time.
my $parser = Pod::Man->new (%options);
my @files;
do {
@files = splice (@ARGV, 0, 2);
+ print " $files[1]\n" if $verbose;
$parser->parse_from_file (@files);
} while (@ARGV);
[B<--center>=I<string>] [B<--date>=I<string>] [B<--fixed>=I<font>]
[B<--fixedbold>=I<font>] [B<--fixeditalic>=I<font>]
[B<--fixedbolditalic>=I<font>] [B<--official>] [B<--lax>]
-[B<--quotes>=I<quotes>] [I<input> [I<output>] ...]
+[B<--quotes>=I<quotes>] [B<--verbose>] [I<input> [I<output>] ...]
pod2man B<--help>
By default, section 1 will be used unless the file ends in .pm in which case
section 3 will be selected.
+=item B<-v>, B<--verbose>
+
+Print out the name of each output file as it is being generated.
+
=back
=head1 DIAGNOSTICS
# pod2text -- Convert POD data to formatted ASCII text.
#
-# Copyright 1999, 2000 by Russ Allbery <rra@stanford.edu>
+# Copyright 1999, 2000, 2001 by Russ Allbery <rra@stanford.edu>
#
# This program is free software; you may redistribute it and/or modify it
# under the same terms as Perl itself.
use strict;
+# Silence -w warnings.
+use vars qw($running_under_some_shell);
+
# Take an initial pass through our options, looking for one of the form
# -<number>. We turn that into -w <number> for compatibility with the
# original pod2text script.
my %options;
$options{sentence} = 0;
Getopt::Long::config ('bundling');
-GetOptions (\%options, 'alt|a', 'color|c', 'help|h', 'indent|i=i',
+GetOptions (\%options, 'alt|a', 'code', 'color|c', 'help|h', 'indent|i=i',
'loose|l', 'overstrike|o', 'quotes|q=s', 'sentence|s',
'termcap|t', 'width|w=i') or exit 1;
pod2usage (1) if $options{help};
=head1 SYNOPSIS
-pod2text [B<-aclost>] [B<-i> I<indent>] [B<-q> I<quotes>] [B<-w> I<width>]
-[I<input> [I<output>]]
+pod2text [B<-aclost>] [B<--code>] [B<-i> I<indent>] S<[B<-q> I<quotes>]>
+S<[B<-w> I<width>]> [I<input> [I<output>]]
pod2text B<-h>
Use an alternate output format that, among other things, uses a different
heading style and marks C<=item> entries with a colon in the left margin.
+=item B<--code>
+
+Include any non-POD text from the input file in the output as well. Useful
+for viewing code documented with POD blocks with the POD rendered and the
+code left intact.
+
=item B<-c>, B<--color>
Format the output with ANSI color escape sequences. Using this option