mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
EPUB Input: Fix page margins specified in Adobe page template files with incorrect mime-types not being removed.
This commit is contained in:
parent
c504bbab3d
commit
9ea1c45ab4
@ -206,9 +206,11 @@ class EPUBInput(InputFormatPlugin):
|
|||||||
not_for_spine = set()
|
not_for_spine = set()
|
||||||
for y in opf.itermanifest():
|
for y in opf.itermanifest():
|
||||||
id_ = y.get('id', None)
|
id_ = y.get('id', None)
|
||||||
if id_ and y.get('media-type', None) in \
|
if id_ and y.get('media-type', None) in {
|
||||||
('application/vnd.adobe-page-template+xml','application/text'):
|
'application/vnd.adobe-page-template+xml', 'application/vnd.adobe.page-template+xml',
|
||||||
not_for_spine.add(id_)
|
'application/adobe-page-template+xml', 'application/adobe.page-template+xml',
|
||||||
|
'application/text'}:
|
||||||
|
not_for_spine.add(id_)
|
||||||
|
|
||||||
seen = set()
|
seen = set()
|
||||||
for x in list(opf.iterspine()):
|
for x in list(opf.iterspine()):
|
||||||
|
@ -20,9 +20,10 @@ class RemoveAdobeMargins(object):
|
|||||||
self.oeb, self.opts, self.log = oeb, opts, log
|
self.oeb, self.opts, self.log = oeb, opts, log
|
||||||
|
|
||||||
for item in self.oeb.manifest:
|
for item in self.oeb.manifest:
|
||||||
if (item.media_type in ('application/vnd.adobe-page-template+xml',
|
if item.media_type in {
|
||||||
'application/vnd.adobe.page-template+xml') and
|
'application/vnd.adobe-page-template+xml', 'application/vnd.adobe.page-template+xml',
|
||||||
hasattr(item.data, 'xpath')):
|
'application/adobe-page-template+xml', 'application/adobe.page-template+xml',
|
||||||
|
} and hasattr(item.data, 'xpath'):
|
||||||
self.log('Removing page margins specified in the'
|
self.log('Removing page margins specified in the'
|
||||||
' Adobe page template')
|
' Adobe page template')
|
||||||
for elem in item.data.xpath(
|
for elem in item.data.xpath(
|
||||||
@ -84,13 +85,12 @@ class RemoveFakeMargins(object):
|
|||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
if ( (hasattr(ti, 'startswith') and ti.startswith('-')) or
|
if ((hasattr(ti, 'startswith') and ti.startswith('-')) or
|
||||||
isinstance(ti, (int, float)) and ti < 0):
|
isinstance(ti, (int, float)) and ti < 0):
|
||||||
raise NegativeTextIndent()
|
raise NegativeTextIndent()
|
||||||
return style.marginLeft, style.marginRight, style
|
return style.marginLeft, style.marginRight, style
|
||||||
return '', '', None
|
return '', '', None
|
||||||
|
|
||||||
|
|
||||||
def process_level(self, level):
|
def process_level(self, level):
|
||||||
elems = self.levels[level]
|
elems = self.levels[level]
|
||||||
self.stats[level+'_left'] = Counter()
|
self.stats[level+'_left'] = Counter()
|
||||||
@ -107,7 +107,6 @@ class RemoveFakeMargins(object):
|
|||||||
remove_left = self.analyze_stats(self.stats[level+'_left'])
|
remove_left = self.analyze_stats(self.stats[level+'_left'])
|
||||||
remove_right = self.analyze_stats(self.stats[level+'_right'])
|
remove_right = self.analyze_stats(self.stats[level+'_right'])
|
||||||
|
|
||||||
|
|
||||||
if remove_left:
|
if remove_left:
|
||||||
mcl = self.stats[level+'_left'].most_common(1)[0][0]
|
mcl = self.stats[level+'_left'].most_common(1)[0][0]
|
||||||
self.log('Removing level %s left margin of:'%level, mcl)
|
self.log('Removing level %s left margin of:'%level, mcl)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user