mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
...
This commit is contained in:
parent
571d80156b
commit
88ade6c371
@ -109,6 +109,7 @@ class RTFMLizer(object):
|
|||||||
if item.spine_position is None:
|
if item.spine_position is None:
|
||||||
stylizer = Stylizer(item.data, item.href, self.oeb_book,
|
stylizer = Stylizer(item.data, item.href, self.oeb_book,
|
||||||
self.opts, self.opts.output_profile)
|
self.opts, self.opts.output_profile)
|
||||||
|
self.currently_dumping_item = item
|
||||||
output += self.dump_text(item.data.find(XHTML('body')), stylizer)
|
output += self.dump_text(item.data.find(XHTML('body')), stylizer)
|
||||||
output += '{\\page }'
|
output += '{\\page }'
|
||||||
for item in self.oeb_book.spine:
|
for item in self.oeb_book.spine:
|
||||||
@ -118,6 +119,7 @@ class RTFMLizer(object):
|
|||||||
content = self.remove_tabs(content)
|
content = self.remove_tabs(content)
|
||||||
content = etree.fromstring(content)
|
content = etree.fromstring(content)
|
||||||
stylizer = Stylizer(content, item.href, self.oeb_book, self.opts, self.opts.output_profile)
|
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 += self.dump_text(content.find(XHTML('body')), stylizer)
|
||||||
output += '{\\page }'
|
output += '{\\page }'
|
||||||
output += self.footer()
|
output += self.footer()
|
||||||
@ -160,14 +162,14 @@ class RTFMLizer(object):
|
|||||||
|
|
||||||
for item in self.oeb_book.manifest:
|
for item in self.oeb_book.manifest:
|
||||||
if item.media_type in OEB_RASTER_IMAGES:
|
if item.media_type in OEB_RASTER_IMAGES:
|
||||||
src = os.path.basename(item.href)
|
src = item.href
|
||||||
try:
|
try:
|
||||||
data, width, height = self.image_to_hexstring(item.data)
|
data, width, height = self.image_to_hexstring(item.data)
|
||||||
except:
|
except:
|
||||||
self.log.warn('Image %s is corrupted, ignoring'%item.href)
|
self.log.warn('Image %s is corrupted, ignoring'%item.href)
|
||||||
repl = '\n\n'
|
repl = '\n\n'
|
||||||
else:
|
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)
|
text = text.replace('SPECIAL_IMAGE-%s-REPLACE_ME' % src, repl)
|
||||||
return text
|
return text
|
||||||
|
|
||||||
@ -211,7 +213,8 @@ class RTFMLizer(object):
|
|||||||
return text
|
return text
|
||||||
|
|
||||||
def dump_text(self, elem, stylizer, tag_stack=[]):
|
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) \
|
if not isinstance(elem.tag, basestring) \
|
||||||
or namespace(elem.tag) != XHTML_NS:
|
or namespace(elem.tag) != XHTML_NS:
|
||||||
@ -242,7 +245,7 @@ class RTFMLizer(object):
|
|||||||
if tag == 'img':
|
if tag == 'img':
|
||||||
src = elem.get('src')
|
src = elem.get('src')
|
||||||
if src:
|
if src:
|
||||||
src = os.path.basename(elem.get('src'))
|
src = urlnormalize(self.currently_dumping_item.abshref(src))
|
||||||
block_start = ''
|
block_start = ''
|
||||||
block_end = ''
|
block_end = ''
|
||||||
if 'block' not in tag_stack:
|
if 'block' not in tag_stack:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user