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'
19 def epub_build(self, builder):
20 super().epub_build(builder)
21 builder.start_element(
24 'class': 'stanza-spacer'
27 builder.push_text('\u00a0');
31 from librarian.parser import parser
34 parser.makeelement('wers')
37 # Before any tags. These are text-only verses.
38 pieces = re.split(r"/\s+", self.text)
39 for piece in pieces[:-1]:
40 verses[-1].text = piece
41 verses.append(parser.makeelement('wers'))
42 verses[-1].text = pieces[-1]
46 pieces = re.split(r"/\s+", child.tail)
47 child_copy = copy(child)
48 child_copy.tail = pieces[0]
49 verses[-1].append(child_copy)
51 for piece in pieces[1:]:
52 verses.append(parser.makeelement('wers'))
53 verses[-1].text = piece
56 verses[-1].append(child)
59 verse[0] if len(verse) == 1 and isinstance(verse[0], Wers)