Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/Pod/Simple/XHTML.pm
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,11 @@ sub encode_entities {
$ents =~ s,(?<!\\)([]/]),\\$1,g;
$ents =~ s,(?<!\\)\\\z,\\\\,;
} else {
$ents = join '', keys %entities;
# the same set of characters as in HTML::Entities
$ents = '^\n\r\t !\#\$%\(-;=?-~';
}
my $str = $_[0];
$str =~ s/([$ents])/'&' . ($entities{$1} || sprintf '#x%X', ord $1) . ';'/ge;
$str =~ s/([$ents])/'&' . ($entities{$1} || sprintf '#x%X', unpack('U', $1)) . ';'/ge;
return $str;
}

Expand Down
23 changes: 20 additions & 3 deletions t/xhtml01.t
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# t/xhtml01.t - check basic output from Pod::Simple::XHTML
use strict;
use warnings;
use Test::More tests => 66;
use Test::More tests => 68;

use_ok('Pod::Simple::XHTML') or exit;

Expand Down Expand Up @@ -712,7 +712,7 @@ is($results, "$html\n\n", "Text with =begin html");

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", 3);
skip("HTML::Entities not installed", 4);
}
local $Pod::Simple::XHTML::HAS_HTML_ENTITIES = $use_html_entities;
initialize($parser, $results);
Expand Down Expand Up @@ -751,11 +751,28 @@ EOHTML
# Keep =encoding out of content.
initialize($parser, $results);
$parser->parse_string_document("=encoding ascii\n\n=head1 NAME\n");
is($results, <<"EOHTML", 'Encoding should not be in content')
is($results, <<"EOHTML", 'Encoding should not be in content');
<h1 id="NAME">NAME</h1>

EOHTML

initialize($parser, $results);
$parser->parse_string_document(<<"EOPOD");
=pod

=encoding UTF-8

The pilcrow, ¶, is used to mark the beginning of a new paragraph.

=cut

EOPOD

$T = $use_html_entities ? '&para;' : '&#xB6;';
is($results, <<"EOHTML", 'Non-ASCII characters are escaped')
<p>The pilcrow, ${T}, is used to mark the beginning of a new paragraph.</p>

EOHTML
}


Expand Down