+
+
+class StandaloneHtmlBuilder(HtmlBuilder):
+ css_url = "https://static.wolnelektury.pl/css/compressed/book_text.css"
+
+ def postprocess(self, document):
+ super(StandaloneHtmlBuilder, self).postprocess(document)
+
+ tree = etree.Element('html')
+ body = etree.SubElement(tree, 'body')
+ body.append(self.tree)
+ self.tree = tree
+
+ head = etree.Element('head')
+ tree.insert(0, head)
+
+
+ etree.SubElement(head, 'meta', charset='utf-8')
+ etree.SubElement(head, 'title').text = document.meta.title
+
+ etree.SubElement(
+ head,
+ 'meta',
+ name="viewport",
+ content="width=device-width, initial-scale=1, maximum-scale=1"
+ )
+
+ if self.no_externalities:
+ etree.SubElement(
+ head, 'style',
+ ).text = urlopen(self.css_url).read().decode('utf-8')
+ else:
+ etree.SubElement(
+ head,
+ 'link',
+ href=self.css_url,
+ rel="stylesheet",
+ type="text/css",
+ )
+
+ etree.SubElement(
+ body, 'script',
+ src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"
+ )
+
+ etree.SubElement(
+ body,
+ "script",
+ src="http://malsup.github.io/min/jquery.cycle2.min.js"
+ )
+
+
+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
+ with_themes = False
+ with_toc = False
+ with_footnotes = False
+ with_nota_red = False
+ with_deep_identifiers = False
+ no_externalities = True
+
+ def output(self):
+ tree = etree.ElementTree(self.tree)
+ tree.docinfo.public_id = '-//W3C//DTD XHTML 1.0 Transitional//EN'
+ tree.docinfo.system_url = 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'
+ return OutputFile.from_bytes(
+ etree.tostring(
+ tree,
+ encoding='utf-8',
+ pretty_print=True,
+ xml_declaration=True
+ )
+ )
+