Permalink
Browse files

Added filename attribute to Heading DOM object.

This allows the ToC to build links to the proper files with only a list of
Heading objects. Perhaps this needs to go elsewhere eventually, but it's more
right than the previous version.
  • Loading branch information...
1 parent 4906f43 commit f4db60dc18aedf53c7ffab6bbd730b08bc7ad5a7 @chromatic committed Mar 27, 2012
Showing with 9 additions and 8 deletions.
  1. +4 −2 lib/Pod/PseudoPod/DOM.pm
  2. +3 −4 lib/Pod/PseudoPod/DOM/Elements.pm
  3. +2 −2 lib/Pod/PseudoPod/DOM/Role/HTML.pm
@@ -194,8 +194,10 @@ BEGIN
my $start_meth = sub
{
my $self = shift;
- $self->push_heading_element(
- Heading => level => $heading, type => 'header'
+ $self->push_heading_element( Heading =>
+ level => $heading,
+ type => 'header',
+ filename => $self->{basefile},
);
};
@@ -82,8 +82,6 @@ use Moose;
extends 'Pod::PseudoPod::DOM::Element::Linkable';
- # XXX: this shouldn't be here
- sub get_filename { shift->link }
sub get_anchor { shift->emit_kids( encode => 'index_anchor' ) }
sub get_link_text { shift->heading->emit_kids }
}
@@ -133,8 +131,9 @@ use Moose;
extends 'Pod::PseudoPod::DOM::ParentElement';
- has 'level', is => 'ro', required => 1;
- has 'anchor', is => 'rw';
+ has 'level', is => 'ro', required => 1;
+ has 'anchor', is => 'rw';
+ has 'filename', is => 'ro', required => 1;
sub exclude_from_toc
{
@@ -21,7 +21,7 @@ sub get_link_for_anchor
my $anchors = $self->anchors;
return unless my $heading = $anchors->{$anchor};
- my $filename = $heading->get_filename;
+ my $filename = $heading->link;
my $target = encode_base64url( $heading->get_anchor );
my $title = $heading->get_link_text;
@@ -166,7 +166,7 @@ sub get_heading_link
my ($self, %args) = @_;
my $content = $self->emit_kids;
- my $filename = $args{filename};
+ my $filename = $self->filename || '';
my $href = $self->emit_kids( encode => 'index_anchor' );
my $frag = 'toc_' . encode_base64url( $href );

0 comments on commit f4db60d

Please sign in to comment.