summaryrefslogtreecommitdiff
path: root/cpan/podlators/lib
diff options
context:
space:
mode:
authorChris 'BinGOs' Williams <chris@bingosnet.co.uk>2010-10-18 15:00:04 +0100
committerChris 'BinGOs' Williams <chris@bingosnet.co.uk>2010-10-18 15:03:19 +0100
commit463da0ac9e3d63ff5a2efbc705aad083d4b2b20e (patch)
tree1b9f955c6ba21bdd3b873bf360529f947fcadb36 /cpan/podlators/lib
parentfb59364be1e5fdc818e4e1b5eba83f65ccfeb189 (diff)
downloadperl-463da0ac9e3d63ff5a2efbc705aad083d4b2b20e.tar.gz
Update podlators to CPAN version 2.4.0
The new perlpodstyle.pod has been located to pod/ Changes were necessary to mkppport because of a new dependency on Encode in podlators that stopped it being built before Encode was built. [DELTA] 2010-10-10 Russ Allbery <rra@stanford.edu> * VERSION: podlators 2.4.0 released. * scripts/pod2man: Remove the code to generate the #! line and supporting code and instead rely on ExtUtils::MakeMaker to handle that during package build. * scripts/pod2text: Likewise. * scripts/pod2man.PL: Renamed to pod2man. * scripts/pod2text.PL: Renamed to pod2text. * Makefile.PL: Remove PL_FILES section. * pod/perlpodstyle.pod: New style guide for POD documentation, split mostly from the NOTES section of the pod2man man page. * scripts/pod2man.PL: Remove NOTES section, now maintained as the separate perlpodstyle document. * Makefile.PL: Add perlpodstyle.1 to the generated man pages. * lib/Pod/Man.pm (cmd_para): Do not strip escaped trailing whitespace, such as that created by S<> at the end of a line, since the backslash is then taken by *roff as escaping the newline. Thanks, Kevin Ryde. * t/man.t: Test S<> at the end of lines. * lib/Pod/Man.pm (output): If the utf8 option is given, encode output in UTF-8 if there is no encoding layer. Now requires the Encode module. (start_document): Rather than forcibly change the PerlIO encoding layer, probe the PerlIO layers with protection for Perl versions without PerlIO and set a flag indicating whether to encode on the fly on output. * lib/Pod/Text.pm: Likewise. * Makefile.PL: Mark Encode as required. * t/man-perlio.t: Test Pod::Man output to a file handle with a PerlIO encoding layer already applied. * t/text-perlio.t: Likewise for Pod::Text.
Diffstat (limited to 'cpan/podlators/lib')
-rw-r--r--cpan/podlators/lib/Pod/Man.pm40
-rw-r--r--cpan/podlators/lib/Pod/Text.pm34
2 files changed, 45 insertions, 29 deletions
diff --git a/cpan/podlators/lib/Pod/Man.pm b/cpan/podlators/lib/Pod/Man.pm
index 9339f835bb..96f3fccee7 100644
--- a/cpan/podlators/lib/Pod/Man.pm
+++ b/cpan/podlators/lib/Pod/Man.pm
@@ -1,7 +1,7 @@
# Pod::Man -- Convert POD data to formatted *roff input.
#
-# Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
-# Russ Allbery <rra@stanford.edu>
+# Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
+# 2010 Russ Allbery <rra@stanford.edu>
# Substantial contributions by Sean Burke <sburke@cpan.org>
#
# This program is free software; you may redistribute it and/or modify it
@@ -31,11 +31,12 @@ use subs qw(makespace);
use vars qw(@ISA %ESCAPES $PREAMBLE $VERSION);
use Carp qw(croak);
+use Encode qw(encode);
use Pod::Simple ();
@ISA = qw(Pod::Simple);
-$VERSION = '2.23';
+$VERSION = '2.25';
# Set the debugging level. If someone has inserted a debug function into this
# class already, use that. Otherwise, use any Pod::Simple debug function
@@ -723,7 +724,11 @@ sub outindex {
# Output some text, without any additional changes.
sub output {
my ($self, @text) = @_;
- print { $$self{output_fh} } @text;
+ if ($$self{ENCODE}) {
+ print { $$self{output_fh} } encode ('UTF-8', join ('', @text));
+ } else {
+ print { $$self{output_fh} } @text;
+ }
}
##############################################################################
@@ -740,17 +745,19 @@ sub start_document {
return;
}
- # If we were given the utf8 option, set an output encoding on our file
- # handle. Wrap in an eval in case we're using a version of Perl too old
- # to understand this.
- #
- # This is evil because it changes the global state of a file handle that
- # we may not own. However, we can't just blindly encode all output, since
- # there may be a pre-applied output encoding (such as from PERL_UNICODE)
- # and then we would double-encode. This seems to be the least bad
- # approach.
+ # When UTF-8 output is set, check whether our output file handle already
+ # has a PerlIO encoding layer set. If it does not, we'll need to encode
+ # our output before printing it (handled in the output() sub). Wrap the
+ # check in an eval to handle versions of Perl without PerlIO.
+ $$self{ENCODE} = 0;
if ($$self{utf8}) {
- eval { binmode ($$self{output_fh}, ':encoding(UTF-8)') };
+ $$self{ENCODE} = 1;
+ eval {
+ my @layers = PerlIO::get_layers ($$self{output_fh});
+ if (grep { $_ eq 'utf8' } @layers) {
+ $$self{ENCODE} = 0;
+ }
+ }
}
# Determine information for the preamble and then output it.
@@ -949,8 +956,9 @@ sub cmd_para {
if defined ($line) && DEBUG && !$$self{IN_NAME};
# Force exactly one newline at the end and strip unwanted trailing
- # whitespace at the end.
- $text =~ s/\s*$/\n/;
+ # whitespace at the end, but leave "\ " backslashed space from an S< >
+ # at the end of a line.
+ $text =~ s/((?:\\ )*)\s*$/$1\n/;
# Output the paragraph.
$self->output ($self->protect ($self->textmapfonts ($text)));
diff --git a/cpan/podlators/lib/Pod/Text.pm b/cpan/podlators/lib/Pod/Text.pm
index c68313c389..cc02820660 100644
--- a/cpan/podlators/lib/Pod/Text.pm
+++ b/cpan/podlators/lib/Pod/Text.pm
@@ -29,6 +29,7 @@ use strict;
use vars qw(@ISA @EXPORT %ESCAPES $VERSION);
use Carp qw(carp croak);
+use Encode qw(encode);
use Exporter ();
use Pod::Simple ();
@@ -37,7 +38,7 @@ use Pod::Simple ();
# We have to export pod2text for backward compatibility.
@EXPORT = qw(pod2text);
-$VERSION = '3.14';
+$VERSION = '3.15';
##############################################################################
# Initialization
@@ -250,7 +251,8 @@ sub reformat {
# necessary to match the input encoding unless UTF-8 output is forced. This
# preserves the traditional pass-through behavior of Pod::Text.
sub output {
- my ($self, $text) = @_;
+ my ($self, @text) = @_;
+ my $text = join ('', @text);
$text =~ tr/\240\255/ /d;
unless ($$self{opt_utf8} || $$self{CHECKED_ENCODING}) {
my $encoding = $$self{encoding} || '';
@@ -259,7 +261,11 @@ sub output {
}
$$self{CHECKED_ENCODING} = 1;
}
- print { $$self{output_fh} } $text;
+ if ($$self{ENCODE}) {
+ print { $$self{output_fh} } encode ('UTF-8', $text);
+ } else {
+ print { $$self{output_fh} } $text;
+ }
}
# Output a block of code (something that isn't part of the POD text). Called
@@ -284,17 +290,19 @@ sub start_document {
# We have to redo encoding handling for each document.
delete $$self{CHECKED_ENCODING};
- # If we were given the utf8 option, set an output encoding on our file
- # handle. Wrap in an eval in case we're using a version of Perl too old
- # to understand this.
- #
- # This is evil because it changes the global state of a file handle that
- # we may not own. However, we can't just blindly encode all output, since
- # there may be a pre-applied output encoding (such as from PERL_UNICODE)
- # and then we would double-encode. This seems to be the least bad
- # approach.
+ # When UTF-8 output is set, check whether our output file handle already
+ # has a PerlIO encoding layer set. If it does not, we'll need to encode
+ # our output before printing it (handled in the output() sub). Wrap the
+ # check in an eval to handle versions of Perl without PerlIO.
+ $$self{ENCODE} = 0;
if ($$self{opt_utf8}) {
- eval { binmode ($$self{output_fh}, ':encoding(UTF-8)') };
+ $$self{ENCODE} = 1;
+ eval {
+ my @layers = PerlIO::get_layers ($$self{output_fh});
+ if (grep { $_ eq 'utf8' } @layers) {
+ $$self{ENCODE} = 0;
+ }
+ };
}
return '';