summaryrefslogtreecommitdiffstats
path: root/lib/Text/MarkdownBook
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Text/MarkdownBook')
-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;
}
}