X-Git-Url: https://git.mdrn.pl/librarian.git/blobdiff_plain/86becb1ae4d215dd782dfc054471d724f6dcd1d7..af72c4ed58e541d491dafbfe4ecb163662f402b5:/src/librarian/builders/html.py diff --git a/src/librarian/builders/html.py b/src/librarian/builders/html.py index ed222d3..7504a66 100644 --- a/src/librarian/builders/html.py +++ b/src/librarian/builders/html.py @@ -24,7 +24,7 @@ class HtmlBuilder: self._base_url = base_url self.tree = text = etree.Element('div', **{'id': 'book-text'}) - self.header = etree.SubElement(text, 'h1') + self.header = etree.Element('h1') self.footnotes = etree.Element('div', id='footnotes') self.footnote_counter = 0 @@ -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() @@ -109,6 +110,9 @@ class HtmlBuilder: if self.with_toc: add_table_of_contents(self.tree) + if len(self.header): + self.tree.insert(0, self.header) + if self.footnote_counter: fnheader = etree.Element("h3") fnheader.text = _("Footnotes") @@ -183,6 +187,15 @@ class StandaloneHtmlBuilder(HtmlBuilder): ) +class SnippetHtmlBuilder(HtmlBuilder): + with_anchors = False + with_themes = False + with_toc = False + with_footnotes = False + with_nota_red = False + with_refs = False + + class DaisyHtmlBuilder(StandaloneHtmlBuilder): file_extension = 'xhtml' with_anchors = False