X-Git-Url: https://git.mdrn.pl/librarian.git/blobdiff_plain/3a0c83394d5783715fab2be29fa1a9cfc3574e28..23d025c8875cca1404f274aca7170c9db5e980e7:/src/librarian/elements/poetry/wers.py diff --git a/src/librarian/elements/poetry/wers.py b/src/librarian/elements/poetry/wers.py index edc4c7c..c188845 100644 --- a/src/librarian/elements/poetry/wers.py +++ b/src/librarian/elements/poetry/wers.py @@ -9,11 +9,13 @@ class Wers(WLElement): TXT_TOP_MARGIN = 1 TXT_BOTTOM_MARGIN = 1 - TXT_LEGACY_TOP_MARGIN = 1 - TXT_LEGACY_BOTTOM_MARGIN = 0 EPUB_TAG = HTML_TAG = 'div' - EPUB_CLASS = HTML_CLASS = 'verse' + EPUB_CLASS = 'verse' + HTML_CLASS = 'wl verse' + FB2_TAG = 'v' + + NUMBERING = 'main' @property def meta(self): @@ -21,7 +23,31 @@ class Wers(WLElement): return self.stanza.meta return super(Wers, self).meta - def _epub_build_inner(self, builder): - super()._epub_build_inner(builder) + def epub_build_inner(self, builder): + super().epub_build_inner(builder) builder.push_text('''\u00a0''') + @property + def has_visible_numbering(self): + try: + number = int(self.attrib['_visible_numbering']) + except: + return False + return number == 1 or not(number % 5) + + @property + def is_stretched(self): + return self.find('.//tab[@szer="*"]') is not None + + def get_html_attr(self, builder): + attr = super().get_html_attr(builder) + if self.is_stretched: + attr['class'] += ' verse-stretched' + return attr + + def html_build_inner(self, builder): + if self.is_stretched: + builder.start_element('span') + super().html_build_inner(builder) + if self.is_stretched: + builder.end_element()