Skip to content

Commit

Permalink
html body id attribute more unique and registered in $self->{ids} for…
Browse files Browse the repository at this point in the history
… idify()
  • Loading branch information
marcgreen committed May 16, 2011
1 parent ccdaf3f commit 1455ce3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
6 changes: 3 additions & 3 deletions lib/Pod/Simple/XHTML.pm
Expand Up @@ -249,7 +249,7 @@ sub new {
$new->{'to_index'} = [];
$new->{'output'} = [];
$new->{'saved'} = [];
$new->{'ids'} = {};
$new->{'ids'} = { '_podtop_' => 1 }; # used in <body>
$new->{'in_li'} = [];

$new->{'__region_targets'} = [];
Expand Down Expand Up @@ -408,7 +408,7 @@ sub _end_head {
my $id = $_[0]->idify($_[0]{scratch});
my $text = $_[0]{scratch};
$_[0]{'scratch'} = $_[0]->backlink && ($h - $add == 0) # backlinks enabled && =head1
? qq{<a href="#top"><h$h id="$id">$text</h$h></a>}
? qq{<a href="#_podtop_"><h$h id="$id">$text</h$h></a>}
: qq{<h$h id="$id">$text</h$h>};
$_[0]->emit;
push @{ $_[0]{'to_index'} }, [$h, $id, $text];
Expand Down Expand Up @@ -477,7 +477,7 @@ $doctype
<title>$title</title>
$metatags
</head>
<body id="top">
<body id="_podtop_">
HTML
$self->emit;
}
Expand Down
25 changes: 12 additions & 13 deletions t/xhtml10.t
Expand Up @@ -44,7 +44,7 @@ is $results, <<'EOF', 'Should have the index';
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
</head>
<body id="top">
<body id="_podtop_">
<ul id="index">
Expand Down Expand Up @@ -409,14 +409,14 @@ is $results, <<'EOF', 'Should have the index and a backlink';
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
</head>
<body id="top">
<body id="_podtop_">
<ul id="index">
<li><a href="#Foo">Foo</a></li>
</ul>
<a href="#top"><h1 id="Foo">Foo</h1></a>
<a href="#_podtop_"><h1 id="Foo">Foo</h1></a>
</body>
</html>
Expand All @@ -435,7 +435,7 @@ is $results, <<'EOF', 'Should have the index and backlinks';
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
</head>
<body id="top">
<body id="_podtop_">
<ul id="index">
Expand All @@ -447,12 +447,11 @@ is $results, <<'EOF', 'Should have the index and backlinks';
<li><a href="#Baz">Baz</a></li>
</ul>
<a href="#top"><h1 id="Foo">Foo</h1></a>
<a href="#_podtop_"><h1 id="Foo">Foo</h1></a>
<h2 id="Bar">Bar</h2>
<a href="#top"><h1 id="Baz">Baz</h1></a>
<a href="#_podtop_"><h1 id="Baz">Baz</h1></a>
</body>
</html>
Expand All @@ -472,12 +471,12 @@ is $results, <<'EOF', 'Should have backlinks but no index';
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
</head>
<body id="top">
<body id="_podtop_">
<a href="#top"><h1 id="Foo">Foo</h1></a>
<a href="#_podtop_"><h1 id="Foo">Foo</h1></a>
<a href="#top"><h1 id="Bar">Bar</h1></a>
<a href="#_podtop_"><h1 id="Bar">Bar</h1></a>
</body>
</html>
Expand All @@ -497,7 +496,7 @@ is $results, <<'EOF', 'Should have index and backlinks around h2 elements';
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
</head>
<body id="top">
<body id="_podtop_">
<ul id="index">
Expand All @@ -509,9 +508,9 @@ is $results, <<'EOF', 'Should have index and backlinks around h2 elements';
</li>
</ul>
<a href="#top"><h2 id="Foo">Foo</h2></a>
<a href="#_podtop_"><h2 id="Foo">Foo</h2></a>
<a href="#top"><h2 id="Bar">Bar</h2></a>
<a href="#_podtop_"><h2 id="Bar">Bar</h2></a>
</body>
</html>
Expand Down

0 comments on commit 1455ce3

Please sign in to comment.