mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
IGN:Handle <font> tags in html2epub
This commit is contained in:
parent
6b6b18e771
commit
bdd9e1c027
@ -89,6 +89,25 @@ class HTMLProcessor(PreProcessor, LoggingInterface):
|
|||||||
css.append('\n'.join(get_text(style)))
|
css.append('\n'.join(get_text(style)))
|
||||||
style.getparent().remove(style)
|
style.getparent().remove(style)
|
||||||
|
|
||||||
|
font_id = 1
|
||||||
|
for font in self.root.xpath('//font'):
|
||||||
|
try:
|
||||||
|
size = int(font.attrib.pop('size', '3'))
|
||||||
|
except:
|
||||||
|
size = 3
|
||||||
|
setting = 'font-size: %d%%;'%int((float(size)/3) * 100)
|
||||||
|
face = font.attrib.pop('face', None)
|
||||||
|
if face is not None:
|
||||||
|
setting += 'font-face:%s;'%face
|
||||||
|
color = font.attrib.pop('color', None)
|
||||||
|
if color is not None:
|
||||||
|
setting += 'color:%s'%color
|
||||||
|
id = 'calibre_font_id_%d'%font_id
|
||||||
|
font['id'] = 'calibre_font_id_%d'%font_id
|
||||||
|
font_id += 1
|
||||||
|
css.append('#%s { %s }'%(id, setting))
|
||||||
|
|
||||||
|
|
||||||
css_counter = 1
|
css_counter = 1
|
||||||
for elem in self.root.xpath('//*[@style]'):
|
for elem in self.root.xpath('//*[@style]'):
|
||||||
if 'id' not in elem.keys():
|
if 'id' not in elem.keys():
|
||||||
|
Loading…
x
Reference in New Issue
Block a user