From: Radek Czajka Date: Thu, 8 Jul 2021 13:01:55 +0000 (+0200) Subject: Epub fixes. X-Git-Tag: 2.1~2 X-Git-Url: https://git.mdrn.pl/librarian.git/commitdiff_plain/e67fee0ec88f99401f5add011bf801ec10181e37?hp=261a3308d235fc252f30ae03603d0e964bb60223 Epub fixes. --- diff --git a/src/librarian/builders/epub.py b/src/librarian/builders/epub.py index 167b8cd..4471e30 100644 --- a/src/librarian/builders/epub.py +++ b/src/librarian/builders/epub.py @@ -558,7 +558,8 @@ class EpubBuilder(Builder): )) ).text = str(m.url) - newp().text = 'Tekst opracowany na podstawie: ' + m.source_name + if m.source_name: + newp().text = 'Tekst opracowany na podstawie: ' + m.source_name newp().text = """ Wydawca: diff --git a/src/librarian/command_line.py b/src/librarian/command_line.py index 2fc7cc1..7b7eb38 100644 --- a/src/librarian/command_line.py +++ b/src/librarian/command_line.py @@ -58,6 +58,6 @@ def main(*args, **kwargs): "mp3": args.mp3, } - output = document.build(builder, **kwargs) + output = document.build(builder, base_url=args.base_url, **kwargs) with open(output_file_path, 'wb') as f: f.write(output.get_bytes()) diff --git a/src/librarian/document.py b/src/librarian/document.py index 0dbb14f..e220c14 100644 --- a/src/librarian/document.py +++ b/src/librarian/document.py @@ -36,8 +36,8 @@ class WLDocument: ) - def build(self, builder, **kwargs): - return builder().build(self, **kwargs) + def build(self, builder, base_url=None, **kwargs): + return builder(base_url=base_url).build(self, **kwargs) def _compat_assign_ordered_ids(self): """ diff --git a/src/librarian/elements/__init__.py b/src/librarian/elements/__init__.py index c3a55fb..549d0cb 100644 --- a/src/librarian/elements/__init__.py +++ b/src/librarian/elements/__init__.py @@ -10,7 +10,8 @@ WL_ELEMENTS = { "coverBarColor": etree.ElementBase, "coverBoxPosition": etree.ElementBase, "coverLogoUrl": etree.ElementBase, - + "contentWarning": etree.ElementBase, + "utwor": root.Utwor, "dramat_wierszowany_l": masters.Master, "dramat_wierszowany_lp": masters.Master, @@ -111,6 +112,8 @@ WL_ELEMENTS = { "animacja": figures.Animacja, "ilustr": figures.Ilustr, + "ref": etree.ElementBase, + # Inline MathML, should really be namespaced. "mrow": etree.ElementBase, "mi": etree.ElementBase, diff --git a/src/librarian/elements/figures/ilustr.py b/src/librarian/elements/figures/ilustr.py index ab7c2b7..c6105f4 100644 --- a/src/librarian/elements/figures/ilustr.py +++ b/src/librarian/elements/figures/ilustr.py @@ -27,10 +27,9 @@ class Ilustr(WLElement): else: th = img.resize((width, round(width * img.size[1] / img.size[0]))) - imgfile.close() buffer = six.BytesIO() th.save(buffer, format=th_format) - ## TODO: Counter + imgfile.close() file_name = 'image%d.%s' % ( builder.assign_image_number(), ext