def _process_element(self, element: ContentElement): """Filter ISD element style properties""" element_styles = list(element.iter_styles()) for style_prop in element_styles: if style_prop in self.supported_style_properties.keys(): value = element.get_style(style_prop) supported_values = self.supported_style_properties[style_prop] if len(supported_values) == 0 or value in supported_values: continue element.set_style(style_prop, None) for child in element: self._process_element(child)
def _process_element(self, element: ContentElement): """Filter ISD element style properties""" element_styles = list(element.iter_styles()) for style_prop in element_styles: value = element.get_style(style_prop) default_value = self.style_property_default_values.get(style_prop) parent = element.parent() if parent is not None and style_prop.is_inherited: # If the parent style property value has not been removed, it means # the value is not set to default, and so that the child style property # value may have been "forced" to the default value, so let's skip it. parent_value = parent.get_style(style_prop) if parent_value is not None and parent_value is not value: continue # Remove the style property if its value is default (and if it is not inherited) if default_value is not None and value == default_value: element.set_style(style_prop, None) for child in element: self._process_element(child)