+ def _epub_build_inner(self, builder):
+ self._build_inner(builder, 'epub_build')
+
+ def get_epub_attr(self, builder):
+ attr = self.EPUB_ATTR.copy()
+ if self.EPUB_CLASS:
+ attr['class'] = self.EPUB_CLASS
+ return attr
+
+ def epub_build(self, builder):
+ from librarian.elements.masters import Master
+
+ # TEMPORARY
+ self.CAN_HAVE_TEXT = True
+ self.STRIP = False
+
+ start_chunk = self.EPUB_START_CHUNK and isinstance(self.getparent(), Master)
+
+ if start_chunk:
+ builder.start_chunk()
+
+ fragment = None
+ if self.SECTION_PRECEDENCE and not self.in_context_of('NO_TOC'):
+ if not start_chunk:
+ fragment = 'sub%d' % builder.assign_section_number()
+ self.attrib['id'] = fragment
+
+ builder.add_toc_entry(
+ fragment,
+ self.raw_printable_text(builder),
+ self.SECTION_PRECEDENCE
+ )
+
+ if self.EPUB_TAG:
+ attr = self.get_epub_attr(builder)
+ if fragment:
+ attr['id'] = fragment
+ builder.start_element(
+ self.EPUB_TAG,
+ attr
+ )
+
+ self._epub_build_inner(builder)
+ if self.EPUB_TAG:
+ builder.end_element()
+
+ def validate(self):
+ from librarian.elements.masters import Master
+ from librarian.elements.blocks import DlugiCytat, PoezjaCyt
+ from librarian.elements.footnotes import Footnote
+
+ if self.SECTION_PRECEDENCE:
+ assert isinstance(self.getparent(), (Master, DlugiCytat, PoezjaCyt, Footnote)), \
+ 'Header {} inside a <{}> instead of a master.'.format(
+ etree.tostring(self), self.getparent().tag)
+
+ for c in self:
+ if isinstance(c, WLElement):
+ c.validate()
+
+