X-Git-Url: https://git.mdrn.pl/librarian.git/blobdiff_plain/3a0c83394d5783715fab2be29fa1a9cfc3574e28..ddeba8a8483dc73d0103030afe46fc5bce51d8a0:/src/librarian/elements/tools/__init__.py?ds=sidebyside diff --git a/src/librarian/elements/tools/__init__.py b/src/librarian/elements/tools/__init__.py index 99f81d9..69a26ea 100644 --- a/src/librarian/elements/tools/__init__.py +++ b/src/librarian/elements/tools/__init__.py @@ -5,11 +5,13 @@ from ..base import WLElement class Numeracja(WLElement): - pass + NUMBERING = True + def assign_id(self, builder): + builder.counters['_visible'] = int(self.get('start', 1)) class Rownolegle(WLElement): - def build_epub(self, builder): + def epub_build(self, builder): for i, block in enumerate(self): attr = {"class": "rownolegly-blok"} if not i: @@ -17,16 +19,49 @@ class Rownolegle(WLElement): if i == len(self) - 1: attr['class'] += ' last' builder.start_element('div', attr) - self.build_epub(block, builder) + block.epub_build(builder) + builder.end_element() + + def html_build(self, builder): + for i, block in enumerate(self): + attr = {"class": "paralell-block"} + if not i: + attr['class'] += ' paralell-block-first' + if i == len(self) - 1: + attr['class'] += ' paralell-block-last' + builder.start_element('div', attr) + block.html_build(builder) builder.end_element() + class Tab(WLElement): EPUB_TAG = HTML_TAG = 'span' + def html_build(self, builder): + szer = self.get('szer', '1') + if szer == '*': + reopen = [] + from lxml import etree + p = builder.cursor + while 'verse' not in p.attrib.get('class', ''): + reopen.append(p) + p = p.getparent() + builder.end_element() + builder.start_element('span', {'class': 'verse-stretched-space'}) + builder.end_element() + while reopen: + p = reopen.pop() + builder.start_element(p.tag, p.attrib) + else: + super().html_build(builder) + def get_html_attr(self, builder): + szer = self.get('szer', '1').strip() + if szer.endswith('em'): + szer = szer[:-2] try: - szer = int(self.get('szer', 1)) + szer = int(szer) except: szer = 1 return { @@ -36,3 +71,12 @@ class Tab(WLElement): get_epub_attr = get_html_attr + def txt_build(self, builder): + szer = self.get('szer', '1').strip() + if szer.endswith('em'): + szer = szer[:-2] + try: + szer = int(szer) + except: + szer = 1 + builder.push_text(' ' * 4 * szer)