mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix #1657. Implement "--ignore-tables" option for oeb2mobi.
This commit is contained in:
parent
c3cffa07fe
commit
a3bc14fcfa
@ -79,6 +79,9 @@ class FormatState(object):
|
|||||||
|
|
||||||
|
|
||||||
class MobiMLizer(object):
|
class MobiMLizer(object):
|
||||||
|
def __init__(self, ignore_tables=False):
|
||||||
|
self.ignore_tables = ignore_tables
|
||||||
|
|
||||||
def transform(self, oeb, context):
|
def transform(self, oeb, context):
|
||||||
oeb.logger.info('Converting XHTML to Mobipocket markup...')
|
oeb.logger.info('Converting XHTML to Mobipocket markup...')
|
||||||
self.oeb = oeb
|
self.oeb = oeb
|
||||||
@ -341,6 +344,8 @@ class MobiMLizer(object):
|
|||||||
tag = 'tr'
|
tag = 'tr'
|
||||||
elif display == 'table-cell':
|
elif display == 'table-cell':
|
||||||
tag = 'td'
|
tag = 'td'
|
||||||
|
if tag in TABLE_TAGS and self.ignore_tables:
|
||||||
|
tag = 'span' if tag == 'td' else 'div'
|
||||||
if tag in TABLE_TAGS:
|
if tag in TABLE_TAGS:
|
||||||
for attr in ('rowspan', 'colspan'):
|
for attr in ('rowspan', 'colspan'):
|
||||||
if attr in elem.attrib:
|
if attr in elem.attrib:
|
||||||
|
@ -524,6 +524,10 @@ def config(defaults=None):
|
|||||||
help=_('Modify images to meet Palm device size limitations.'))
|
help=_('Modify images to meet Palm device size limitations.'))
|
||||||
mobi('toc_title', ['--toc-title'], default=None,
|
mobi('toc_title', ['--toc-title'], default=None,
|
||||||
help=_('Title for any generated in-line table of contents.'))
|
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))
|
||||||
@ -581,7 +585,7 @@ def oeb2mobi(opts, inpath):
|
|||||||
rasterizer.transform(oeb, context)
|
rasterizer.transform(oeb, context)
|
||||||
trimmer = ManifestTrimmer()
|
trimmer = ManifestTrimmer()
|
||||||
trimmer.transform(oeb, context)
|
trimmer.transform(oeb, context)
|
||||||
mobimlizer = MobiMLizer()
|
mobimlizer = MobiMLizer(ignore_tables=opts.ignore_tables)
|
||||||
mobimlizer.transform(oeb, context)
|
mobimlizer.transform(oeb, context)
|
||||||
writer = MobiWriter(compression=compression, imagemax=imagemax)
|
writer = MobiWriter(compression=compression, imagemax=imagemax)
|
||||||
writer.dump(oeb, outpath)
|
writer.dump(oeb, outpath)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user