From: Radek Czajka Date: Tue, 10 Jan 2023 14:54:18 +0000 (+0100) Subject: tabs and centered verses X-Git-Tag: 2.4.10 X-Git-Url: https://git.mdrn.pl/librarian.git/commitdiff_plain/0ad20be3eadf8dbba51d95c9ca3bfc97825d44c6?ds=inline tabs and centered verses --- diff --git a/setup.py b/setup.py index 91cf6a0..cdeb58f 100755 --- a/setup.py +++ b/setup.py @@ -22,7 +22,7 @@ def whole_tree(prefix, path): setup( name='librarian', - version='2.4.8', + version='2.4.10', description='Converter from WolneLektury.pl XML-based language to XHTML, TXT and other formats', author="Marek Stępniowski", author_email='marek@stepniowski.com', diff --git a/src/librarian/elements/__init__.py b/src/librarian/elements/__init__.py index 6efd725..c715e3a 100644 --- a/src/librarian/elements/__init__.py +++ b/src/librarian/elements/__init__.py @@ -23,6 +23,8 @@ WL_ELEMENTS = { "opowiadanie": masters.Master, "powiesc": masters.Master, + "blok": tools.WLElement, + "autor_utworu": front.AutorUtworu, "dzielo_nadrzedne": front.DzieloNadrzedne, "nazwa_utworu": front.NazwaUtworu, @@ -67,6 +69,7 @@ WL_ELEMENTS = { "wers_akap": poetry.WersAkap, "zastepnik_wersu": poetry.ZastepnikWersu, "wers_do_prawej": poetry.WersDoPrawej, + "wers_srodek": poetry.WersSrodek, "pa": footnotes.PA, "pe": footnotes.PE, @@ -117,6 +120,8 @@ WL_ELEMENTS = { "ilustr": figures.Ilustr, "numeracja": tools.Numeracja, + "rownolegle": tools.Rownolegle, + "tab": tools.Tab, # Section "wywiad_pyt": blocks.WywiadPyt, diff --git a/src/librarian/elements/poetry/__init__.py b/src/librarian/elements/poetry/__init__.py index 4784ad0..6eeee4a 100644 --- a/src/librarian/elements/poetry/__init__.py +++ b/src/librarian/elements/poetry/__init__.py @@ -2,6 +2,7 @@ from .strofa import Strofa from .wers_akap import WersAkap from .wers_cd import WersCd from .wers_do_prawej import WersDoPrawej +from .wers_srodek import WersSrodek from .wers import Wers from .wers_wciety import WersWciety from .zastepnik_wersu import ZastepnikWersu diff --git a/src/librarian/elements/poetry/wers_srodek.py b/src/librarian/elements/poetry/wers_srodek.py new file mode 100644 index 0000000..2e95db3 --- /dev/null +++ b/src/librarian/elements/poetry/wers_srodek.py @@ -0,0 +1,9 @@ +from .wers import Wers + + +class WersSrodek(Wers): + TXT_PREFIX = ' ' + + EPUB_ATTR = HTML_ATTR = { + "style": "text-align: center", + } diff --git a/src/librarian/elements/tools/__init__.py b/src/librarian/elements/tools/__init__.py index 1e9d53f..ad0ab97 100644 --- a/src/librarian/elements/tools/__init__.py +++ b/src/librarian/elements/tools/__init__.py @@ -4,3 +4,32 @@ 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 + diff --git a/src/librarian/epub/style.css b/src/librarian/epub/style.css index dfd9fe7..8325c12 100644 --- a/src/librarian/epub/style.css +++ b/src/librarian/epub/style.css @@ -402,3 +402,14 @@ th, td { font-size: 1.3em; line-height: 1.4em; } + +.rownolegly-blok { + border-left: 2px solid red; + padding-left: .5em; +} +.rownolegly-blok.first { + border-radius: 0 0 0 .75em; +} +.rownolegly-blok.last { + border-radius: .75em 0 0 0; +} diff --git a/src/librarian/xslt/book2html.xslt b/src/librarian/xslt/book2html.xslt index f540b49..2057326 100644 --- a/src/librarian/xslt/book2html.xslt +++ b/src/librarian/xslt/book2html.xslt @@ -331,7 +331,7 @@ - + @@ -339,14 +339,14 @@ - + - + @@ -377,6 +377,9 @@ text-align: right + + text-align: center + @@ -534,6 +537,47 @@ + + + + + +
+ + rownolegly-blok + + last + + + first + + + + border-left: 2px solid red; padding-left: .5em; + + border-radius: 0 0 0 .75em; + + + border-radius: .75em 0 0 0; + + + +
+
+ + + + + + display: inline-block; width: em + + + display: inline-block; width: 1em + + + + +