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);
40 my $source_base = $input;
41 $source_base =~ s/\.[^.]+$//;
42 my $target_base = $output || $input;
43 $target_base =~ s/\.[^.]+$//;
44 my $input_file_xhtml = "content.xhtml";
45 $output = $target_base . ".epub" unless($output);
46 my $title = $target_base;
49 print STDERR
"Convert $input to $input_file_xhtml...\n";
50 unlink $input_file_xhtml if(-f
$input_file_xhtml);
55 "-o",$input_file_xhtml,
57 die("Failed!") unless(-f
$input_file_xhtml);
58 $def_arg{"--title"}=$title;
59 foreach my $img_ext qw
/.jpg .png .jpeg/
61 if (-f
"${source_base}${img_ext}")
63 $def_arg{"--cover"}="$source_base$img_ext";
65 elsif(-f
"cover$img_ext")
67 $def_arg{"--cover"}="cover$img_ext";
75 $def_arg{$_} = "!EMPTY!_!MARK!";
79 $def_arg{$last_arg} = $_;
83 print STDERR
"Convert $input_file_xhtml to $output...\n";
84 unlink $output if(-f
$output);
85 my @calibre_args = ();
86 foreach (keys %def_arg) {
87 if($def_arg{$_} eq '!EMPTY!_!MARK!') {
88 push @calibre_args,$_;
91 push @calibre_args,$_,$def_arg{$_};
95 &run
("epub_convert",$input_file_xhtml,$output,@calibre_args);
103 epub_convert_text - Covert plain text file to EPUB book
107 epub_convert_text input_file [[output_file] [options...]]
111 options are passing to calibre 'B<ebook-convert>'
115 Covert plain text file to EPUB, Implemented
116 using "epub_text2xhtml" and "epub_convert"
117 which depends on "ebook-convert" privided
122 2010-06-07 xiaoranzzz <xiaoranzzz@myplace.hell>
128 xiaoranzzz <xiaoranzzz@myplace.hell>