Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #46 from tsibley/code-in-head-regression

Fix code (C<>) in head regression
  • Loading branch information...
commit 1ca92b99daf0d34129d2ae13bd11a59abda95dcf 2 parents 59be9b7 + 17c7b67
@theory authored
Showing with 25 additions and 5 deletions.
  1. +8 −4 lib/Pod/Simple/XHTML.pm
  2. +17 −1 t/xhtml10.t
View
12 lib/Pod/Simple/XHTML.pm
@@ -342,15 +342,19 @@ sub accept_targets_as_html {
}
sub handle_text {
- if ($_[0]{'in_code'} && @{$_[0]{'in_code'}}) {
- return $_[0]->handle_code( $_[1], $_[0]{'in_code'}[-1] );
- }
# escape special characters in HTML (<, >, &, etc)
my $text = $_[0]->__in_literal_xhtml_region
? $_[1]
: $_[0]->encode_entities( $_[1] );
- $_[0]{'scratch'} .= $text;
+ if ($_[0]{'in_code'} && @{$_[0]{'in_code'}}) {
+ # Intentionally use the raw text in $_[1], even if we're not in a
+ # literal xhtml region, since handle_code calls encode_entities.
+ $_[0]->handle_code( $_[1], $_[0]{'in_code'}[-1] );
+ } else {
+ $_[0]{'scratch'} .= $text;
+ }
+
$_[0]{htext} .= $text if $_[0]{'in_head'};
}
View
18 t/xhtml10.t
@@ -8,7 +8,7 @@ BEGIN {
use strict;
use lib '../lib';
-use Test::More tests => 58;
+use Test::More tests => 60;
#use Test::More 'no_plan';
use_ok('Pod::Simple::XHTML') or exit;
@@ -97,6 +97,22 @@ is $results, <<'EOF', 'Should have both and the index';
<h1 id="Bar">Bar</h1>
EOF
+
+initialize($parser, $results);
+ok $parser->parse_string_document( "=head1 Foo C<Bar>\n\n=head1 C<Baz>" ),
+ 'Parse two headers with C<> formatting';
+is $results, <<'EOF', 'Should have the index';
+<ul id="index">
+ <li><a href="#Foo-Bar">Foo Bar</a></li>
+ <li><a href="#Baz">Baz</a></li>
+</ul>
+
+<h1 id="Foo-Bar">Foo <code>Bar</code></h1>
+
+<h1 id="Baz"><code>Baz</code></h1>
+
+EOF
+
initialize($parser, $results);
ok $parser->parse_string_document( "=head1 Foo\n\n=head1 Bar\n\n=head1 Baz" ),
'Parse three headers';
Please sign in to comment.
Something went wrong with that request. Please try again.