mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Pretty much full utility for LIT->MOBI direct conversion pipeline.
This commit is contained in:
parent
f24f4f7b1a
commit
459d350af3
@ -84,11 +84,16 @@ class MobiMLizer(object):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def config(cls, cfg):
|
def config(cls, cfg):
|
||||||
|
group = cfg.add_group('mobiml', _('Mobipocket markup options.'))
|
||||||
|
group('ignore_tables', ['--ignore-tables'], default=False,
|
||||||
|
help=_('Render HTML tables as blocks of text instead of actual '
|
||||||
|
'tables. This is neccessary if the HTML contains very '
|
||||||
|
'large or complex tables.'))
|
||||||
return cfg
|
return cfg
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def generate(cls, opts):
|
def generate(cls, opts):
|
||||||
return cls()
|
return cls(ignore_tables=opts.ignore_tables)
|
||||||
|
|
||||||
def __call__(self, oeb, context):
|
def __call__(self, oeb, context):
|
||||||
oeb.logger.info('Converting XHTML to Mobipocket markup...')
|
oeb.logger.info('Converting XHTML to Mobipocket markup...')
|
||||||
|
@ -292,13 +292,28 @@ class Serializer(object):
|
|||||||
buffer.seek(hoff)
|
buffer.seek(hoff)
|
||||||
buffer.write('%010d' % ioff)
|
buffer.write('%010d' % ioff)
|
||||||
|
|
||||||
|
|
||||||
|
class MobiFlattener(object):
|
||||||
|
def config(self, cfg):
|
||||||
|
return cfg
|
||||||
|
|
||||||
|
def generate(self, opts):
|
||||||
|
return self
|
||||||
|
|
||||||
|
def __call__(self, oeb, context):
|
||||||
|
fbase = context.dest.fbase
|
||||||
|
fkey = context.dest.fnums.values()
|
||||||
|
flattener = CSSFlattener(
|
||||||
|
fbase=fbase, fkey=fkey, unfloat=True, untable=True)
|
||||||
|
return flattener(oeb, context)
|
||||||
|
|
||||||
|
|
||||||
class MobiWriter(object):
|
class MobiWriter(object):
|
||||||
COLLAPSE_RE = re.compile(r'[ \t\r\n\v]+')
|
COLLAPSE_RE = re.compile(r'[ \t\r\n\v]+')
|
||||||
|
|
||||||
DEFAULT_PROFILE = 'CybookG3'
|
DEFAULT_PROFILE = 'CybookG3'
|
||||||
|
|
||||||
TRANSFORMS = [HTMLTOCAdder, CaseMangler, CSSFlattener, SVGRasterizer,
|
TRANSFORMS = [HTMLTOCAdder, CaseMangler, MobiFlattener(), SVGRasterizer,
|
||||||
ManifestTrimmer, MobiMLizer]
|
ManifestTrimmer, MobiMLizer]
|
||||||
|
|
||||||
def __init__(self, compression=None, imagemax=None,
|
def __init__(self, compression=None, imagemax=None,
|
||||||
@ -562,13 +577,6 @@ def config(defaults=None):
|
|||||||
else:
|
else:
|
||||||
c = StringConfig(defaults, desc)
|
c = StringConfig(defaults, desc)
|
||||||
|
|
||||||
mobi = c.add_group('mobipocket', _('Mobipocket-specific options.'))
|
|
||||||
mobi('toc_title', ['--toc-title'], default=None,
|
|
||||||
help=_('Title for any generated in-line table of contents.'))
|
|
||||||
mobi('ignore_tables', ['--ignore-tables'], default=False,
|
|
||||||
help=_('Render HTML tables as blocks of text instead of actual '
|
|
||||||
'tables. This is neccessary if the HTML contains very large '
|
|
||||||
'or complex tables.'))
|
|
||||||
profiles = c.add_group('profiles', _('Device renderer profiles. '
|
profiles = c.add_group('profiles', _('Device renderer profiles. '
|
||||||
'Affects conversion of font sizes, image rescaling and rasterization '
|
'Affects conversion of font sizes, image rescaling and rasterization '
|
||||||
'of tables. Valid profiles are: %s.') % ', '.join(_profiles))
|
'of tables. Valid profiles are: %s.') % ', '.join(_profiles))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user