# Pod::Man -- Convert POD data to formatted *roff input.
-# $Id: Man.pm,v 2.4 2005/03/19 19:40:01 eagle Exp $
+# $Id: Man.pm,v 2.8 2006-01-25 23:56:52 eagle Exp $
#
-# Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005
+# Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
# Russ Allbery <rra@stanford.edu>
# Substantial contributions by Sean Burke <sburke@cpan.org>
#
# 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.04;
+$VERSION = 2.08;
# Set the debugging level. If someone has inserted a debug function into this
# class already, use that. Otherwise, use any Pod::Simple debug function
}
} elsif ($self->can ("end_$method")) {
my $method = 'end_' . $method;
- $self->$method;
+ $self->$method ();
} else {
DEBUG > 2 and print "No $method end method, skipping\n";
}
sub cmd_item_block { my $self = shift; $self->item_common ('block', @_) }
##############################################################################
+# Backward compatibility
+##############################################################################
+
+# Reset the underlying Pod::Simple object between calls to parse_from_file so
+# that the same object can be reused to convert multiple pages.
+sub parse_from_file {
+ my $self = shift;
+ $self->reinit;
+ my $retval = $self->SUPER::parse_from_file (@_);
+ my $fh = $self->output_fh ();
+ my $oldfh = select $fh;
+ my $oldflush = $|;
+ $| = 1;
+ print $fh '';
+ $| = $oldflush;
+ select $oldfh;
+ return $retval;
+}
+
+##############################################################################
# Translation tables
##############################################################################
=head1 COPYRIGHT AND LICENSE
-Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005
+Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
by Russ Allbery <rra@stanford.edu>.
This program is free software; you may redistribute it and/or modify it
# Pod::Text -- Convert POD data to formatted ASCII text.
-# $Id: Text.pm,v 3.1 2005/03/19 19:40:01 eagle Exp $
+# $Id: Text.pm,v 3.6 2006-01-25 23:56:52 eagle Exp $
#
-# Copyright 1999, 2000, 2001, 2002, 2004 by Russ Allbery <rra@stanford.edu>
+# Copyright 1999, 2000, 2001, 2002, 2004, 2006
+# 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 = 3.01;
+$VERSION = 3.06;
##############################################################################
# Initialization
}
} elsif ($self->can ("end_$method")) {
my $method = 'end_' . $method;
- $self->$method;
+ $self->$method ();
}
}
return;
}
$fhs[0] = \*IN;
- return $parser->parse_file (@fhs);
+ $parser->output_fh ($fhs[1]);
+ my $retval = $parser->parse_file ($fhs[0]);
+ my $fh = $parser->output_fh ();
+ close $fh;
+ return $retval;
} else {
return $parser->parse_file (@_);
}
}
+# Reset the underlying Pod::Simple object between calls to parse_from_file so
+# that the same object can be reused to convert multiple pages.
+sub parse_from_file {
+ my $self = shift;
+ $self->reinit;
+ my $retval = $self->Pod::Simple::parse_from_file (@_);
+ my $fh = $self->output_fh ();
+ my $oldfh = select $fh;
+ my $oldflush = $|;
+ $| = 1;
+ print $fh '';
+ $| = $oldflush;
+ select $oldfh;
+ return $retval;
+}
+
##############################################################################
# Module return value and documentation
##############################################################################
=head1 COPYRIGHT AND LICENSE
-Copyright 1999, 2000, 2001, 2002, 2004 by Russ Allbery <rra@stanford.edu>.
+Copyright 1999, 2000, 2001, 2002, 2004, 2006 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::Color -- Convert POD data to formatted color ASCII text
-# $Id: Color.pm,v 2.1 2004/12/31 21:50:00 eagle Exp $
+# $Id: Color.pm,v 2.3 2006-01-25 23:56:54 eagle Exp $
#
-# Copyright 1999, 2001, 2004 by Russ Allbery <rra@stanford.edu>
+# Copyright 1999, 2001, 2004, 2006 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 = 2.01;
+$VERSION = 2.03;
##############################################################################
# Overrides
my $output = '';
my $spaces = ' ' x $$self{MARGIN};
my $width = $$self{opt_width} - $$self{MARGIN};
+
+ # We have to do $shortchar and $longchar in variables because the
+ # construct ${char}{0,$width} didn't do the right thing until Perl 5.8.x.
my $char = '(?:(?:\e\[[\d;]+m)*[^\n])';
+ my $shortchar = $char . "{0,$width}";
+ my $longchar = $char . "{$width}";
while (length > $width) {
- if (s/^(${char}{0,$width})\s+// || s/^(${char}{$width})//) {
+ if (s/^($shortchar)\s+// || s/^($longchar)//) {
$output .= $spaces . $1 . "\n";
} else {
last;
=head1 COPYRIGHT AND LICENSE
-Copyright 1999, 2001, 2004 by Russ Allbery <rra@stanford.edu>.
+Copyright 1999, 2001, 2004, 2006 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 2.1 2004/12/31 21:50:00 eagle Exp $
+# $Id: Termcap.pm,v 2.3 2006-01-25 23:56:54 eagle Exp $
#
-# Copyright 1999, 2001, 2002, 2004 by Russ Allbery <rra@stanford.edu>
+# Copyright 1999, 2001, 2002, 2004, 2006 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 = 2.01;
+$VERSION = 2.03;
##############################################################################
# Overrides
# $codes matches a single special sequence. $char matches any number of
# special sequences preceeding a single character other than a newline.
+ # We have to do $shortchar and $longchar in variables because the
+ # construct ${char}{0,$width} didn't do the right thing until Perl 5.8.x.
my $codes = "(?:\Q$$self{BOLD}\E|\Q$$self{UNDL}\E|\Q$$self{NORM}\E)";
my $char = "(?:$codes*[^\\n])";
+ my $shortchar = $char . "{0,$width}";
+ my $longchar = $char . "{$width}";
while (length > $width) {
- if (s/^(${char}{0,$width})\s+// || s/^(${char}{$width})//) {
+ if (s/^($shortchar)\s+// || s/^($longchar)//) {
$output .= $spaces . $1 . "\n";
} else {
last;
=head1 COPYRIGHT AND LICENSE
-Copyright 1999, 2001, 2002, 2004 by Russ Allbery <rra@stanford.edu>.
+Copyright 1999, 2001, 2002, 2004, 2006 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.
#!/usr/bin/perl -w
-# $Id: basic.t,v 1.8 2004/12/31 21:27:58 eagle Exp $
+# $Id: basic.t,v 1.9 2006-01-20 21:20:58 eagle Exp $
#
# basic.t -- Basic tests for podlators.
#
# line. That means that we don't check those things; oh well. The header
# changes with each version change or touch of the input file.
$parser->parse_from_file (source_path ('basic.pod'), 'out.tmp');
- undef $parser;
if ($_ eq 'Pod::Man') {
open (TMP, 'out.tmp') or die "Cannot open out.tmp: $!\n";
open (OUTPUT, "> out.$translators{$_}")
#!/usr/bin/perl -w
-# $Id: color.t,v 1.1 2004/12/31 21:50:05 eagle Exp $
+# $Id: color.t,v 1.2 2006-01-20 21:20:58 eagle Exp $
#
# color.t -- Additional specialized tests for Pod::Text::Color.
#
$loaded = 1;
print "ok 1\n";
+my $parser = Pod::Text::Color->new or die "Cannot create parser\n";
my $n = 2;
while (<DATA>) {
next until $_ eq "###\n";
print TMP $_;
}
close TMP;
- my $parser = Pod::Text::Color->new or die "Cannot create parser\n";
$parser->parse_from_file ('tmp.pod', 'out.tmp');
- undef $parser;
open (TMP, 'out.tmp') or die "Cannot open out.tmp: $!\n";
my $output;
{
#!/usr/bin/perl -w
-# $Id: man.t,v 1.5 2004/02/15 06:42:49 eagle Exp $
+# $Id: man.t,v 1.8 2006-01-25 23:58:22 eagle Exp $
#
# man.t -- Additional specialized tests for Pod::Man.
#
-# Copyright 2002, 2003, 2004 by Russ Allbery <rra@stanford.edu>
+# Copyright 2002, 2003, 2004, 2006 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.
$loaded = 1;
print "ok 1\n";
-SKIP: {
- if (defined $ENV{PERL_UNICODE}) {
- print "not ok 2 # TODO Unicode not yet supported\n"
- } else {
- my $pod = <<EOP;
-=head1 ACCENTS
-
-Beyoncé! Beyoncé! Beyoncé!!
-
- Beyoncé! Beyoncé!
- Beyoncé! Beyoncé!
- Beyoncé! Beyoncé!
-
-Older versions didn't convert Beyoncé in verbatim.
-EOP
-
- my $expected = <<"EOM";
-.SH "ACCENTS"
-.IX Header "ACCENTS"
-Beyonce\\*'! Beyonce\\*'! Beyonce\\*'!!
-.PP
-.Vb 3
-\\& Beyonce\\*'! Beyonce\\*'!
-\\& Beyonce\\*'! Beyonce\\*'!
-\\& Beyonce\\*'! Beyonce\\*'!
-.Ve
-.PP
-Older versions didn't convert Beyonce\\*' in verbatim.
-EOM
- $parser = Pod::Man->new or die "Cannot create parser\n";
- open my $out_fh, ">", 'out.tmp' or die "Can't open \$out_fh: $!";
- $parser->output_fh($out_fh);
- $parser->parse_string_document($pod);
- close $out_fh;
- open my $in_fh, "<", 'out.tmp' or die "Can't open \$in_fh: $!";
- while (<$in_fh>) { last if /^\.TH/; }
- my $man;
- {
- local $/ = undef;
- $man = <$in_fh>;
- }
- close $in_fh;
- unlink 'out.tmp';
- if ($man eq $expected) {
- print "ok 2\n";
- } else {
- print "not ok 2\n";
- print "Expected\n========\n$expected\nOutput\n======\n$man\n";
- }
- }
-}
-
-my $n = 3;
+my $parser = Pod::Man->new or die "Cannot create parser\n";
+my $n = 2;
while (<DATA>) {
next until $_ eq "###\n";
open (TMP, '> tmp.pod') or die "Cannot create tmp.pod: $!\n";
+
+ # We have a test in ISO 8859-1 encoding. Make sure that nothing strange
+ # happens if Perl thinks the world is Unicode. Wrap this in eval so that
+ # older versions of Perl don't croak.
+ eval { binmode (\*TMP, ':encoding(iso-8859-1)') };
+
while (<DATA>) {
last if $_ eq "###\n";
print TMP $_;
}
close TMP;
- my $parser = Pod::Man->new or die "Cannot create parser\n";
$parser->parse_from_file ('tmp.pod', 'out.tmp');
- undef $parser;
open (OUT, 'out.tmp') or die "Cannot open out.tmp: $!\n";
while (<OUT>) { last if /^\.TH/ }
my $output;
###
###
+=encoding iso-8859-1
+
+=head1 ACCENTS
+
+Beyoncé! Beyoncé! Beyoncé!!
+
+ Beyoncé! Beyoncé!
+ Beyoncé! Beyoncé!
+ Beyoncé! Beyoncé!
+
+Older versions didn't convert Beyoncé in verbatim.
+###
+.SH "ACCENTS"
+.IX Header "ACCENTS"
+Beyonce\*'! Beyonce\*'! Beyonce\*'!!
+.PP
+.Vb 3
+\& Beyonce\*'! Beyonce\*'!
+\& Beyonce\*'! Beyonce\*'!
+\& Beyonce\*'! Beyonce\*'!
+.Ve
+.PP
+Older versions didn't convert Beyonce\*' in verbatim.
+###
+
+###
=over 4
=item 1. Not a number
#!/usr/bin/perl -w
-# $Id: termcap.t,v 1.2 2005/11/28 23:38:02 eagle Exp $
+# $Id: termcap.t,v 1.3 2006-01-20 21:20:58 eagle Exp $
#
# termcap.t -- Additional specialized tests for Pod::Text::Termcap.
#
$loaded = 1;
print "ok 1\n";
+my $parser = Pod::Text::Termcap->new or die "Cannot create parser\n";
my $n = 2;
while (<DATA>) {
next until $_ eq "###\n";
print TMP $_;
}
close TMP;
- my $parser = Pod::Text::Termcap->new or die "Cannot create parser\n";
$parser->parse_from_file ('tmp.pod', 'out.tmp');
- undef $parser;
open (TMP, 'out.tmp') or die "Cannot open out.tmp: $!\n";
my $output;
{
#!/usr/bin/perl -w
-# $Id: text-options.t,v 1.4 2004/12/31 21:29:34 eagle Exp $
+# $Id: text-options.t,v 1.5 2006-01-20 21:20:58 eagle Exp $
#
# text-options.t -- Additional tests for Pod::Text options.
#
close TMP;
my $parser = Pod::Text->new (%options) or die "Cannot create parser\n";
$parser->parse_from_file ('tmp.pod', 'out.tmp');
- undef $parser;
open (TMP, 'out.tmp') or die "Cannot open out.tmp: $!\n";
my $output;
{
#!/usr/bin/perl -w
-# $Id: text.t,v 1.3 2004/12/31 21:29:48 eagle Exp $
+# $Id: text.t,v 1.4 2006-01-20 21:20:58 eagle Exp $
#
# text.t -- Additional specialized tests for Pod::Text.
#
$loaded = 1;
print "ok 1\n";
+my $parser = Pod::Text->new or die "Cannot create parser\n";
my $n = 2;
while (<DATA>) {
next until $_ eq "###\n";
print TMP $_;
}
close TMP;
- my $parser = Pod::Text->new or die "Cannot create parser\n";
$parser->parse_from_file ('tmp.pod', 'out.tmp');
- undef $parser;
open (TMP, 'out.tmp') or die "Cannot open out.tmp: $!\n";
my $output;
{
print OUT <<'!NO!SUBS!';
# pod2man -- Convert POD data to formatted *roff input.
-# $Id: pod2man.PL,v 1.14 2004/12/31 20:39:30 eagle Exp $
+# $Id: pod2man.PL,v 1.16 2006-01-21 01:53:55 eagle Exp $
#
-# Copyright 1999, 2000, 2001 by Russ Allbery <rra@stanford.edu>
+# Copyright 1999, 2000, 2001, 2004, 2006 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.
# 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 {
- my $parser = Pod::Man->new (%options);
@files = splice (@ARGV, 0, 2);
print " $files[1]\n" if $verbose;
$parser->parse_from_file (@files);
=head1 COPYRIGHT AND LICENSE
-Copyright 1999, 2000, 2001 by Russ Allbery <rra@stanford.edu>.
+Copyright 1999, 2000, 2001, 2004, 2006 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.
# pod2text -- Convert POD data to formatted ASCII text.
#
-# Copyright 1999, 2000, 2001 by Russ Allbery <rra@stanford.edu>
+# Copyright 1999, 2000, 2001, 2004, 2006 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.
delete @options{'color', 'termcap', 'overstrike'};
# Initialize and run the formatter.
+my $parser = $formatter->new (%options);
do {
- my $parser = $formatter->new (%options);
my ($input, $output) = splice (@ARGV, 0, 2);
- $parser->parse_file ($input, $output);
- undef $parser;
+ $parser->parse_from_file ($input, $output);
} while (@ARGV);
__END__
=head1 COPYRIGHT AND LICENSE
-Copyright 1999, 2000, 2001, 2004 by Russ Allbery <rra@stanford.edu>.
+Copyright 1999, 2000, 2001, 2004, 2006 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.