mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix #1526 (Error on EPUB conversion from deDRMed Mobipocket file)
This commit is contained in:
parent
4f8315a5bb
commit
c9177f4658
@ -788,7 +788,10 @@ class Processor(Parser):
|
|||||||
size = '3'
|
size = '3'
|
||||||
if size and size.strip() and size.strip()[0] in ('+', '-'):
|
if size and size.strip() and size.strip()[0] in ('+', '-'):
|
||||||
size = 3 + float(size) # Hack assumes basefont=3
|
size = 3 + float(size) # Hack assumes basefont=3
|
||||||
setting = 'font-size: %d%%;'%int((float(size)/3) * 100)
|
try:
|
||||||
|
setting = 'font-size: %d%%;'%int((float(size)/3) * 100)
|
||||||
|
except ValueError:
|
||||||
|
setting = ''
|
||||||
face = font.attrib.pop('face', None)
|
face = font.attrib.pop('face', None)
|
||||||
if face is not None:
|
if face is not None:
|
||||||
setting += 'font-face:%s;'%face
|
setting += 'font-face:%s;'%face
|
||||||
|
@ -234,6 +234,15 @@ class MobiReader(object):
|
|||||||
def cleanup_soup(self, soup):
|
def cleanup_soup(self, soup):
|
||||||
if self.verbose:
|
if self.verbose:
|
||||||
print 'Replacing height, width and align attributes'
|
print 'Replacing height, width and align attributes'
|
||||||
|
size_map = {
|
||||||
|
'xx-small' : '0.5',
|
||||||
|
'x-small' : '1',
|
||||||
|
'small' : '2',
|
||||||
|
'medium' : '3',
|
||||||
|
'large' : '4',
|
||||||
|
'x-large' : '5',
|
||||||
|
'xx-large' : '6',
|
||||||
|
}
|
||||||
for tag in soup.recursiveChildGenerator():
|
for tag in soup.recursiveChildGenerator():
|
||||||
if not isinstance(tag, Tag): continue
|
if not isinstance(tag, Tag): continue
|
||||||
styles = []
|
styles = []
|
||||||
@ -258,6 +267,15 @@ class MobiReader(object):
|
|||||||
pass
|
pass
|
||||||
if styles:
|
if styles:
|
||||||
tag['style'] = '; '.join(styles)
|
tag['style'] = '; '.join(styles)
|
||||||
|
|
||||||
|
if tag.name.lower() == 'font':
|
||||||
|
sz = tag.get('size', '')
|
||||||
|
try:
|
||||||
|
float(sz)
|
||||||
|
except ValueError:
|
||||||
|
sz = sz.lower()
|
||||||
|
if sz in size_map.keys():
|
||||||
|
tag['size'] = size_map[sz]
|
||||||
|
|
||||||
def create_opf(self, htmlfile, guide=None):
|
def create_opf(self, htmlfile, guide=None):
|
||||||
mi = self.book_header.exth.mi
|
mi = self.book_header.exth.mi
|
||||||
|
Loading…
x
Reference in New Issue
Block a user