Epub fixes.
authorRadek Czajka <rczajka@rczajka.pl>
Thu, 8 Jul 2021 13:01:55 +0000 (15:01 +0200)
committerRadek Czajka <rczajka@rczajka.pl>
Thu, 8 Jul 2021 13:01:55 +0000 (15:01 +0200)
src/librarian/builders/epub.py
src/librarian/command_line.py
src/librarian/document.py
src/librarian/elements/__init__.py
src/librarian/elements/figures/ilustr.py

index 167b8cd..4471e30 100644 (file)
@@ -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:
index 2fc7cc1..7b7eb38 100644 (file)
@@ -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())
index 0dbb14f..e220c14 100644 (file)
@@ -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):
         """
index c3a55fb..549d0cb 100644 (file)
@@ -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,
index ab7c2b7..c6105f4 100644 (file)
@@ -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