epub: remove reduntant toc entry, fix validation
authorRadek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Fri, 17 Sep 2010 15:48:38 +0000 (17:48 +0200)
committerRadek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Fri, 17 Sep 2010 15:48:38 +0000 (17:48 +0200)
librarian/epub.py

index c25ba19..84a745f 100644 (file)
@@ -349,13 +349,13 @@ def transform(provider, slug, output_file=None, output_dir=None):
                                'version="2005-1"><head></head><docTitle></docTitle><navMap>' \
                                '<navPoint id="NavPoint-1" playOrder="1"><navLabel>' \
                                '<text>Strona tytułowa</text></navLabel><content src="title.html" />' \
-                               '</navPoint><navPoint id="NavPoint-2" playOrder="2"><navLabel>' \
-                               '<text>Początek utworu</text></navLabel><content src="part1.html" />' \
                                '</navPoint></navMap></ncx>')
     nav_map = toc_file[-1]
 
     toc, chunk_counter = transform_file(input_xml)
-    toc_counter = toc.write_to_xml(nav_map, 3) # we already have 2 navpoints
+    if not toc.children:
+        toc.add(u"Początek utworu", 1)
+    toc_counter = toc.write_to_xml(nav_map, 2)
 
     # Last modifications in container files and EPUB creation
     if len(annotations) > 0: