A fuller fix for #1681.

This commit is contained in:
Marshall T. Vandegrift 2009-01-25 14:45:21 -05:00
parent 16c495cd95
commit 9f5078add1
2 changed files with 8 additions and 6 deletions

View File

@ -165,8 +165,11 @@ class HTMLProcessor(Processor, Rationalizer):
br.tag = 'p' br.tag = 'p'
br.text = u'\u00a0' br.text = u'\u00a0'
if (br.tail and br.tail.strip()) or sibling is None or \ if (br.tail and br.tail.strip()) or sibling is None or \
getattr(sibling, 'tag', '') != 'br': getattr(sibling, 'tag', '') != 'br':
br.set('style', br.get('style', '')+'; margin: 0pt; border:0pt; height:0pt') style = br.get('style', '').split(';')
style = filter(None, map(lambda x: x.strip(), style))
style.append('margin: 0pt; border:0pt; height:0pt')
br.set('style', '; '.join(style))
else: else:
sibling.getparent().remove(sibling) sibling.getparent().remove(sibling)
if sibling.tail: if sibling.tail:

View File

@ -277,10 +277,9 @@ class Style(object):
def _apply_style_attr(self): def _apply_style_attr(self):
attrib = self._element.attrib attrib = self._element.attrib
if 'style' in attrib: if 'style' in attrib:
css = attrib['style'].strip() css = attrib['style'].split(';')
if css.startswith(';'): css = filter(None, map(lambda x: x.strip(), css))
css = css[1:] style = CSSStyleDeclaration('; '.join(css))
style = CSSStyleDeclaration(css)
self._style.update(self._stylizer.flatten_style(style)) self._style.update(self._stylizer.flatten_style(style))
def _has_parent(self): def _has_parent(self):