mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Ignore unparsable CSS in @style attributes.
This commit is contained in:
parent
3c402a26b0
commit
f65418b92f
@ -17,6 +17,7 @@ import types
|
||||
import re
|
||||
import copy
|
||||
from itertools import izip
|
||||
from xml.dom import SyntaxErr as CSSSyntaxError
|
||||
import cssutils
|
||||
from cssutils.css import CSSStyleRule, CSSPageRule, CSSStyleDeclaration, \
|
||||
CSSValueList, cssproperties
|
||||
@ -291,10 +292,14 @@ class Style(object):
|
||||
|
||||
def _apply_style_attr(self):
|
||||
attrib = self._element.attrib
|
||||
if 'style' in attrib:
|
||||
if 'style' not in attrib:
|
||||
return
|
||||
css = attrib['style'].split(';')
|
||||
css = filter(None, map(lambda x: x.strip(), css))
|
||||
css = filter(None, (x.strip() for x in css))
|
||||
try:
|
||||
style = CSSStyleDeclaration('; '.join(css))
|
||||
except CSSSyntaxError:
|
||||
return
|
||||
self._style.update(self._stylizer.flatten_style(style))
|
||||
|
||||
def _has_parent(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user