diff --git a/delta/html.py b/delta/html.py index d34fed8..7dd0582 100644 --- a/delta/html.py +++ b/delta/html.py @@ -37,9 +37,13 @@ def styled(element, styles): if element.tag != 'span': element = sub_element(element, 'span') declare = parseStyle(element.attrib.get('style', '')) - for k, v in styles.items(): - declare.setProperty(k, v) - element.attrib['style'] = declare.getCssText(' ') + try: + for k, v in styles.items(): + declare.setProperty(k, v) + element.attrib['style'] = declare.getCssText(' ') + except: + # Ignore invalid css attributes + pass return element def classed(element, *classes): diff --git a/tests/test_html.py b/tests/test_html.py index 614d05c..e1a69af 100644 --- a/tests/test_html.py +++ b/tests/test_html.py @@ -59,6 +59,21 @@ def test_colors(): source = '

quill

' assert html.render(ops) == source +def test_unsupported_style_attribute(): + ops = [ + {"insert": "quill", "attributes": {"color": "var(--some-color)", "background": "#000000"}} + ] + + source = '

quill

' + assert html.render(ops) == source + + ops = [ + {"insert": "quill", "attributes": {"background": "#000000", "color": "#FFFFFF"}} + ] + + source = '

quill

' + assert html.render(ops) == source + def test_classes(): ops = [ {"insert":"Quill", "attributes": {"font": "monospace", "size": "huge"}}