return self.current_cursors[-1]
def enter_fragment(self, fragment):
- self.current_cursors.append(self.cursors[fragment])
+ cursor = self.cursors.get(fragment, self.cursor)
+ self.current_cursors.append(cursor)
def exit_fragment(self):
self.current_cursors.pop()
def _compat_assigns_section_ids_in_elem(elem, prefix='sec'):
for i, child in enumerate(elem):
idfier = '{}{}'.format(prefix, i + 1)
- child.attrib['_compat_section_id'] = idfier
+ try:
+ child.attrib['_compat_section_id'] = idfier
+ except:
+ pass
_compat_assigns_section_ids_in_elem(child, idfier + '-')
_compat_assigns_section_ids_in_elem(self.tree.getroot().master)
# do we dare go up?
parent = self.getparent()
if parent is not None and parent.CAN_HAVE_TEXT:
- print(etree.tostring(self, encoding='unicode'))
- assert False
words, parsnip = parent.snip(words, before=self)
return words, parsnip[:-1] + snippet + parsnip[-1:]