From c14216c2fe1f9fd569af8445a8fe24b8c8b0c7ae Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Mon, 13 Aug 2012 22:05:07 -0400 Subject: Index chapters by ID as well as sections. --- diff --git a/lib/Text/MarkdownBook/Book.pm b/lib/Text/MarkdownBook/Book.pm index 4c5f6c7..137a9fa 100644 --- a/lib/Text/MarkdownBook/Book.pm +++ b/lib/Text/MarkdownBook/Book.pm @@ -155,8 +155,9 @@ sub add_section push(@{$self->{'sections'}}, $section); - # Index sections (not documents) by ID. - if (ref($section) eq 'Text::MarkdownBook::Section') { + if (ref($section) =~ m/^Text::MarkdownBook::Document/) { + $self->{'sections_by_id'}->{$section->file()} = $section; + } elsif (ref($section) eq 'Text::MarkdownBook::Section') { $self->{'sections_by_id'}->{$section->id()} = $section; } } -- cgit v0.9.1