mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-05-09 10:43:52 +02:00
...
This commit is contained in:
parent
571d80156b
commit
88ade6c371
1 changed files with 7 additions and 4 deletions
|
|
@ -109,6 +109,7 @@ def mlize_spine(self):
|
|||
if item.spine_position is None:
|
||||
stylizer = Stylizer(item.data, item.href, self.oeb_book,
|
||||
self.opts, self.opts.output_profile)
|
||||
self.currently_dumping_item = item
|
||||
output += self.dump_text(item.data.find(XHTML('body')), stylizer)
|
||||
output += '{\\page }'
|
||||
for item in self.oeb_book.spine:
|
||||
|
|
@ -118,6 +119,7 @@ def mlize_spine(self):
|
|||
content = self.remove_tabs(content)
|
||||
content = etree.fromstring(content)
|
||||
stylizer = Stylizer(content, item.href, self.oeb_book, self.opts, self.opts.output_profile)
|
||||
self.currently_dumping_item = item
|
||||
output += self.dump_text(content.find(XHTML('body')), stylizer)
|
||||
output += '{\\page }'
|
||||
output += self.footer()
|
||||
|
|
@ -160,14 +162,14 @@ def insert_images(self, text):
|
|||
|
||||
for item in self.oeb_book.manifest:
|
||||
if item.media_type in OEB_RASTER_IMAGES:
|
||||
src = os.path.basename(item.href)
|
||||
src = item.href
|
||||
try:
|
||||
data, width, height = self.image_to_hexstring(item.data)
|
||||
except:
|
||||
self.log.warn('Image %s is corrupted, ignoring'%item.href)
|
||||
repl = '\n\n'
|
||||
else:
|
||||
repl = '\n\n{\\*\\shppict{\\pict\\picw%i\\pich%i\\jpegblip \n%s\n}}\n\n' % (width, height, data)
|
||||
repl = '\n\n{\\*\\shppict{\\pict\\jpegblip\\picw%i\\pich%i \n%s\n}}\n\n' % (width, height, data)
|
||||
text = text.replace('SPECIAL_IMAGE-%s-REPLACE_ME' % src, repl)
|
||||
return text
|
||||
|
||||
|
|
@ -211,7 +213,8 @@ def clean_text(self, text):
|
|||
return text
|
||||
|
||||
def dump_text(self, elem, stylizer, tag_stack=[]):
|
||||
from calibre.ebooks.oeb.base import XHTML_NS, namespace, barename
|
||||
from calibre.ebooks.oeb.base import (XHTML_NS, namespace, barename,
|
||||
urlnormalize)
|
||||
|
||||
if not isinstance(elem.tag, basestring) \
|
||||
or namespace(elem.tag) != XHTML_NS:
|
||||
|
|
@ -242,7 +245,7 @@ def dump_text(self, elem, stylizer, tag_stack=[]):
|
|||
if tag == 'img':
|
||||
src = elem.get('src')
|
||||
if src:
|
||||
src = os.path.basename(elem.get('src'))
|
||||
src = urlnormalize(self.currently_dumping_item.abshref(src))
|
||||
block_start = ''
|
||||
block_end = ''
|
||||
if 'block' not in tag_stack:
|
||||
|
|
|
|||
Loading…
Reference in a new issue