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):
10 def assign_id(self, document):
11 document.counters['_visible'] = int(self.get('start', 1))
14 class Rownolegle(WLElement):
15 def epub_build(self, builder):
16 for i, block in enumerate(self):
17 attr = {"class": "rownolegly-blok"}
19 attr['class'] += ' first'
20 if i == len(self) - 1:
21 attr['class'] += ' last'
22 builder.start_element('div', attr)
23 block.epub_build(builder)
26 def html_build(self, builder):
27 for i, block in enumerate(self):
28 attr = {"class": "paralell-block"}
30 attr['class'] += ' paralell-block-first'
31 if i == len(self) - 1:
32 attr['class'] += ' paralell-block-last'
33 builder.start_element('div', attr)
34 block.html_build(builder)
40 EPUB_TAG = HTML_TAG = 'span'
42 def html_build(self, builder):
43 szer = self.get('szer', '1')
46 from lxml import etree
48 while 'verse' not in p.attrib.get('class', ''):
52 builder.start_element('span', {'class': 'verse-stretched-space'})
56 builder.start_element(p.tag, p.attrib)
58 super().html_build(builder)
60 def get_html_attr(self, builder):
61 szer = self.get('szer', '1').strip()
62 if szer.endswith('em'):
69 "display": "inline-block",
73 get_epub_attr = get_html_attr
75 def txt_build(self, builder):
76 szer = self.get('szer', '1').strip()
77 if szer.endswith('em'):
83 builder.push_text(' ' * 4 * szer)