def get_elements(leave): result = {} for name, value in get_dict(source=elements, leave=leave).iteritems(): remove = remove_attributes_for_all + remove_attributes_for_element.get(name, []) replace = {} replace.update(replace_attributes_for_all) replace.update(replace_attributes_for_element.get(name, {})) rules = get_dict(attributes[name], remove=remove, append=replace) element = Element(rules=rules, empty_element=value.empty_element, default=value.default, optional_start=value.optional_start, optional_end=value.optional_end, contents=value.contents, save_content=value.save_content) result[name] = element for name in remove_elements_with_content: element = Element(remove_element=True, save_content=False) result[name] = element return result
] allowed = [ # If we need float for image, we need it too: 'clear', # We need it, but we must disable: 'blink' 'text-decoration', ] text_decoration_base = List(values=[ 'underline', 'overline', 'line-through', # Disable: 'blink', ]) text_decoration = Or(rules=[ Sequence(rule=text_decoration_base, min_split=1), none, inherit, ]) replace = { 'text-decoration': text_decoration, } common = get_dict(source=values, leave=allowed, append=replace) tables = get_dict(source=values, leave=allowed + for_table, append=replace) images = get_dict(source=values, leave=allowed + for_image, append=replace) #style_div = Style(rules={ # 'display': List(values=[ # 'none'], invalid=True, element_exception=True), #})