def add_anchors(root):
counter = 1
for element in root.iterdescendants():
- if any_ancestor(element, lambda e: e.get('class') in ('note', 'motto', 'motto_podpis', 'dedication')
+ if any_ancestor(element, lambda e: e.get('class') in ('note', 'motto', 'motto_podpis', 'dedication', 'frame')
or e.get('id') == 'nota_red'
or e.tag == 'blockquote'):
continue
for i, fragment in enumerate(fragments):
item = etree.SubElement(themes_li, 'a', href="#%s" % fragment)
item.text = str(i + 1)
+ item.tail = ' '
root.insert(0, themes_div)