Permalink
Browse files

Added id to HTML anchors for ePub navpoints.

  • Loading branch information...
1 parent 7f087ee commit 44b6c78afb39a0c122bf5d3f421ca992ee6eb0ab @chromatic committed Mar 19, 2012
Showing with 16 additions and 12 deletions.
  1. +3 −4 lib/Pod/PseudoPod/DOM/Role/XHTML.pm
  2. +1 −1 t/html/basic.t
  3. +1 −1 t/html/figures.t
  4. +6 −3 t/html/sections.t
  5. +5 −3 t/html/tags.t
View
7 lib/Pod/PseudoPod/DOM/Role/XHTML.pm
@@ -283,10 +283,9 @@ sub emit_literal
sub emit_anchor
{
- my $self = shift;
- return qq|<a name="|
- . $self->emit_kids( encode => 'index_anchor' )
- . qq|"></a>|;
+ my $self = shift;
+ my $anchor = $self->emit_kids( encode => 'index_anchor' );
+ return qq|<a name="$anchor" id="nav_$anchor"></a>|;
}
sub emit_italics
View
2 t/html/basic.t
@@ -220,7 +220,7 @@ $result = parse( <<'EOPOD' );
A plain paragraph with a Z<crossreferenceendpoint>.
EOPOD
is($result, <<"EOHTML", "Link anchor entity in a paragraph");
-<p>A plain paragraph with a <a name="crossreferenceendpoint"></a>.</p>
+<p>A plain paragraph with a <a name="crossreferenceendpoint" id="nav_crossreferenceendpoint"></a>.</p>
EOHTML
View
2 t/html/figures.t
@@ -14,7 +14,7 @@ use_ok( 'Pod::PseudoPod::DOM' ) or exit;
my $file = read_file( catfile( qw( t test_file.pod ) ) );
my ($doc, $result) = parse_with_anchors( $file );
-like_string $result, qr/<p><a name="figure_link">/,
+like_string $result, qr/<p><a name="figure_link" id="nav_figure_link">/,
'figure should start a figure environment';
like_string $result, qr!<img src="some/path/to/image_file.png"!,
'... without quoting image file paths';
View
9 t/html/sections.t
@@ -33,19 +33,22 @@ like_string $result, qr!<h4>c heading</h4>!,
like_string $result, qr!<h1>Another Suppressed Heading</h1>!,
'... chapter title TOC suppression should create heading';
-like_string $result, qr/<a name="AnotherSuppressedHeading">/,
+like_string $result,
+ qr/<a name="AnotherSuppressedHeading" id="nav_AnotherSuppressedHeading">/,
'... but with anchor';
like_string $result, qr!<h2>A Suppressed Heading</h2>!,
'... section title suppression should create heading';
-like_string $result, qr/<a name="ASuppressedHeading">/,
+like_string $result,
+ qr/<a name="ASuppressedHeading" id="nav_ASuppressedHeading">/,
'... but with anchor';
like_string $result, qr!<h3>Yet Another Suppressed Heading</h3>!,
'... subsection title suppression should create heading';
-like_string $result, qr/<a name="YetAnotherSuppressedHeading">/,
+like_string $result,
+ qr/<a name="YetAnotherSuppressedHeading" id="nav_YetAnotherSuppressedHeading">/,
'... but with anchor';
like_string $result,
View
8 t/html/tags.t
@@ -14,13 +14,15 @@ use_ok( 'Pod::PseudoPod::DOM' ) or exit;
my $file = read_file( catfile( qw( t test_file.pod ) ) );
my $result = parse_with_anchors( $file );
-like_string $result, qr!<a name="startofdocument"></a>!m,
+like_string $result,
+ qr!<a name="startofdocument" id="nav_startofdocument"></a>!m,
'Z<> tags should become anchors';
-like_string $result, qr!<a name="next_heading"></a>!m,
+like_string $result, qr!<a name="next_heading" id="nav_next_heading"></a>!m,
'... without normal escaping';
-like_string $result, qr!<a name="slightlycomplex\?heading"></a>!,
+like_string $result,
+ qr!<a name="slightlycomplex\?heading" id="nav_slightlycomplex\?heading"></a!,
'... and escaping non-alphanumerics';
like_string $result, qr!<a class="url" href="http://www.google.com/">!,

0 comments on commit 44b6c78

Please sign in to comment.