3 from ..base import WLElement
7 class Strofa(WLElement):
10 TXT_LEGACY_TOP_MARGIN = 1
11 TXT_LEGACY_BOTTOM_MARGIN = 0
13 EPUB_TAG = HTML_TAG = 'div'
14 EPUB_CLASS = HTML_CLASS = 'stanza'
16 def epub_build(self, builder):
17 super().epub_build(builder)
18 builder.start_element(
21 'class': 'stanza-spacer'
24 builder.push_text('\u00a0');
28 from librarian.parser import parser
31 parser.makeelement('wers')
34 # Before any tags. These are text-only verses.
35 pieces = re.split(r"/\s+", self.text)
36 for piece in pieces[:-1]:
37 verses[-1].text = piece
38 verses.append(parser.makeelement('wers'))
39 verses[-1].text = pieces[-1]
43 pieces = re.split(r"/\s+", child.tail)
44 child_copy = copy(child)
45 child_copy.tail = pieces[0]
46 verses[-1].append(child_copy)
48 for piece in pieces[1:]:
49 verses.append(parser.makeelement('wers'))
50 verses[-1].text = piece
53 verses[-1].append(child)
57 if len(verse) == 1 and isinstance(verse[0], Wers):
58 assert not (verse.text or '').strip()
59 assert not (verse[0].tail or '').strip()
64 def _build_inner(self, builder, build_method):
65 for child in self.get_verses():
66 getattr(child, build_method)(builder)