10 $PROGRAM_DIR =~ s/[^\/\\]+$//;
11 $PROGRAM_DIR = "./" unless($PROGRAM_DIR);
13 map "$PROGRAM_DIR$_",qw{modules lib
../modules
..lib
};
18 require MyPlace
::Usage
;
19 MyPlace
::Usage
::PrintHelp
();
25 print STDERR
$cmd," ",join(" ",map "\'$_\'",@_),"\n";
32 if($output =~ m/^--/) {
33 unshift @ARGV,$output;
36 die("Usage: input_file [[output_file] [options...]]\n") unless($input);
39 #--verbose !EMPTY!_!MARK!
47 --publisher xiaoranzzz
52 $def_arg{"--level1-toc"} = "//h:h2";
53 $def_arg{"--level2-toc"} = "//h:h3";
54 $def_arg{"--pubdate"} = localtime();
56 my $source_base = $input;
57 $source_base =~ s/\.[^.]+$//;
58 my $target_base = $output || $input;
59 $target_base =~ s/\.[^.]+$//;
60 $output = $target_base . ".epub" unless($output);
61 my $title = $target_base;
64 $def_arg{"--title"}=$title;
65 $def_arg{"--extract-to"}=$target_base;
66 foreach my $img_ext qw
/.jpg .png .jpeg/
68 if (-f
"${source_base}${img_ext}")
70 $def_arg{"--cover"}="$source_base$img_ext";
72 elsif(-f
"cover$img_ext")
74 $def_arg{"--cover"}="cover$img_ext";
82 $def_arg{$_} = "!EMPTY!_!MARK!";
86 $def_arg{$last_arg} = $_;
90 print STDERR
"Convert $input to $output...\n";
91 unlink $output if(-f
$output);
92 my @calibre_args = ();
93 foreach (keys %def_arg) {
94 if($def_arg{$_} eq '!EMPTY!_!MARK!') {
95 push @calibre_args,$_;
98 push @calibre_args,$_,$def_arg{$_};
101 &run
("ebook-convert",$input,$output,@calibre_args);
109 epub_convert - Covert to EPUB book
113 epub_convert input [[output_file] [options...]]
117 options are passing to calibre 'B<ebook-convert>'
121 Covert input to EPUB, Implemented
122 using "calibre ebook-convert".
126 2010-06-07 xiaoranzzz <xiaoranzzz@myplace.hell>
132 xiaoranzzz <xiaoranzzz@myplace.hell>