diff options
Diffstat (limited to 'Master/tlpkg/tlperl/lib/Pod/Text.pm')
-rw-r--r-- | Master/tlpkg/tlperl/lib/Pod/Text.pm | 65 |
1 files changed, 33 insertions, 32 deletions
diff --git a/Master/tlpkg/tlperl/lib/Pod/Text.pm b/Master/tlpkg/tlperl/lib/Pod/Text.pm index 87f9e816d00..e141da2fd6d 100644 --- a/Master/tlpkg/tlperl/lib/Pod/Text.pm +++ b/Master/tlpkg/tlperl/lib/Pod/Text.pm @@ -1,4 +1,4 @@ -# Pod::Text -- Convert POD data to formatted ASCII text. +# Pod::Text -- Convert POD data to formatted text. # # This module converts POD to formatted text. It replaces the old Pod::Text # module that came with versions of Perl prior to 5.6.0 and attempts to match @@ -11,8 +11,8 @@ # me any patches at the address above in addition to sending them to the # standard Perl mailing lists. # -# Copyright 1999, 2000, 2001, 2002, 2004, 2006, 2008, 2009, 2012, 2013 -# Russ Allbery <rra@stanford.edu> +# Copyright 1999, 2000, 2001, 2002, 2004, 2006, 2008, 2009, 2012, 2013, 2014, +# 2015 Russ Allbery <rra@cpan.org> # # This program is free software; you may redistribute it and/or modify it # under the same terms as Perl itself. @@ -23,9 +23,10 @@ package Pod::Text; -require 5.004; - +use 5.006; use strict; +use warnings; + use vars qw(@ISA @EXPORT %ESCAPES $VERSION); use Carp qw(carp croak); @@ -38,7 +39,7 @@ use Pod::Simple (); # We have to export pod2text for backward compatibility. @EXPORT = qw(pod2text); -$VERSION = '3.18'; +$VERSION = '4.07'; ############################################################################## # Initialization @@ -126,10 +127,10 @@ sub new { $$self{LQUOTE} = $$self{RQUOTE} = ''; } elsif (length ($$self{opt_quotes}) == 1) { $$self{LQUOTE} = $$self{RQUOTE} = $$self{opt_quotes}; - } elsif ($$self{opt_quotes} =~ /^(.)(.)$/ - || $$self{opt_quotes} =~ /^(..)(..)$/) { - $$self{LQUOTE} = $1; - $$self{RQUOTE} = $2; + } elsif (length ($$self{opt_quotes}) % 2 == 0) { + my $length = length ($$self{opt_quotes}) / 2; + $$self{LQUOTE} = substr ($$self{opt_quotes}, 0, $length); + $$self{RQUOTE} = substr ($$self{opt_quotes}, $length); } else { croak qq(Invalid quote specification "$$self{opt_quotes}"); } @@ -273,12 +274,12 @@ sub output { my ($self, @text) = @_; my $text = join ('', @text); $text =~ tr/\240\255/ /d; - unless ($$self{opt_utf8} || $$self{CHECKED_ENCODING}) { + unless ($$self{opt_utf8}) { my $encoding = $$self{encoding} || ''; - if ($encoding) { + if ($encoding && $encoding ne $$self{ENCODING}) { + $$self{ENCODING} = $encoding; eval { binmode ($$self{output_fh}, ":encoding($encoding)") }; } - $$self{CHECKED_ENCODING} = 1; } if ($$self{ENCODE}) { print { $$self{output_fh} } encode ('UTF-8', $text); @@ -312,7 +313,7 @@ sub start_document { $$self{PENDING} = [[]]; # Pending output. # We have to redo encoding handling for each document. - delete $$self{CHECKED_ENCODING}; + $$self{ENCODING} = ''; # 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 @@ -326,6 +327,7 @@ sub start_document { my $flag = (PerlIO::get_layers ($$self{output_fh}, @options))[-1]; if ($flag & PerlIO::F_UTF8 ()) { $$self{ENCODE} = 0; + $$self{ENCODING} = 'UTF-8'; } }; } @@ -759,7 +761,7 @@ parsers =head1 NAME -Pod::Text - Convert POD data to formatted ASCII text +Pod::Text - Convert POD data to formatted text =head1 SYNOPSIS @@ -774,10 +776,10 @@ Pod::Text - Convert POD data to formatted ASCII text =head1 DESCRIPTION -Pod::Text is a module that can convert documentation in the POD format (the -preferred language for documenting Perl) into formatted ASCII. It uses no -special formatting controls or codes whatsoever, and its output is therefore -suitable for nearly any device. +Pod::Text is a module that can convert documentation in the POD format +(the preferred language for documenting Perl) into formatted text. It +uses no special formatting controls or codes whatsoever, and its output is +therefore suitable for nearly any device. As a derived class from Pod::Simple, Pod::Text supports the same methods and interfaces. See L<Pod::Simple> for all the details; briefly, one creates a @@ -850,10 +852,9 @@ important. =item quotes Sets the quote marks used to surround CE<lt>> text. If the value is a -single character, it is used as both the left and right quote; if it is two -characters, the first character is used as the left quote and the second as -the right quoted; and if it is four characters, the first two are used as -the left quote and the second two as the right quote. +single character, it is used as both the left and right quote. Otherwise, +it is split in half, and the first half of the string is used as the left +quote and the second is used as the right quote. This may also be set to the special value C<none>, in which case no quote marks are added around CE<lt>> text. @@ -880,10 +881,10 @@ doesn't encode its output). If this option is given, the output encoding is forced to UTF-8. Be aware that, when using this option, the input encoding of your POD -source must be properly declared unless it is US-ASCII or Latin-1. POD -input without an C<=encoding> command will be assumed to be in Latin-1, -and if it's actually in UTF-8, the output will be double-encoded. See -L<perlpod(1)> for more information on the C<=encoding> command. +source should be properly declared unless it's US-ASCII. Pod::Simple will +attempt to guess the encoding and may be successful if it's Latin-1 or +UTF-8, but it will produce warnings. Use the C<=encoding> command to +declare the encoding. See L<perlpod(1)> for more information. =item width @@ -933,8 +934,8 @@ and the input file it was given could not be opened. =item Invalid quote specification "%s" (F) The quote specification given (the C<quotes> option to the -constructor) was invalid. A quote specification must be one, two, or four -characters long. +constructor) was invalid. A quote specification must be either one +character long or an even number (greater than one) characters long. =item POD document had syntax errors @@ -989,7 +990,7 @@ Perl core distribution as of 5.6.0. =head1 AUTHOR -Russ Allbery <rra@stanford.edu>, based I<very> heavily on the original +Russ Allbery <rra@cpan.org>, based I<very> heavily on the original Pod::Text by Tom Christiansen <tchrist@mox.perl.com> and its conversion to Pod::Parser by Brad Appleton <bradapp@enteract.com>. Sean Burke's initial conversion of Pod::Man to use Pod::Simple provided much-needed guidance on @@ -997,8 +998,8 @@ how to use Pod::Simple. =head1 COPYRIGHT AND LICENSE -Copyright 1999, 2000, 2001, 2002, 2004, 2006, 2008, 2009, 2012, 2013 Russ -Allbery <rra@stanford.edu>. +Copyright 1999, 2000, 2001, 2002, 2004, 2006, 2008, 2009, 2012, 2013, 2014, +2015 Russ Allbery <rra@cpan.org> This program is free software; you may redistribute it and/or modify it under the same terms as Perl itself. |