From: Radek Czajka Date: Fri, 16 Jun 2023 08:01:18 +0000 (+0200) Subject: fixes for edge cases X-Git-Tag: 2.5.1~1 X-Git-Url: https://git.mdrn.pl/librarian.git/commitdiff_plain/bd97f61d25eb0c3e51a29286c7de509146eceb37?ds=sidebyside;hp=295a1350b069ee750d2f7430e779e5ac6f23a673 fixes for edge cases --- diff --git a/src/librarian/builders/html.py b/src/librarian/builders/html.py index 18a5b36..7504a66 100644 --- a/src/librarian/builders/html.py +++ b/src/librarian/builders/html.py @@ -51,7 +51,8 @@ class HtmlBuilder: 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() diff --git a/src/librarian/document.py b/src/librarian/document.py index d4063c5..6cdf191 100644 --- a/src/librarian/document.py +++ b/src/librarian/document.py @@ -101,7 +101,10 @@ class WLDocument: 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) diff --git a/src/librarian/elements/base.py b/src/librarian/elements/base.py index 646067e..8e83311 100644 --- a/src/librarian/elements/base.py +++ b/src/librarian/elements/base.py @@ -278,8 +278,6 @@ class WLElement(etree.ElementBase): # 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:]