1 # This file is part of Librarian, licensed under GNU Affero GPLv3 or later.
2 # Copyright © Fundacja Wolne Lektury. See NOTICE for more information.
6 from ..base import WLElement
10 class Strofa(WLElement):
16 EPUB_TAG = HTML_TAG = 'div'
17 EPUB_CLASS = HTML_CLASS = 'stanza'
22 def epub_build(self, builder):
23 super().epub_build(builder)
24 builder.start_element(
27 'class': 'stanza-spacer'
30 builder.push_text('\u00a0');
34 from librarian.parser import parser
37 parser.makeelement('wers')
40 # Before any tags. These are text-only verses.
41 pieces = re.split(r"/\s+", self.text)
42 for piece in pieces[:-1]:
43 verses[-1].text = piece
44 verses.append(parser.makeelement('wers'))
45 verses[-1].text = pieces[-1]
49 pieces = re.split(r"/\s+", child.tail)
50 child_copy = copy(child)
51 child_copy.tail = pieces[0]
52 verses[-1].append(child_copy)
54 for piece in pieces[1:]:
55 verses.append(parser.makeelement('wers'))
56 verses[-1].text = piece
59 verses[-1].append(child)
62 verse[0] if len(verse) == 1 and isinstance(verse[0], Wers)