[epub, mobi] new switch use-kindlegen and html-toc switch improvement
[librarian.git] / librarian / book2anything.py
index b8b8d27..0a8e736 100755 (executable)
@@ -10,7 +10,7 @@ import optparse
 
 from librarian import DirDocProvider, ParseError
 from librarian.parser import WLDocument
-from librarian.cover import WLCover
+from librarian.cover import DefaultEbookCover
 
 
 class Option(object):
@@ -56,6 +56,12 @@ class Book2Anything(object):
         parser.add_option('-v', '--verbose', 
                 action='store_true', dest='verbose', default=False,
                 help='print status messages to stdout')
+        parser.add_option('-t', '--html-toc', 
+                action='store_true', dest='html_toc', default=False,
+                help='with inline html toc [book2epub only]')
+        parser.add_option('-k', '--use-kindlegen', 
+                action='store_true', dest='use_kindlegen', default=False,
+                help='use kindlegen tool [book2mobi only]')
         parser.add_option('-d', '--make-dir',
                 action='store_true', dest='make_dir', default=False,
                 help='create a directory for author and put the output file in it')
@@ -97,13 +103,17 @@ class Book2Anything(object):
         if transform_flags:
             transform_args['flags'] = transform_flags
         # Add cover support, if any.
+        if options.html_toc and cls.ext == 'epub':
+            transform_args['html_toc'] = True
+        if options.use_kindlegen and cls.ext == 'mobi':
+            transform_args['use_kindlegen'] = True
         if cls.uses_cover:
             if options.image_cache:
                 def cover_class(*args, **kwargs):
-                    return WLCover(image_cache=options.image_cache, *args, **kwargs)
+                    return DefaultEbookCover(image_cache=options.image_cache, *args, **kwargs)
                 transform_args['cover'] = cover_class
             elif not cls.cover_optional or options.with_cover:
-                transform_args['cover'] = WLCover
+                transform_args['cover'] = DefaultEbookCover
 
 
         # Do some real work