X-Git-Url: https://git.mdrn.pl/librarian.git/blobdiff_plain/e870e40d5fb975ba9ec0ec327014b3d16eea51e4..295a1350b069ee750d2f7430e779e5ac6f23a673:/src/librarian/builders/html.py diff --git a/src/librarian/builders/html.py b/src/librarian/builders/html.py index ee50cb8..18a5b36 100644 --- a/src/librarian/builders/html.py +++ b/src/librarian/builders/html.py @@ -18,12 +18,13 @@ class HtmlBuilder: with_footnotes = True with_nota_red = True no_externalities = False + orphans = True - def __init__(self, image_location='https://wolnelektury.pl/media/book/pictures/marcos-historia-kolorow/'): - self.image_location = image_location + def __init__(self, base_url=None): + 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 @@ -38,6 +39,13 @@ class HtmlBuilder: } self.current_cursors = [text] + @property + def base_url(self): + if self._base_url is not None: + return self._base_url + else: + return 'https://wolnelektury.pl/media/book/pictures/{}/'.format(self.document.meta.url.slug) + @property def cursor(self): return self.current_cursors[-1] @@ -60,6 +68,8 @@ class HtmlBuilder: document._compat_assign_section_ids() def build(self, document, **kwargs): + self.document = document + self.preprocess(document) document.tree.getroot().html_build(self) self.postprocess(document) @@ -99,6 +109,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") @@ -173,6 +186,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