X-Git-Url: https://git.mdrn.pl/librarian.git/blobdiff_plain/1e1abb45277301597bcbb54d17675330bedd7fc5..deca3e31b94bc7ec95d47c309ff560a097337e97:/src/librarian/builders/html.py diff --git a/src/librarian/builders/html.py b/src/librarian/builders/html.py index 165a265..ee50cb8 100644 --- a/src/librarian/builders/html.py +++ b/src/librarian/builders/html.py @@ -36,18 +36,14 @@ class HtmlBuilder: 'footnotes': self.footnotes, 'nota_red': self.nota_red, } - self.current_cursors = [None] + self.current_cursors = [text] @property def cursor(self): - return self.cursors[self.current_cursors[-1]] - - @cursor.setter - def cursor(self, value): - self.cursors[self.current_cursors[-1]] = value + return self.current_cursors[-1] def enter_fragment(self, fragment): - self.current_cursors.append(fragment) + self.current_cursors.append(self.cursors[fragment]) def exit_fragment(self): self.current_cursors.pop() @@ -63,7 +59,7 @@ class HtmlBuilder: document._compat_assign_ordered_ids() document._compat_assign_section_ids() - def build(self, document): + def build(self, document, **kwargs): self.preprocess(document) document.tree.getroot().html_build(self) self.postprocess(document) @@ -110,19 +106,16 @@ class HtmlBuilder: self.tree.append(self.footnotes) def start_element(self, tag, attrib=None): - self.cursor = etree.SubElement( + self.current_cursors.append(etree.SubElement( self.cursor, tag, **(attrib or {}) - ) + )) def end_element(self): - self.cursor = self.cursor.getparent() + self.current_cursors.pop() def push_text(self, text): - if text == 'Między nami nic nie było': - print(self.cursors) - print(self.current_cursors) cursor = self.cursor if len(cursor): cursor[-1].tail = (cursor[-1].tail or '') + text