mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
Fix bug with SVG rasterizer. Remove some unneeded voodoo.
This commit is contained in:
parent
8cd38455f2
commit
16dba58dca
@ -731,9 +731,7 @@ def oeb2lit(opts, inpath):
|
||||
mangler = CaseMangler()
|
||||
mangler.transform(oeb, context)
|
||||
fbase = context.dest.fbase
|
||||
fkey = context.dest.fnames.values()
|
||||
flattener = CSSFlattener(
|
||||
fbase=fbase, fkey=fkey, unfloat=True, untable=True)
|
||||
flattener = CSSFlattener(fbase=fbase, unfloat=True, untable=True)
|
||||
flattener.transform(oeb, context)
|
||||
rasterizer = SVGRasterizer()
|
||||
rasterizer.transform(oeb, context)
|
||||
|
@ -66,8 +66,7 @@ class HTMLTOCAdder(object):
|
||||
element(head, XHTML('link'), rel='stylesheet', type=CSS_MIME,
|
||||
href=css_href)
|
||||
body = element(contents, XHTML('body'),
|
||||
attrib={'id': 'calibre_toc',
|
||||
'class': 'calibre_toc'})
|
||||
attrib={'class': 'calibre_toc'})
|
||||
h1 = element(body, XHTML('h1'),
|
||||
attrib={'class': 'calibre_toc_header'})
|
||||
h1.text = 'Table of Contents'
|
||||
@ -75,7 +74,7 @@ class HTMLTOCAdder(object):
|
||||
id, href = oeb.manifest.generate('contents', 'contents.xhtml')
|
||||
item = oeb.manifest.add(id, href, XHTML_MIME, data=contents)
|
||||
oeb.spine.add(item, linear=False)
|
||||
oeb.guide.add('toc', 'Table of Contents', href + '#calibre_toc')
|
||||
oeb.guide.add('toc', 'Table of Contents', href)
|
||||
|
||||
def add_toc_level(self, elem, toc):
|
||||
for node in toc:
|
||||
|
@ -26,6 +26,7 @@ from calibre.ebooks.oeb.base import xml2str, xpath, namespace, barename
|
||||
from calibre.ebooks.oeb.stylizer import Stylizer
|
||||
|
||||
IMAGE_TAGS = set([XHTML('img'), XHTML('object')])
|
||||
KEEP_ATTRS = set(['class', 'style', 'width', 'height', 'align'])
|
||||
|
||||
class SVGRasterizer(object):
|
||||
def __init__(self):
|
||||
@ -172,12 +173,15 @@ class SVGRasterizer(object):
|
||||
self.images[key] = href
|
||||
elem.tag = XHTML('img')
|
||||
for attr in elem.attrib:
|
||||
del elem.attrib[attr]
|
||||
if attr not in KEEP_ATTRS:
|
||||
del elem.attrib[attr]
|
||||
elem.attrib['src'] = item.relhref(href)
|
||||
elem.text = None
|
||||
if elem.text:
|
||||
elem.attrib['alt'] = elem.text
|
||||
elem.text = None
|
||||
for child in elem:
|
||||
elem.remove(child)
|
||||
|
||||
|
||||
def rasterize_cover(self):
|
||||
covers = self.oeb.metadata.cover
|
||||
if not covers:
|
||||
|
Loading…
x
Reference in New Issue
Block a user