summaryrefslogtreecommitdiffstats
path: root/scripts/MarkdownBook/Book.pm
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/MarkdownBook/Book.pm')
-rw-r--r--scripts/MarkdownBook/Book.pm19
1 files changed, 8 insertions, 11 deletions
diff --git a/scripts/MarkdownBook/Book.pm b/scripts/MarkdownBook/Book.pm
index f942803..572fb53 100644
--- a/scripts/MarkdownBook/Book.pm
+++ b/scripts/MarkdownBook/Book.pm
@@ -30,17 +30,14 @@ sub new
$self = {};
bless($self, $class);
- if ($format eq 'html') {
- use MarkdownBook::Document::HTML;
- $self->{'format'} = 'html';
- $self->{'format_mod'} = 'HTML';
- } elsif ($format eq 'txt') {
- use MarkdownBook::Document::Txt;
- $self->{'format'} = 'txt';
- $self->{'format_mod'} = 'Txt';
- } else {
- croak('Unsupported format "' . $format . '"');
+ unless ($format =~ m/^[a-z]+/) {
+ Carp::croak('Invalid format "' . $format . '"');
}
+ eval {
+ require 'MarkdownBook/Document/' . $format . '.pm';
+ 1;
+ } or Carp::croak('Unsupported format "' . $format . '"');
+ $self->{'format'} = $format;
$self->{'dir'} = $dir;
$self->{'docs'} = [];
@@ -96,7 +93,7 @@ sub _get_document_module
{
my ($self) = @_;
- return 'MarkdownBook::Document::' . $self->{'format_mod'};
+ return 'MarkdownBook::Document::' . $self->{'format'};
}
sub create_documents