summaryrefslogtreecommitdiffstats
path: root/scripts/MarkdownBook
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/MarkdownBook')
-rw-r--r--scripts/MarkdownBook/Book.pm10
-rw-r--r--scripts/MarkdownBook/Book/HTML.pm41
-rw-r--r--scripts/MarkdownBook/Document/HTML.pm38
3 files changed, 44 insertions, 45 deletions
diff --git a/scripts/MarkdownBook/Book.pm b/scripts/MarkdownBook/Book.pm
index ac41631..ffabb18 100644
--- a/scripts/MarkdownBook/Book.pm
+++ b/scripts/MarkdownBook/Book.pm
@@ -142,6 +142,16 @@ sub parse
}
}
+sub output
+{
+ my ($self) = @_;
+ my $doc;
+
+ foreach $doc (@{$self->{'docs'}}) {
+ $doc->output();
+ }
+}
+
sub list_documents
{
my ($self) = @_;
diff --git a/scripts/MarkdownBook/Book/HTML.pm b/scripts/MarkdownBook/Book/HTML.pm
index 864d3f1..1edc215 100644
--- a/scripts/MarkdownBook/Book/HTML.pm
+++ b/scripts/MarkdownBook/Book/HTML.pm
@@ -39,45 +39,4 @@ sub new
return $self;
}
-sub output
-{
- my ($self) = @_;
- my $doc_tmpl;
- my $doc;
- my $doc_fh;
-
- $doc_tmpl = HTML::Template->new(filename => 'include/document.tmpl');
-
- foreach $doc (@{$self->{'docs'}}) {
-
- $doc_tmpl->param(
- IS_INDEX => (ref($doc) eq $self->get_document_module('Index')));
-
- $doc_tmpl->param(BOOK_TITLE => $self->{'title'});
- $doc_tmpl->param(TITLE => $doc->title());
- $doc_tmpl->param(CHAPT_TITLE => $doc->full_title());
-
- if (defined($doc->prev())) {
- $doc_tmpl->param(PREV_LINK => $doc->prev()->file() . '.html');
- $doc_tmpl->param(PREV_TITLE => $doc->prev()->title());
- } else {
- $doc_tmpl->param(PREV_LINK => undef);
- $doc_tmpl->param(PREV_TITLE => undef);
- }
- if (defined($doc->next())) {
- $doc_tmpl->param(NEXT_LINK => $doc->next()->file() . '.html');
- $doc_tmpl->param(NEXT_TITLE => $doc->next()->title());
- } else {
- $doc_tmpl->param(NEXT_LINK => undef);
- $doc_tmpl->param(NEXT_TITLE => undef);
- }
-
- $doc_tmpl->param(BODY => $doc->output());
-
- open($doc_fh, '>', $doc->file_path() . '.html');
- $doc_tmpl->output(print_to => $doc_fh);
- close($doc_fh);
- }
-}
-
1;
diff --git a/scripts/MarkdownBook/Document/HTML.pm b/scripts/MarkdownBook/Document/HTML.pm
index 3548b65..bb30e56 100644
--- a/scripts/MarkdownBook/Document/HTML.pm
+++ b/scripts/MarkdownBook/Document/HTML.pm
@@ -66,19 +66,49 @@ sub output
{
my ($self) = @_;
- my $elem;
+ my $doc_tmpl;
my %opt_end_tags;
- my $out;
+ my $elem;
+ my $body;
+ my $doc_fh;
+
+ $doc_tmpl = HTML::Template->new(filename => 'include/document.tmpl');
# Don't omit any end tags.
%opt_end_tags = map([$_ => 0], %HTML::Element::optionalEndTag);
foreach $elem (@{$self->{'tree_body'}}[0]->content_list()) {
# It's safe to assume (ref($elem) eq 'HTML::Element').
- $out .= $elem->as_HTML('<>&', '', \%opt_end_tags) . "\n";
+ $body .= $elem->as_HTML('<>&', '', \%opt_end_tags) . "\n";
}
- return $out;
+ $doc_tmpl->param(IS_INDEX => (ref($self) eq
+ $self->{'book'}->get_document_module('Index')));
+
+ $doc_tmpl->param(BOOK_TITLE => $self->{'book'}->title());
+ $doc_tmpl->param(TITLE => $self->{'title'});
+ $doc_tmpl->param(CHAPT_TITLE => $self->full_title());
+
+ if (defined($self->{'prev'})) {
+ $doc_tmpl->param(PREV_LINK => $self->{'prev'}->file() . '.html');
+ $doc_tmpl->param(PREV_TITLE => $self->{'prev'}->title());
+ } else {
+ $doc_tmpl->param(PREV_LINK => undef);
+ $doc_tmpl->param(PREV_TITLE => undef);
+ }
+ if (defined($self->{'next'})) {
+ $doc_tmpl->param(NEXT_LINK => $self->{'next'}->file() . '.html');
+ $doc_tmpl->param(NEXT_TITLE => $self->{'next'}->title());
+ } else {
+ $doc_tmpl->param(NEXT_LINK => undef);
+ $doc_tmpl->param(NEXT_TITLE => undef);
+ }
+
+ $doc_tmpl->param(BODY => $body);
+
+ open($doc_fh, '>', $self->file_path() . '.html');
+ $doc_tmpl->output(print_to => $doc_fh);
+ close($doc_fh);
}
1;