summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorP. J. McDermott <pjm@nac.net>2012-08-13 22:05:07 (EDT)
committer P. J. McDermott <pjm@nac.net>2012-08-13 22:07:03 (EDT)
commitc14216c2fe1f9fd569af8445a8fe24b8c8b0c7ae (patch)
tree0263ac68a10c90d21eaabdcf2ca251591b737a34
parent8fcbf58f2ca41b492aaf0336f118314b0fa69daa (diff)
Index chapters by ID as well as sections.
-rw-r--r--lib/Text/MarkdownBook/Book.pm5
1 files changed, 3 insertions, 2 deletions
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;
}
}