3 from ..base import WLElement
7 class Strofa(WLElement):
12 TXT_LEGACY_TOP_MARGIN = 1
13 TXT_LEGACY_BOTTOM_MARGIN = 0
15 EPUB_TAG = HTML_TAG = 'div'
16 EPUB_CLASS = HTML_CLASS = 'stanza'
18 def epub_build(self, builder):
19 super().epub_build(builder)
20 builder.start_element(
23 'class': 'stanza-spacer'
26 builder.push_text('\u00a0');
30 from librarian.parser import parser
33 parser.makeelement('wers')
36 # Before any tags. These are text-only verses.
37 pieces = re.split(r"/\s+", self.text)
38 for piece in pieces[:-1]:
39 verses[-1].text = piece
40 verses.append(parser.makeelement('wers'))
41 verses[-1].text = pieces[-1]
45 pieces = re.split(r"/\s+", child.tail)
46 child_copy = copy(child)
47 child_copy.tail = pieces[0]
48 verses[-1].append(child_copy)
50 for piece in pieces[1:]:
51 verses.append(parser.makeelement('wers'))
52 verses[-1].text = piece
55 verses[-1].append(child)
59 if len(verse) == 1 and isinstance(verse[0], Wers):
60 assert not (verse.text or '').strip()
61 assert not (verse[0].tail or '').strip()
66 def _build_inner(self, builder, build_method):
67 for child in self.get_verses():
68 getattr(child, build_method)(builder)