EPUB: Support for subchapters without chapters.
authorRadek Czajka <rczajka@rczajka.pl>
Fri, 18 Dec 2020 09:22:34 +0000 (10:22 +0100)
committerRadek Czajka <rczajka@rczajka.pl>
Fri, 18 Dec 2020 09:22:34 +0000 (10:22 +0100)
src/librarian/epub.py

index c286903..35766b8 100644 (file)
@@ -327,6 +327,18 @@ def transform_chunk(chunk_xml, chunk_no, annotations, empty=False,
                 )
             )
         elif element.tag in ('naglowek_podrozdzial', 'naglowek_scena'):
+            if not toc:
+                toc.append(
+                    (
+                        epub.Link(
+                            "part%d.xhtml" % chunk_no,
+                            " ",
+                            "part%d" % chunk_no
+                        ),
+                        []
+                    )
+                )
+
             subnumber = len(toc[-1][1])
             toc[-1][1].append(
                 epub.Link(