Commits

Brian Mearns committed 1c1c340

Better handling for chapters with no titles.

Comments (0)

Files changed (4)

 Rel 7 - ???????? - ????-??-??
-    [n] A little better handling of UTF-8 and a few character accents.
+    [p] A little better handling of UTF-8 and a few character accents.
         (cs ff19a2f)
+    [p] Better handling for chapters with no titles.
 
 Rel 6 - v1.2.3.0 - 2013-04-08
     [n] Always add space at end of line, for things like quotes that close at
         for child in node.childNodes:
             if child.nodeType == xml.dom.Node.ELEMENT_NODE:
                 if child.tagName.lower() == "title":
-                    titled.appendTitle(child.firstChild.nodeValue.strip())
+                    if child.firstChild is not None:
+                        titled.appendTitle(child.firstChild.nodeValue.strip())
         
     def __parsePart(self, node):
         part = Part()

src/tome/writeLatex.py

             for chapter in book:
                 chAllTitles = chapter.allTitles()
 
-                chLatTitle = latexEscape(chAllTitles[0])
+                if len(chAllTitles) > 0:
+                    chLatTitle = latexEscape(chAllTitles[0])
+                else:
+                    chLatTitle = ""
 
                 chLatSubtitles = "\n".join("\t\\chSubtitle{%s}" % latexEscape(subtitle) for subtitle in chAllTitles[1:])
 

src/tome/writeText.py

                     leftOver -= 1
             ostream.write(line[-1] + "\n")
             prefix = indent
+
         #Don't justify the last line.
-        ostream.write(prefix + " ".join(lines[-1]))
+        if len(lines) > 0:
+            ostream.write(prefix + " ".join(lines[-1]))
 
             
     def writeText(self, tome, ostream):