X-Git-Url: https://git.mdrn.pl/librarian.git/blobdiff_plain/bc7e9351bc22788218e988c188defdbdfbe12fd8..e2acc67a478455184e5e714e63a61e78ad37d787:/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 +