1 # This file is part of Librarian, licensed under GNU Affero GPLv3 or later.
2 # Copyright © Fundacja Wolne Lektury. See NOTICE for more information.
4 from ..base import WLElement
7 class Numeracja(WLElement):
9 def assign_id(self, builder):
10 builder.counters['_visible'] = int(self.get('start', 1))
13 class Rownolegle(WLElement):
14 def epub_build(self, builder):
15 for i, block in enumerate(self):
16 attr = {"class": "rownolegly-blok"}
18 attr['class'] += ' first'
19 if i == len(self) - 1:
20 attr['class'] += ' last'
21 builder.start_element('div', attr)
22 block.epub_build(builder)
25 def html_build(self, builder):
26 for i, block in enumerate(self):
27 attr = {"class": "paralell-block"}
29 attr['class'] += ' paralell-block-first'
30 if i == len(self) - 1:
31 attr['class'] += ' paralell-block-last'
32 builder.start_element('div', attr)
33 block.html_build(builder)
39 EPUB_TAG = HTML_TAG = 'span'
41 def html_build(self, builder):
42 szer = self.get('szer', '1')
45 from lxml import etree
47 while 'verse' not in p.attrib.get('class', ''):
51 builder.start_element('span', {'class': 'verse-stretched-space'})
55 builder.start_element(p.tag, p.attrib)
57 super().html_build(builder)
59 def get_html_attr(self, builder):
60 szer = self.get('szer', '1').strip()
61 if szer.endswith('em'):
68 "display": "inline-block",
72 get_epub_attr = get_html_attr
74 def txt_build(self, builder):
75 szer = self.get('szer', '1').strip()
76 if szer.endswith('em'):
82 builder.push_text(' ' * 4 * szer)