MOBI Input: Handle MOBI files with empty <u> tags correctly. Fixes #774785 (Private bug)

This commit is contained in:
Kovid Goyal 2011-05-01 10:46:42 -06:00
parent 186a47da8c
commit 9a32f09a71
2 changed files with 7 additions and 2 deletions

View File

@ -253,6 +253,8 @@ class MobiReader(object):
.italic { font-style: italic }
.underline { text-decoration: underline }
.mbp_pagebreak {
page-break-after: always; margin: 0; display: block
}
@ -601,6 +603,9 @@ class MobiReader(object):
elif tag.tag == 'i':
tag.tag = 'span'
tag.attrib['class'] = 'italic'
elif tag.tag == 'u':
tag.tag = 'span'
tag.attrib['class'] = 'underline'
elif tag.tag == 'b':
tag.tag = 'span'
tag.attrib['class'] = 'bold'

View File

@ -1049,8 +1049,8 @@ class Manifest(object):
# Remove hyperlinks with no content as they cause rendering
# artifacts in browser based renderers
# Also remove empty <b> and <i> tags
for a in xpath(data, '//h:a[@href]|//h:i|//h:b'):
# Also remove empty <b>, <u> and <i> tags
for a in xpath(data, '//h:a[@href]|//h:i|//h:b|//h:u'):
if a.get('id', None) is None and a.get('name', None) is None \
and len(a) == 0 and not a.text:
remove_elem(a)