From: Steve Peters Date: Thu, 5 Jun 2008 12:56:53 +0000 (+0000) Subject: Upgrade to Pod-Simple-3.07 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8737ae4deeb0953ae3b76fcc430072d0e030997c;p=p5sagit%2Fp5-mst-13.2.git Upgrade to Pod-Simple-3.07 p4raw-id: //depot/perl@34000 --- diff --git a/lib/Pod/Simple.pm b/lib/Pod/Simple.pm index 0b26a2f..1e32572 100644 --- a/lib/Pod/Simple.pm +++ b/lib/Pod/Simple.pm @@ -18,7 +18,7 @@ use vars qw( ); @ISA = ('Pod::Simple::BlackBox'); -$VERSION = '3.06'; +$VERSION = '3.07'; @Known_formatting_codes = qw(I B C L E F S X Z); %Known_formatting_codes = map(($_=>1), @Known_formatting_codes); diff --git a/lib/Pod/Simple/XHTML.pm b/lib/Pod/Simple/XHTML.pm index 05c25da..d130faa 100644 --- a/lib/Pod/Simple/XHTML.pm +++ b/lib/Pod/Simple/XHTML.pm @@ -27,13 +27,31 @@ L, but it largely preserves the same interface. package Pod::Simple::XHTML; use strict; -use vars qw( $VERSION @ISA ); +use vars qw( $VERSION @ISA $HAS_HTML_ENTITIES ); $VERSION = '3.04'; use Carp (); use Pod::Simple::Methody (); @ISA = ('Pod::Simple::Methody'); -use HTML::Entities 'encode_entities'; +BEGIN { + $HAS_HTML_ENTITIES = eval "require HTML::Entities; 1"; +} + +my %entities = ( + q{>} => 'gt', + q{<} => 'lt', + q{'} => '#39', + q{"} => 'quot', + q{&} => 'amp', +); + +sub encode_entities { + return HTML::Entities::encode_entities( $_[0] ) if $HAS_HTML_ENTITIES; + my $str = $_[0]; + my $ents = join '', keys %entities; + $str =~ s/([$ents])/'&' . $entities{$1} . ';'/ge; + return $str; +} #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/lib/Pod/Simple/t/xhtml01.t b/lib/Pod/Simple/t/xhtml01.t index 37e295c..d75605a 100644 --- a/lib/Pod/Simple/t/xhtml01.t +++ b/lib/Pod/Simple/t/xhtml01.t @@ -8,7 +8,7 @@ BEGIN { use strict; use lib '../lib'; -use Test::More tests => 25; +use Test::More tests => 26; use_ok('Pod::Simple::XHTML') or exit; @@ -318,8 +318,13 @@ is($results, <<"EOHTML", "Verbatim text with encodable entities"); EOHTML -initialize($parser, $results); -$parser->parse_string_document(<<'EOPOD'); +SKIP: for my $use_html_entities (0, 1) { + if ($use_html_entities and not $Pod::Simple::XHTML::HAS_HTML_ENTITIES) { + skip("HTML::Entities not installed", 1); + } + local $Pod::Simple::XHTML::HAS_HTML_ENTITIES = $use_html_entities; + initialize($parser, $results); + $parser->parse_string_document(<<'EOPOD'); =pod # this header is very important & don't you forget it @@ -332,6 +337,7 @@ is($results, <<"EOHTML", "Verbatim text with markup and embedded formatting"); my \$text = "File is: " . <FILE>; EOHTML +} ######################################