mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-05-08 16:03:36 +02:00
Use <b> and <i> instead of <span> where possible
This commit is contained in:
parent
9961ada770
commit
b8be1a27b2
1 changed files with 11 additions and 0 deletions
|
|
@ -84,3 +84,14 @@ def cleanup_markup(root, styles):
|
|||
for child in span:
|
||||
parent.append(child)
|
||||
|
||||
# Make spans whose only styling is bold or italic into <b> and <i> tags
|
||||
for span in root.xpath('//span[@class]'):
|
||||
css = class_map.get(span.get('class', None), {})
|
||||
if len(css) == 1:
|
||||
if css == {'font-style':'italic'}:
|
||||
span.tag = 'i'
|
||||
del span.attrib['class']
|
||||
elif css == {'font-weight':'bold'}:
|
||||
span.tag = 'b'
|
||||
del span.attrib['class']
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue