if element.tag == 'h3' and len(sections) and sections[-1][1] == 'h2':
sections[-1][3].append((counter, element.tag, ''.join(element.xpath('text()')), []))
else:
sections.append((counter, element.tag, ''.join(element.xpath('text()')), []))
add_anchor(element, "s%d" % counter, with_link=False)
counter += 1
if element.tag == 'h3' and len(sections) and sections[-1][1] == 'h2':
sections[-1][3].append((counter, element.tag, ''.join(element.xpath('text()')), []))
else:
sections.append((counter, element.tag, ''.join(element.xpath('text()')), []))
add_anchor(element, "s%d" % counter, with_link=False)
counter += 1