diff options
author | P. J. McDermott <pjm@nac.net> | 2012-08-12 07:35:01 (EDT) |
---|---|---|
committer | P. J. McDermott <pjm@nac.net> | 2012-08-12 07:35:01 (EDT) |
commit | eda7d670f3545bbf0a5704a19920417c71d25e60 (patch) | |
tree | 7f76621fa02e8b7edb21739bf051447ab7b660a6 /scripts/MarkdownBook | |
parent | 64bc54a6fed0d8de05df260f83cd7bb177fd93b3 (diff) |
Collect sections in book.
Diffstat (limited to 'scripts/MarkdownBook')
-rw-r--r-- | scripts/MarkdownBook/Book.pm | 10 | ||||
-rw-r--r-- | scripts/MarkdownBook/Document.pm | 1 |
2 files changed, 11 insertions, 0 deletions
diff --git a/scripts/MarkdownBook/Book.pm b/scripts/MarkdownBook/Book.pm index f758aa3..3328cae 100644 --- a/scripts/MarkdownBook/Book.pm +++ b/scripts/MarkdownBook/Book.pm @@ -40,6 +40,8 @@ sub new } $self->{'dir'} = $dir; $self->{'docs'} = []; + $self->{'sections'} = []; + $self->{'sections_by_id'} = {}; open($control_fh, '<', $dir . '/control'); while (<$control_fh>) { @@ -142,6 +144,14 @@ sub create_documents } } +sub add_section +{ + my ($self, $section) = @_; + + push(@{$self->{'sections'}}, $section); + $self->{'sections_by_id'}->{$section->id()} = $section; +} + sub parse { my ($self) = @_; diff --git a/scripts/MarkdownBook/Document.pm b/scripts/MarkdownBook/Document.pm index 6b6b966..63750f3 100644 --- a/scripts/MarkdownBook/Document.pm +++ b/scripts/MarkdownBook/Document.pm @@ -213,6 +213,7 @@ sub _do_header $section = MarkdownBook::Section->new($self, $section_number, $section_id, $section_title); push(@{$self->{'sections'}}, $section); + $self->{'book'}->add_section($section); $text = $section_number . ' ' . $section_title; |