X-Git-Url: https://git.mdrn.pl/librarian.git/blobdiff_plain/bc7e9351bc22788218e988c188defdbdfbe12fd8..9c9a55d7dda5595a236f11977d7f21f804d37872:/src/librarian/elements/tools/__init__.py?ds=sidebyside diff --git a/src/librarian/elements/tools/__init__.py b/src/librarian/elements/tools/__init__.py index 1e9d53f..99f81d9 100644 --- a/src/librarian/elements/tools/__init__.py +++ b/src/librarian/elements/tools/__init__.py @@ -1,6 +1,38 @@ +# This file is part of Librarian, licensed under GNU Affero GPLv3 or later. +# Copyright © Fundacja Wolne Lektury. See NOTICE for more information. +# from ..base import WLElement class Numeracja(WLElement): pass + +class Rownolegle(WLElement): + def build_epub(self, builder): + for i, block in enumerate(self): + attr = {"class": "rownolegly-blok"} + if not i: + attr['class'] += ' first' + if i == len(self) - 1: + attr['class'] += ' last' + builder.start_element('div', attr) + self.build_epub(block, builder) + builder.end_element() + + +class Tab(WLElement): + EPUB_TAG = HTML_TAG = 'span' + + def get_html_attr(self, builder): + try: + szer = int(self.get('szer', 1)) + except: + szer = 1 + return { + "display": "inline-block", + "width": f"{szer}em", + } + + get_epub_attr = get_html_attr +