lib/Pod/t/Select.t See if Pod::Select works
lib/Pod/t/termcap.t podlators test
lib/Pod/t/text-options.t podlators test
+lib/Pod/t/text-utf8.t podlators test
lib/Pod/t/text.t podlators test
lib/Pod/t/Usage.t See if Pod::Usage works
lib/Pod/t/user.t See if Pod::LaTeX works
@ISA = qw(Pod::Simple);
-$VERSION = '2.18';
+$VERSION = '2.19';
# Set the debugging level. If someone has inserted a debug function into this
# class already, use that. Otherwise, use any Pod::Simple debug function
my $self = $class->SUPER::new;
# Tell Pod::Simple not to handle S<> by automatically inserting .
- # Note that this messes up Unicode output by embedding explicit ISO 8859-1
- # non-breaking spaces that we have to clean up later.
$self->nbsp_for_S (1);
# Tell Pod::Simple to keep whitespace whenever possible.
# variables.
%$self = (%$self, @_);
+ # Send errors to stderr if requested.
+ if ($$self{stderr}) {
+ $self->no_errata_section (1);
+ $self->complain_stderr (1);
+ delete $$self{stderr};
+ }
+
# Initialize various other internal constants based on our arguments.
$self->init_fonts;
$self->init_quotes;
$text =~ s/([^\x00-\x7F])/$ESCAPES{ord ($1)} || "X"/eg;
}
- # For Unicode output, unconditionally remap ISO 8859-1 non-breaking spaces
- # to the correct code point. This is really a bug in Pod::Simple to be
- # embedding ISO 8859-1 characters in the output stream that we see.
- if ($$self{utf8} && ASCII) {
- $text =~ s/\xA0/\xC2\xA0/g;
- }
-
# Ensure that *roff doesn't convert literal quotes to UTF-8 single quotes,
# but don't mess up our accept escapes.
if ($literal) {
Pod::Man - Convert POD data to formatted *roff input
=for stopwords
-en em ALLCAPS teeny fixedbold fixeditalic fixedbolditalic utf8 UTF-8
-Allbery Sean Burke Ossanna
+en em ALLCAPS teeny fixedbold fixeditalic fixedbolditalic stderr utf8
+UTF-8 Allbery Sean Burke Ossanna Solaris
=head1 SYNOPSIS
By default, section 1 will be used unless the file ends in C<.pm> in which
case section 3 will be selected.
+=item stderr
+
+Send error messages about invalid POD to standard error instead of
+appending a POD ERRORS section to the generated *roff output.
+
=item utf8
By default, Pod::Man produces the most conservative possible *roff output
@ISA = qw(Exporter);
@EXPORT = qw(parselink);
-$VERSION = 1.07;
+$VERSION = 1.08;
##############################################################################
# Implementation
Pod::ParseLink - Parse an LE<lt>E<gt> formatting code in POD text
=for stopwords
-markup Allbery
+markup Allbery URL
=head1 SYNOPSIS
# We have to export pod2text for backward compatibility.
@EXPORT = qw(pod2text);
-$VERSION = 3.09;
+$VERSION = 3.10;
##############################################################################
# Initialization
my @opts = map { ("opt_$_", $opts{$_}) } keys %opts;
%$self = (%$self, @opts);
+ # Send errors to stderr if requested.
+ if ($$self{opt_stderr}) {
+ $self->no_errata_section (1);
+ $self->complain_stderr (1);
+ delete $$self{opt_stderr};
+ }
+
# Initialize various things from our parameters.
$$self{opt_alt} = 0 unless defined $$self{opt_alt};
$$self{opt_indent} = 4 unless defined $$self{opt_indent};
return $self->wrap ($_);
}
-# Output text to the output device.
+# Output text to the output device. Replace non-breaking spaces with spaces
+# and soft hyphens with nothing.
sub output {
my ($self, $text) = @_;
$text =~ tr/\240\255/ /d;
Pod::Text - Convert POD data to formatted ASCII text
=for stopwords
-alt Allbery Sean Burke's
+alt stderr Allbery Sean Burke's
=head1 SYNOPSIS
consecutive whitespace in non-verbatim paragraphs is compressed into a
single space. Defaults to true.
+=item stderr
+
+Send error messages about invalid POD to standard error instead of
+appending a POD ERRORS section to the generated output.
+
=item width
The column at which to wrap text on the right-hand side. Defaults to 76.
}
unshift (@INC, '../blib/lib');
$| = 1;
- print "1..7\n";
+ print "1..16\n";
}
END {
use Pod::Man;
+# Redirect stderr to a file.
+sub stderr_save {
+ open (OLDERR, '>&STDERR') or die "Can't dup STDERR: $!\n";
+ open (STDERR, '> out.err') or die "Can't redirect STDERR: $!\n";
+}
+
+# Restore stderr.
+sub stderr_restore {
+ close STDERR;
+ open (STDERR, '>&OLDERR') or die "Can't dup STDERR: $!\n";
+ close OLDERR;
+}
+
$loaded = 1;
print "ok 1\n";
my $n = 2;
+eval { binmode (\*DATA, ':encoding(utf-8)') };
while (<DATA>) {
my %options;
next until $_ eq "###\n";
$options{$option} = $value;
}
open (TMP, '> tmp.pod') or die "Cannot create tmp.pod: $!\n";
+ eval { binmode (\*TMP, ':encoding(utf-8)') };
+ print TMP "=encoding utf-8\n\n";
while (<DATA>) {
last if $_ eq "###\n";
print TMP $_;
close TMP;
my $parser = Pod::Man->new (%options) or die "Cannot create parser\n";
open (OUT, '> out.tmp') or die "Cannot create out.tmp: $!\n";
+ eval { binmode (\*OUT, ':encoding(utf-8)') };
+ stderr_save;
$parser->parse_from_file ('tmp.pod', \*OUT);
+ stderr_restore;
close OUT;
my $accents = 0;
open (TMP, 'out.tmp') or die "Cannot open out.tmp: $!\n";
+ eval { binmode (\*TMP, ':encoding(utf-8)') };
while (<TMP>) {
$accents = 1 if /Accent mark definitions/;
last if /^\.nh/;
print "Expected\n========\n$expected\nOutput\n======\n$output\n";
}
$n++;
+ open (ERR, 'out.err') or die "Cannot open out.err: $!\n";
+ my $errors;
+ {
+ local $/;
+ $errors = <ERR>;
+ }
+ close ERR;
+ unlink ('out.err');
+ $expected = '';
+ while (<DATA>) {
+ last if $_ eq "###\n";
+ $expected .= $_;
+ }
+ if ($errors eq $expected) {
+ print "ok $n\n";
+ } else {
+ print "not ok $n\n";
+ print "Expected errors:\n ${expected}Errors:\n $errors";
+ }
+ $n++;
}
# Below the marker are bits of POD and corresponding expected text output.
.PP
Older versions did not convert Beyoncé in verbatim.
###
+###
###
utf8 1
###
.SH "S<> output with UTF\-8"
.IX Header "S<> output with UTF-8"
-This is non\-breaking output.
+This is non-breaking output.
+###
###
###
.IX Header "FIXED FONTS"
\&\f(CR\*(C`foo \f(CYbar \f(CXbaz\f(CY\f(CR \f(CWbay\f(CR\*(C'\fR
###
+###
+
+###
+###
+=over 4
+
+=item Foo
+
+Bar.
+
+=head1 NEXT
+###
+.IP "Foo" 4
+.IX Item "Foo"
+Bar.
+.SH "NEXT"
+.IX Header "NEXT"
+.SH "POD ERRORS"
+.IX Header "POD ERRORS"
+Hey! \fBThe above document had some coding errors, which are explained below:\fR
+.IP "Around line 9:" 4
+.IX Item "Around line 9:"
+You forgot a '=back' before '=head1'
+###
+###
+
+###
+stderr 1
+###
+=over 4
+
+=item Foo
+
+Bar.
+
+=head1 NEXT
+###
+.IP "Foo" 4
+.IX Item "Foo"
+Bar.
+.SH "NEXT"
+.IX Header "NEXT"
+###
+tmp.pod around line 9: You forgot a '=back' before '=head1'
+###
my @spell;
for my $dir (split ':', $ENV{PATH}) {
if (-x "$dir/ispell") {
- @spell = ("$dir/ispell", '-d', 'american', '-l');
+ @spell = ("$dir/ispell", '-d', 'american', '-l', '-p', '/dev/null');
}
last if @spell;
}
}
unshift (@INC, '../blib/lib');
$| = 1;
- print "1..5\n";
+ print "1..13\n";
}
END {
use Pod::Text;
+# Redirect stderr to a file.
+sub stderr_save {
+ open (OLDERR, '>&STDERR') or die "Can't dup STDERR: $!\n";
+ open (STDERR, '> out.err') or die "Can't redirect STDERR: $!\n";
+}
+
+# Restore stderr.
+sub stderr_restore {
+ close STDERR;
+ open (STDERR, '>&OLDERR') or die "Can't dup STDERR: $!\n";
+ close OLDERR;
+}
+
$loaded = 1;
print "ok 1\n";
close TMP;
my $parser = Pod::Text->new (%options) or die "Cannot create parser\n";
open (OUT, '> out.tmp') or die "Cannot create out.tmp: $!\n";
+ stderr_save;
$parser->parse_from_file ('tmp.pod', \*OUT);
+ stderr_restore;
close OUT;
open (TMP, 'out.tmp') or die "Cannot open out.tmp: $!\n";
my $output;
print "Expected\n========\n$expected\nOutput\n======\n$output\n";
}
$n++;
+ open (ERR, 'out.err') or die "Cannot open out.err: $!\n";
+ my $errors;
+ {
+ local $/;
+ $errors = <ERR>;
+ }
+ close ERR;
+ unlink ('out.err');
+ $expected = '';
+ while (<DATA>) {
+ last if $_ eq "###\n";
+ $expected .= $_;
+ }
+ if ($errors eq $expected) {
+ print "ok $n\n";
+ } else {
+ print "not ok $n\n";
+ print "Expected errors:\n ${expected}Errors:\n $errors";
+ }
+ $n++;
}
# Below the marker are bits of POD and corresponding expected text output.
Paragraph.
###
+###
###
margin 4
This is another indented paragraph.
###
+###
###
code 1
This is more random text.
###
+###
###
sentence 1
eat all of the space in front of it.
###
+###
+
+###
+###
+=over 4
+
+=item Foo
+
+Bar.
+
+=head1 NEXT
+###
+ Foo Bar.
+
+NEXT
+POD ERRORS
+ Hey! The above document had some coding errors, which are explained
+ below:
+
+ Around line 7:
+ You forgot a '=back' before '=head1'
+
+###
+###
+
+###
+stderr 1
+###
+=over 4
+
+=item Foo
+
+Bar.
+
+=head1 NEXT
+###
+ Foo Bar.
+
+NEXT
+###
+tmp.pod around line 7: You forgot a '=back' before '=head1'
+###
--- /dev/null
+#!/usr/bin/perl -w
+#
+# text-utf8.t -- Test Pod::Text with UTF-8 input.
+#
+# Copyright 2002, 2004, 2006, 2007, 2008 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.
+
+BEGIN {
+ chdir 't' if -d 't';
+ if ($ENV{PERL_CORE}) {
+ @INC = '../lib';
+ } else {
+ unshift (@INC, '../blib/lib');
+ }
+ unshift (@INC, '../blib/lib');
+ $| = 1;
+ print "1..3\n";
+}
+
+END {
+ print "not ok 1\n" unless $loaded;
+}
+
+use Pod::Text;
+use Pod::Simple;
+
+$loaded = 1;
+print "ok 1\n";
+
+my $parser = Pod::Text->new or die "Cannot create parser\n";
+my $n = 2;
+eval { binmode (\*DATA, ':encoding(utf-8)') };
+eval { binmode (\*STDOUT, ':encoding(utf-8)') };
+while (<DATA>) {
+ next until $_ eq "###\n";
+ open (TMP, '> tmp.pod') or die "Cannot create tmp.pod: $!\n";
+ eval { binmode (\*TMP, ':encoding(utf-8)') };
+ print TMP "=encoding UTF-8\n\n";
+ while (<DATA>) {
+ last if $_ eq "###\n";
+ print TMP $_;
+ }
+ close TMP;
+ open (OUT, '> out.tmp') or die "Cannot create out.tmp: $!\n";
+ eval { binmode (\*OUT, ':encoding(utf-8)') };
+ $parser->parse_from_file ('tmp.pod', \*OUT);
+ close OUT;
+ open (TMP, 'out.tmp') or die "Cannot open out.tmp: $!\n";
+ eval { binmode (\*TMP, ':encoding(utf-8)') };
+ my $output;
+ {
+ local $/;
+ $output = <TMP>;
+ }
+ close TMP;
+ unlink ('tmp.pod', 'out.tmp');
+ my $expected = '';
+ while (<DATA>) {
+ last if $_ eq "###\n";
+ $expected .= $_;
+ }
+ if ($output eq $expected) {
+ print "ok $n\n";
+ } else {
+ print "not ok $n\n";
+ print "Expected\n========\n$expected\nOutput\n======\n$output\n";
+ }
+ $n++;
+}
+
+# Below the marker are bits of POD and corresponding expected text output.
+# This is used to test specific features or problems with Pod::Text. The
+# input and output are separated by lines containing only ###.
+
+__DATA__
+
+###
+=head1 Test of SE<lt>E<gt>
+
+This is S<some whitespace>.
+###
+Test of S<>
+ This is some whitespace.
+
+###
+
+###
+=head1 I can eat glass
+
+=over 4
+
+=item Esperanto
+
+Mi povas manĝi vitron, ĝi ne damaĝas min.
+
+=item Braille
+
+⠊⠀⠉⠁⠝⠀⠑⠁⠞⠀⠛⠇⠁⠎⠎⠀⠁⠝⠙⠀⠊⠞⠀⠙⠕⠑⠎⠝⠞⠀⠓⠥⠗⠞⠀⠍⠑
+
+=item Hindi
+
+मैं काँच खा सकता हूँ और मुझे उससे कोई चोट नहीं पहुंचती.
+
+=back
+
+See L<http://www.columbia.edu/kermit/utf8.html>
+###
+I can eat glass
+ Esperanto
+ Mi povas manĝi vitron, ĝi ne damaĝas min.
+
+ Braille
+ ⠊⠀⠉⠁⠝⠀⠑⠁⠞⠀⠛⠇⠁⠎⠎⠀⠁⠝⠙⠀⠊⠞⠀⠙⠕⠑⠎⠝⠞⠀⠓⠥⠗⠞⠀⠍⠑
+
+ Hindi
+ मैं काँच खा सकता हूँ और मुझे उससे कोई चोट नहीं पहुंचती.
+
+ See <http://www.columbia.edu/kermit/utf8.html>
+
+###
This is some whitespace.
###
-==
# Parse our options, trying to retain backwards compatibility with pod2man but
# allowing short forms as well. --lax is currently ignored.
my %options;
+$options{errors} = 'pod';
Getopt::Long::config ('bundling_override');
-GetOptions (\%options, 'section|s=s', 'release|r:s', 'center|c=s',
- 'date|d=s', 'fixed=s', 'fixedbold=s', 'fixeditalic=s',
- 'fixedbolditalic=s', 'name|n=s', 'official|o', 'quotes|q=s',
- 'lax|l', 'help|h', 'verbose|v', 'utf8|u') or exit 1;
+GetOptions (\%options, 'center|c=s', 'date|d=s', 'fixed=s', 'fixedbold=s',
+ 'fixeditalic=s', 'fixedbolditalic=s', 'help|h', 'lax|l',
+ 'name|n=s', 'official|o', 'quotes|q=s', 'release|r:s',
+ 'section|s=s', 'stderr', 'verbose|v', 'utf8|u') or exit 1;
pod2usage (0) if $options{help};
# Official sets --center, but don't override things explicitly set.
pod2man - Convert POD data to formatted *roff input
=for stopwords
-en em --utf8 UTF-8 overdo markup MT-LEVEL Allbery
+en em --stderr stderr --utf8 UTF-8 overdo markup MT-LEVEL Allbery Solaris
+URL
=head1 SYNOPSIS
-pod2man [B<--section>=I<manext>] [B<--release>[=I<version>]]
- [B<--center>=I<string>] [B<--date>=I<string>] [B<--fixed>=I<font>]
- [B<--fixedbold>=I<font>] [B<--fixeditalic>=I<font>]
+pod2man [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<--name>=I<name>] [B<--official>]
- [B<--lax>] [B<--quotes>=I<quotes>] [B<--verbose>]
+ [B<--quotes>=I<quotes>] [B<--release>[=I<version>]]
+ [B<--section>=I<manext>] [B<--stderr>] [B<--utf8>] [B<--verbose>]
[I<input> [I<output>] ...]
pod2man B<--help>
load and compile times) by providing multiple pairs of I<input> and
I<output> files on the command line.
-B<--section>, B<--release>, B<--center>, B<--date>, and B<--official> can be
-used to set the headers and footers to use; if not given, Pod::Man will
+B<--section>, B<--release>, B<--center>, B<--date>, and B<--official> can
+be used to set the headers and footers to use; if not given, Pod::Man will
assume various defaults. See below or L<Pod::Man> for details.
B<pod2man> assumes that your *roff formatters have a fixed-width font
By default, section 1 will be used unless the file ends in C<.pm>, in
which case section 3 will be selected.
+=item B<--stderr>
+
+By default, B<pod2man> puts any errors detected in the POD input in a POD
+ERRORS section in the output manual page. If B<--stderr> is given, errors
+are sent to standard error instead and the POD ERRORS section is
+suppressed.
+
=item B<-u>, B<--utf8>
By default, B<pod2man> produces the most conservative possible *roff
Getopt::Long::config ('bundling');
GetOptions (\%options, 'alt|a', 'code', 'color|c', 'help|h', 'indent|i=i',
'loose|l', 'margin|left-margin|m=i', 'overstrike|o',
- 'quotes|q=s', 'sentence|s', 'termcap|t', 'width|w=i') or exit 1;
+ 'quotes|q=s', 'sentence|s', 'stderr', 'termcap|t', 'width|w=i')
+ or exit 1;
pod2usage (1) if $options{help};
# Figure out what formatter we're going to use. -c overrides -t.
pod2text - Convert POD data to formatted ASCII text
=for stopwords
--aclost --alt Allbery
+-aclost --alt --stderr Allbery
=head1 SYNOPSIS
pod2text [B<-aclost>] [B<--code>] [B<-i> I<indent>] S<[B<-q> I<quotes>]>
- S<[B<-w> I<width>]> [I<input> [I<output> ...]]
+ [B<--stderr>] S<[B<-w> I<width>]> [I<input> [I<output> ...]]
pod2text B<-h>
Without this option, all consecutive whitespace in non-verbatim paragraphs
is compressed into a single space.
+=item B<--stderr>
+
+By default, B<pod2text> puts any errors detected in the POD input in a POD
+ERRORS section in the output manual page. If B<--stderr> is given, errors
+are sent to standard error instead and the POD ERRORS section is
+suppressed.
+
=item B<-t>, B<--termcap>
Try to determine the width of the screen and the bold and underline