mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
This commit is contained in:
commit
15de9783e6
@ -12,7 +12,7 @@ import copy
|
|||||||
import re
|
import re
|
||||||
from lxml import etree
|
from lxml import etree
|
||||||
from calibre.ebooks.oeb.base import namespace, barename
|
from calibre.ebooks.oeb.base import namespace, barename
|
||||||
from calibre.ebooks.oeb.base import XHTML, XHTML_NS
|
from calibre.ebooks.oeb.base import XHTML, XHTML_NS, OEB_DOCS
|
||||||
from calibre.ebooks.oeb.stylizer import Stylizer
|
from calibre.ebooks.oeb.stylizer import Stylizer
|
||||||
from calibre.ebooks.oeb.transforms.flatcss import KeyMapper
|
from calibre.ebooks.oeb.transforms.flatcss import KeyMapper
|
||||||
|
|
||||||
@ -96,8 +96,11 @@ class MobiMLizer(object):
|
|||||||
href = oeb.guide['cover'].href
|
href = oeb.guide['cover'].href
|
||||||
del oeb.guide['cover']
|
del oeb.guide['cover']
|
||||||
item = oeb.manifest.hrefs[href]
|
item = oeb.manifest.hrefs[href]
|
||||||
oeb.manifest.remove(item)
|
if item.spine_position is not None:
|
||||||
|
oeb.spine.remove(item)
|
||||||
|
if item.media_type in OEB_DOCS:
|
||||||
|
self.oeb.manifest.remove(item)
|
||||||
|
|
||||||
def mobimlize_spine(self):
|
def mobimlize_spine(self):
|
||||||
for item in self.oeb.spine:
|
for item in self.oeb.spine:
|
||||||
stylizer = Stylizer(item.data, item.href, self.oeb, self.profile)
|
stylizer = Stylizer(item.data, item.href, self.oeb, self.profile)
|
||||||
|
@ -180,7 +180,6 @@ class Serializer(object):
|
|||||||
if not isinstance(elem.tag, basestring) \
|
if not isinstance(elem.tag, basestring) \
|
||||||
or namespace(elem.tag) not in nsrmap:
|
or namespace(elem.tag) not in nsrmap:
|
||||||
return
|
return
|
||||||
hrefs = self.oeb.manifest.hrefs
|
|
||||||
tag = prefixname(elem.tag, nsrmap)
|
tag = prefixname(elem.tag, nsrmap)
|
||||||
for attr in ('name', 'id'):
|
for attr in ('name', 'id'):
|
||||||
if attr in elem.attrib:
|
if attr in elem.attrib:
|
||||||
@ -203,7 +202,7 @@ class Serializer(object):
|
|||||||
continue
|
continue
|
||||||
elif attr == 'src':
|
elif attr == 'src':
|
||||||
href = item.abshref(val)
|
href = item.abshref(val)
|
||||||
if href in hrefs:
|
if href in self.images:
|
||||||
index = self.images[href]
|
index = self.images[href]
|
||||||
buffer.write('recindex="%05d"' % index)
|
buffer.write('recindex="%05d"' % index)
|
||||||
continue
|
continue
|
||||||
|
@ -506,6 +506,7 @@ class Spine(object):
|
|||||||
self.items.pop(index)
|
self.items.pop(index)
|
||||||
for i in xrange(index, len(self.items)):
|
for i in xrange(index, len(self.items)):
|
||||||
self.items[i].spine_position = i
|
self.items[i].spine_position = i
|
||||||
|
item.spine_position = None
|
||||||
|
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
for item in self.items:
|
for item in self.items:
|
||||||
|
@ -41,8 +41,9 @@ class ManifestTrimmer(object):
|
|||||||
while unchecked:
|
while unchecked:
|
||||||
new = set()
|
new = set()
|
||||||
for item in unchecked:
|
for item in unchecked:
|
||||||
if item.media_type in OEB_DOCS or \
|
if (item.media_type in OEB_DOCS or
|
||||||
item.media_type[-4:] in ('/xml', '+xml'):
|
item.media_type[-4:] in ('/xml', '+xml')) and \
|
||||||
|
item.data is not None:
|
||||||
hrefs = [sel(item.data) for sel in LINK_SELECTORS]
|
hrefs = [sel(item.data) for sel in LINK_SELECTORS]
|
||||||
for href in chain(*hrefs):
|
for href in chain(*hrefs):
|
||||||
href = item.abshref(href)
|
href = item.abshref(href)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user