def enhance_tables(content): if not isinstance(content, contents.Article): return with modify_html(content) as html_tree: for table in html_tree.findall('.//table'): div = etree.Element('div') div.set('class', 'table') wrap_element(table, div)
def tweet_to_figure(blockquote): if 'twitter-tweet' not in blockquote.classes: return wrap_element(blockquote, etree.Element('figure'))
def object_to_figure(object_): wrap_element(object_, etree.Element('figure'))
def iframe_to_figure(iframe): wrap_element(iframe, etree.Element('figure'))