Commits

Derek Mannheim committed 962275e

Branching to try to add books and parts to EPUB.

Comments (0)

Files changed (8)

src/tome/res/epub-template/bookTitle.xhtml.tmpl

+{#  "
+
+    "
+}{syntax xml
+
+}<?xml version="1.0" encoding="UTF-8"?>
+<html xmlns="http://www.w3.org/1999/xhtml">
+    <head>
+        <title>Book {roman-up {$ BOOK-NUM}}{$ BOOK-TITLE-SEP-HTML}{$ BOOK-SHORTMARK}</title>
+        <link href="stylesheet.css" type="text/css" rel="stylesheet" />
+        <link rel="stylesheet" type="application/vnd.adobe-page-template+xml" href="page-template.xpgt"/>
+
+        {$ LICENSE-LINK-HTML }
+        <link rel="contents" href="toc.xhtml" />
+        <link rel="start" href="frontcover.xhtml" />
+
+    </head>
+    <body class='bodymatter book titlepage'>
+
+        <a id="chapter{$ BOOK-NUM}" />
+        <div class='title'>
+            <h3 class='titleGeneric'>Book {roman-up {$ BOOK-NUM}}</h3>
+            <h1 class='title'>{$ BOOK-TITLE}</h1>
+            <hr class='titleSep' />
+            {$ BOOK-SUBTITLES-HTML}
+        </div>
+
+    </body>
+</html>
+

src/tome/res/epub-template/chapter.xhtml.tmpl

         <link rel="stylesheet" type="text/css" href="stylesheet.css" />
         <link rel="stylesheet" type="application/vnd.adobe-page-template+xml" href="page-template.xpgt"/>
 
+        {$ LICENSE-LINK-HTML }
         <link rel="contents" href="toc.xhtml" />
         <link rel="start" href="frontcover.xhtml" />
-        <link rel="license" href="https://creativecommons.org/licenses/by-nc-nd/3.0/deed.en_US" />
 
         {if
             {$ CHAP-IS-FIRST}

src/tome/res/epub-template/endnotes.xhtml.tmpl

     "
 }{v{:
 
-}}{syntax xml
+}}{syn html
 
 }<?xml version="1.0" encoding="UTF-8"?>
 <html xmlns="http://www.w3.org/1999/xhtml">
         <link href="stylesheet.css" type="text/css" rel="stylesheet" />
         <link rel="stylesheet" type="application/vnd.adobe-page-template+xml" href="page-template.xpgt"/>
 
+        {$ LICENSE-LINK-HTML }
         <link rel="contents" href="toc.xhtml" />
         <link rel="start" href="frontcover.xhtml" />
-        <link rel="license" href="https://creativecommons.org/licenses/by-nc-nd/3.0/deed.en_US" />
 
         <link rel="prev" href="{$ LAST-CHAP-FILE-HTML}" />
     </head>

src/tome/res/epub-template/frontcover.xhtml.tmpl

         <link href="stylesheet.css" type="text/css" rel="stylesheet" />
         <link rel="stylesheet" type="application/vnd.adobe-page-template+xml" href="page-template.xpgt"/>
 
+        {$ LICENSE-LINK-HTML }
         <link rel="contents" href="toc.xhtml" />
         <link rel="start" href="frontcover.xhtml" />
-        <link rel="license" href="https://creativecommons.org/licenses/by-nc-nd/3.0/deed.en_US" />
 
         <link rel="next" href="titlepage.xhtml" />
 

src/tome/res/epub-template/partTitle.xhtml.tmpl

+{#  "
+
+    "
+}{syntax xml
+
+}<?xml version="1.0" encoding="UTF-8"?>
+<html xmlns="http://www.w3.org/1999/xhtml">
+    <head>
+        <title>Part {roman-up {$ PART-NUM}}{$ PART-TITLE-SEP-HTML}{$ PART-SHORTMARK}</title>
+        <link href="stylesheet.css" type="text/css" rel="stylesheet" />
+        <link rel="stylesheet" type="application/vnd.adobe-page-template+xml" href="page-template.xpgt"/>
+
+        {$ LICENSE-LINK-HTML }
+        <link rel="contents" href="toc.xhtml" />
+        <link rel="start" href="frontcover.xhtml" />
+
+    </head>
+    <body class='bodymatter part titlepage'>
+
+        <a id="chapter{$ PART-NUM}" />
+        <div class='title'>
+            <h3 class='titleGeneric'>Part {roman-up {$ PART-NUM}}</h3>
+            <h1 class='title'>{$ PART-TITLE}</h1>
+            <hr class='titleSep' />
+            {$ PART-SUBTITLES-HTML}
+        </div>
+
+    </body>
+</html>
+

src/tome/res/epub-template/title_page.xhtml.tmpl

         <link href="stylesheet.css" type="text/css" rel="stylesheet" />
         <link rel="stylesheet" type="application/vnd.adobe-page-template+xml" href="page-template.xpgt"/>
 
+        {$ LICENSE-LINK-HTML }
         <link rel="contents" href="toc.xhtml" />
         <link rel="start" href="frontcover.xhtml" />
-        <link rel="license" href="https://creativecommons.org/licenses/by-nc-nd/3.0/deed.en_US" />
 
         <link rel="prev" href="frontcover.xhtml" />
         <link rel="next" href="toc.xhtml" />

src/tome/res/epub-template/toc.xhtml.tmpl

         <link href="stylesheet.css" type="text/css" rel="stylesheet" />
         <link rel="stylesheet" type="application/vnd.adobe-page-template+xml" href="page-template.xpgt"/>
 
+        {$ LICENSE-LINK-HTML }
         <link rel="contents" href="toc.xhtml" />
         <link rel="start" href="frontcover.xhtml" />
-        <link rel="license" href="https://creativecommons.org/licenses/by-nc-nd/3.0/deed.en_US" />
 
         <link rel='prev' href='titlepage.xhtml' />
-        <link rel="next" href="chapter0001.xhtml" />
         
     </head>
     <body class="frontmatter toc" id="toc">

src/tome/writeEpub.py

         for f in srcFiles:
             if os.path.join(self.__templateDir, f) == self.__chapterTemplatePath:
                 continue
+            if os.path.join(self.__templateDir, f) == self.__bookTitleTemplatePath:
+                continue
+            if os.path.join(self.__templateDir, f) == self.__partTitleTemplatePath:
+                continue
             elif self.__tmplFilter(f):
                 templFiles.append(f)
             else:
         topScope["MODIFIED"] = templ.ttypes.String(time.strftime("%Y-%m-%dT%H:%M:%SZ", now))
         topScope["COPYRIGHT-YEAR"] = templ.ttypes.String(time.strftime("%Y", now))
         topScope["COPYRIGHT-HOLDER"] = templ.ttypes.String(firstAuthor)
+
         topScope["LICENSE-HTML"] = templ.ttypes.String("")
         if self.__tome.hasMeta("license-html"):
             topScope["LICENSE-HTML"] = templ.ttypes.String(
                 licenseHtml = pretext + licenseHtml
                 topScope["LICENSE-HTML"] = templ.ttypes.String(licenseHtml)
 
+        topScope["LICENSE-LINK-HTML"] = templ.ttypes.String("")
+        if self.__tome.hasMeta("license-url"):
+            topScope["LICENSE-LINK-HTML"] = templ.ttypes.String(
+                "".join(("""
+        <link rel="license" href="{url}" />""".format(
+                        url = htmlEscape(url)
+                    )) for url in self.__tome.getMeta("license-url")
+            )
+        )
 
 
         #TODO Include Parts and Books.
 
-        chFileList = []
         hasEndnotes = "0"
         lastPart = False
         lastBook = False
                 self.__bkIdx += 1
                 lastBook = (bkNumber+1 == len(part))
 
+                #Generate the book content.
+                startingDepth = templStack.depth()
+                bkOstream = cStringIO.StringIO()
+                #TODO: FIXME: Only include part and book if explicitely titled.
+                self.writeBookContent(templStack, bkOstream, prtNumber, bkNumber, book)
+                bkFileContent = bkOstream.getvalue()
+                bkOstream.close()
+
+                #Add the generated bkapter file to the zipfile.
+                zf.writestr(self.bookFileName(self.__bkIdx), bkFileContent)
+                bkFileContent = ""
+                if templStack.depth() != startingDepth:
+                    raise Exception("Error processing book %d: stack depth is incorrect." % self.__bkIdx)
+
+
                 for chNumber in xrange(len(book)):
                     chapter = book[chNumber]
                     self.__chIdx += 1
                     #Generate the chapter content.
                     startingDepth = templStack.depth()
                     chOstream = cStringIO.StringIO()
-                    chRelPath = self.writeChapterContent(templStack, chOstream, prtNumber, bkNumber, chapter, lastChapter and lastBook and lastPart)
-                    chFileList.append(chRelPath)
+                    self.writeChapterContent(templStack, chOstream, prtNumber, bkNumber, chapter, lastChapter and lastBook and lastPart)
                     chFileContent = chOstream.getvalue()
                     chOstream.close()
 
                     #Add the generated chapter file to the zipfile.
-                    zf.writestr(chRelPath, chFileContent)
+                    zf.writestr(self.chapterFileName(self.__chIdx), chFileContent)
                     chFileContent = ""
                     if templStack.depth() != startingDepth:
                         raise Exception("Error processing chapter %d: stack depth is incorrect." % self.__chIdx)
 
 
         #Now that we've processed everything, we can add the rest of the symbols to the scope.
-        topScope["CHAP-FILE-LIST"] = templ.ttypes.List(chFileList)
-        topScope["LAST-CHAP-FILE-HTML"] = templ.ttypes.String(htmlEscape(chFileList[-1]))
+        #TODO: Check this.
+        topScope["CHAP-FILE-LIST"] = templ.ttypes.List(self.chapterFileName(chIdx) for chIdx in xrange(1, self.__chIdx+1))
+        topScope["LAST-CHAP-FILE-HTML"] = templ.ttypes.String(self.chapterFileName(self.__chIdx))
         topScope["CHAP-COUNT"] = templ.ttypes.String(self.__chIdx)
 
         topScope["HAS-ENDNOTES"] = templ.ttypes.String(hasEndnotes)
         topScope["ENDNOTES-LIST"] = templ.ttypes.List(self.__enList)
         topScope["ENDNOTES-HTML"] = templ.ttypes.String(self.generate_ENDNOTES_HTML())
 
-        topScope["MANIFEST-XML"] = templ.ttypes.String(self.generate_MANIFEST_XML(chFileList))
+        topScope["MANIFEST-XML"] = templ.ttypes.String(self.generate_MANIFEST_XML())
         topScope["SPINE-XML"] = templ.ttypes.String(self.generate_SPINE_XML())
         topScope["NAV-HTML"] = templ.ttypes.String(self.generate_NAV_HTML())
         topScope["NCX-XML"] = templ.ttypes.String(self.generate_NCX_XML())
         zf.close()
 
 
+    def writeBookContent(self, templStack, bkOstream, prtNumber, bkNumber, book):
+
+        #A new scope for this book, which we'll pop before we go.
+        #TODO: Don't push or pop it here: push it in the calling function and pop it after the 
+        # whole book is done, so the chapter can access book stuff, too.
+        bookScope = templStack.push()
+
+        bookScope["BOOK-NUM"] = templ.ttypes.String(str(self.__bkIdx))
+        bookScope["BOOK-TITLE-LIST"] = templ.ttypes.List(book.allTitles())
+        bookScope["BOOK-TITLE"] = templ.ttypes.String(self.generate_any_TITLE(book))
+        bookScope["BOOK-TITLE-SEP-HTML"] = templ.ttypes.String(self.generate_any_TITLE_SEP_HTML(book))
+        bookScope["BOOK-TITLES-HTML"] = templ.ttypes.String(self.generate_any_TITLES_HTML(book))
+        bookScope["BOOK-SUBTITLES-HTML"] = templ.ttypes.String(self.generate_any_SUBTITLES_HTML(book))
+        bookScope["BOOK-SHORTMARK"] = templ.ttypes.String(self.generate_any_SHORTMARK(book))
+        bookScope["BOOK-HAS-SHORTMARK"] = templ.ttypes.String(self.generate_any_HAS_SHORTMARK(book))
+        bookScope["BOOK-SHORTMARK-SEP-HTML"] = templ.ttypes.String(self.generate_any_SHORTMARK_SEP_HTML(book))
+        bookScope["BOOK-CHAP-COUNT"] = templ.ttypes.String(len(book))
+
+        #Open the book template file.
+        try:
+            istream = open(self.__bookTitleTemplatePath, "r")
+        except Exception, e:
+            raise Exception("Error opening book template file for reading:", e)
+
+        #Process to the given output stream.
+        ostream = templ.tstreams.TemplateStreamOutputStream(bkOstream)
+        templ.templ.processWithStack(istream, ostream, templStack, self.__bookTitleTemplatePath, debug=False)
+        istream.close()
+
+        templStack.pop()
+
+
     def writeChapterContent(self, templStack, chOstream, prtNumber, bkNumber, chapter, isLastChapter):
         """
         Writes all the content files.
             chapScope["CHAP-IS-LAST"] = templ.ttypes.String("0")
             chapScope["CHAP-REL-NEXT-HTML"] = templ.ttypes.String(self.generate_CHAP_REL_NEXT_HTML())
         chapScope["CHAP-TITLE-LIST"] = templ.ttypes.List(chAllTitles)
-        chapScope["CHAP-TITLE"] = templ.ttypes.String(self.generate_CHAP_TITLE(chapter))
-        chapScope["CHAP-TITLES-HTML"] = templ.ttypes.String(self.generate_CHAP_TITLES_HTML(chapter))
-        chapScope["CHAP-TITLE-SEP-HTML"] = templ.ttypes.String(self.generate_CHAP_TITLE_SEP_HTML(chapter))
-        chapScope["CHAP-SHORTMARK"] = templ.ttypes.String(self.generate_CHAP_SHORTMARK(chapter))
-        chapScope["CHAP-HAS-SHORTMARK"] = templ.ttypes.String(self.generate_CHAP_HAS_SHORTMARK(chapter))
-        chapScope["CHAP-SHORTMARK-SEP-HTML"] = templ.ttypes.String(self.generate_CHAP_SHORTMARK_SEP_HTML(chapter))
+        chapScope["CHAP-TITLE"] = templ.ttypes.String(self.generate_any_TITLE(chapter))
+        chapScope["CHAP-TITLES-HTML"] = templ.ttypes.String(self.generate_any_TITLES_HTML(chapter))
+        chapScope["CHAP-TITLE-SEP-HTML"] = templ.ttypes.String(self.generate_any_TITLE_SEP_HTML(chapter))
+        chapScope["CHAP-SHORTMARK"] = templ.ttypes.String(self.generate_any_SHORTMARK(chapter))
+        chapScope["CHAP-HAS-SHORTMARK"] = templ.ttypes.String(self.generate_any_HAS_SHORTMARK(chapter))
+        chapScope["CHAP-SHORTMARK-SEP-HTML"] = templ.ttypes.String(self.generate_any_SHORTMARK_SEP_HTML(chapter))
         chapScope["CHAP-SCENE-COUNT"] = templ.ttypes.String(len(chapter))
 
 
 
         templStack.pop()
 
-        return "chapter%s.xhtml" % chUid
+
+    def chapterFileName(self, chIdx):
+        return "chapter%s.xhtml" % self.__chUid(chIdx)
+
+    def bookFileName(self, bkIdx):
+        return "book%s.xhtml" % self.__chUid(bkIdx)
+
+    def partFileName(self, prtIdx):
+        return "part%s.xhtml" % self.__chUid(prtIdx)
 
 
     def generate_AUTHORS_HTML(self):
 
 
 
-    def generate_CHAP_TITLE(self, chapter):
-        title = chapter.title()
+    def generate_any_TITLE(self, titled):
+        title = titled.title()
         if title is None:
             return ""
         else:
             return title
 
     def generate_TITLE(self):
-        title = self.__tome.title()
-        if title is None:
-            return ""
-        else:
-            return title
+        return self.generate_any_TITLE(self.__tome)
 
     def generate_AUTHOR(self):
         authors = self.__tome.authors()
         else:
             return authors[0]
 
-    def generate_CHAP_SHORTMARK(self, chapter):
+    def generate_any_SHORTMARK(self, titled):
         """
-        Returns a short title for the given chapter. If the chapter has a short mark, then it is the shortmark.
+        Returns a short title for the given titled section. If the section has a short mark, then it is the shortmark.
         If it doesn't, then it is the first title. If it doesn't have a title either, then it's an empty string.
         """
-        smark = chapter.shortMark()
+        smark = titled.shortMark()
         if smark is None:
-            return self.generate_CHAP_TITLE(chapter)
+            return self.generate_any_TITLE(titled)
         else:
             return smark
 
-    def hasChapShortMark(self, chapter):
+    def hasShortMark(self, titled):
         """
-        Determines whether or not the given chapter has a short mark, as specified by <generate_CHAP_SHORTMARK>, which
+        Determines whether or not the given section has a short mark, as specified by <generate_any_SHORTMARK>, which
         really just means it has anything it can use for a shortmark.
         """
-        smark = chapter.shortMark()
+        smark = titled.shortMark()
         if smark is None:
-            if len(chapter.allTitles()) == 0:
+            if len(titled.allTitles()) == 0:
                 return False
             else:
                 return True
         else:
             return False
 
-    def generate_CHAP_HAS_SHORTMARK(self, chapter):
-        if self.hasChapShortMark(chapter):
+    def generate_any_HAS_SHORTMARK(self, titled):
+        if self.hasShortMark(titled):
             return "1"
         else:
             return "0"
 
-    def generate_CHAP_SHORTMARK_SEP_HTML(self, chapter):
+    def generate_any_SHORTMARK_SEP_HTML(self, titled):
         """
-        Returns an HTML string which can be used to separate the chapter shortmark from other text, for instance the chapter number.
-        If there is no short mark (as determined by :meth:`hasChapShortMark`), returns an empty string, so you can safely include this
+        Returns an HTML string which can be used to separate the section's shortmark from other text, for instance the section number.
+        If there is no short mark (as determined by :meth:`hasShortMark`), returns an empty string, so you can safely include this
         regardless of whether there is or isn't a short mark.
         """
-        if self.hasChapShortMark(chapter):
+        if self.hasShortMark(titled):
             return " &#8211; "
         else:
             return ""
 
-    def generate_CHAP_TITLE_SEP_HTML(self, chapter):
-        if len(chapter.allTitles()) == 0:
+    def generate_any_TITLE_SEP_HTML(self, titled):
+        if len(titled.allTitles()) == 0:
             return ""
         else:
             return " &#8211; "
 
-    def generate_CHAP_TITLES_HTML(self, chapter):
+    def generate_any_TITLES_HTML(self, titled):
         #Build the HTML for the chatper titles.
         titleLevel = 2
         titleIdx = 0
-        chHtmlAllTitles = ""
-        allTitles = chapter.allTitles()
+        htmlAllTitles = ""
+        allTitles = titled.allTitles()
         titleCount = len(allTitles)
         for title in allTitles:
             titleIdx += 1
             if titleIdx > 1:
                 subtitleClasses = "subtitle subtitle%d" % (titleIdx)
 
-            chHtmlAllTitles += "<h%d class='title %s %s'>%s</h%d>\n" % (titleLevel, subtitleClasses, lastTitle, htmlEscape(title), titleLevel)
+            htmlAllTitles += "<h%d class='title %s %s'>%s</h%d>\n" % (titleLevel, subtitleClasses, lastTitle, htmlEscape(title), titleLevel)
             if titleLevel < 6:
                 titleLevel += 1
-        return chHtmlAllTitles
+        return htmlAllTitles
 
     def generate_ENDNOTES_HTML(self):
         endNotesHtml = """
                     if len(chEndNotes) > 0:
                         chNum = str(chIdx)
                         chUid = self.__chUid(chIdx)
-                        shortMark = self.generate_CHAP_SHORTMARK_SEP_HTML(chapter) + self.generate_CHAP_SHORTMARK(chapter)
+                        shortMark = self.generate_any_SHORTMARK_SEP_HTML(chapter) + self.generate_any_SHORTMARK(chapter)
 
                         #Open the chapter section.
                         endNotesHtml += """
             <h2 class='title'>Chapter Notes</h2>""".format(chNum = str(chIdx))
 
             
+    def generate_SUBTITLES_HTML(self):
+        return self.generate_any_SUBTITLES_HTML(self.__tome)
 
-    def generate_SUBTITLES_HTML(self):
+
+    def generate_any_SUBTITLES_HTML(self, titled):
         ### Build some HTML for the sub titles.
         titleLevel = 2
         subtitleHtml = ""
-        allSubTitles = self.__tome.allTitles()[1:]
+        allSubTitles = titled.allTitles()[1:]
         stitleCount = len(allSubTitles)
         for titleIdx in xrange(stitleCount):
             lastTitle = ""
 
         
 
-    def generate_MANIFEST_XML(self, chapterFiles):
+    def generate_MANIFEST_XML(self):
         manifestXml = ""
         chIdx = 0
-        for path in chapterFiles:
-            chIdx += 1
+        bkIdx = 0
+        prtIdx = 0
+        #TODO: FIXME: Only include part and book if explicitely titled.
+        for part in self.__tome:
+            prtIdx += 1
             manifestXml += """
-        <item id="chapter{chUid}" href="{path}" media-type="application/xhtml+xml" />""".format(
-                chUid = self.__chUid(chIdx),
-                path = path
+        <item id="part{idx}" href="{path}" media-type="application/xhtml+xml" />""".format(
+                idx = str(prtIdx),
+                path = self.partFileName(prtIdx)
             )
 
+            for book in part:
+                bkIdx += 1
+                manifestXml += """
+            <item id="book{idx}" href="{path}" media-type="application/xhtml+xml" />""".format(
+                    idx = str(bkIdx),
+                    path = self.bookFileName(bkIdx)
+                )
+
+                for chapter in book:
+                    chIdx += 1
+                    manifestXml += """
+                <item id="chapter{idx}" href="{path}" media-type="application/xhtml+xml" />""".format(
+                        idx = str(chIdx),
+                        path = self.chapterFileName(chIdx)
+                    )
+
         return manifestXml
 
     def generate_SPINE_XML(self):
         spineXml = ""
-        for i in xrange(self.__chIdx):
+        chIdx = 0
+        bkIdx = 0
+        prtIdx = 0
+        #TODO: FIXME: Only include part and book if explicitely titled.
+        for part in self.__tome:
+            prtIdx += 1
             spineXml += """
-        <itemref idref="chapter{chUid}" />""".format(
-                chUid = self.__chUid(i+1)
+        <itemref idref="part{idx}" />""".format(
+                idx = str(prtIdx)
             )
+
+            for book in part:
+                bkIdx += 1
+                spineXml += """
+            <itemref idref="book{idx}" />""".format(
+                    idx = str(bkIdx)
+                )
+
+                for chapter in book:
+                    chIdx += 1
+                    spineXml += """
+                <itemref idref="chapter{idx}" />""".format(
+                        idx = str(chIdx)
+                    )
+
         return spineXml
 
 
     def generate_TOC_HTML(self):
         tocHtml = ""
+        prtIdx = 0
+        bkIdx = 0
         chIdx = 0
         for part in self.__tome:
+            prtIdx += 1
+            if part.title() is not None:
+                title = self.generate_any_TITLE_SEP_HTML(part) + htmlEscape(self.generate_any_TITLE(part))
+                tocHtml += """
+                <li class='bodymatter part' id='tocPart{idx}'>
+                    <a href="{path}">
+                        Part {idx}{title}
+                    </a>
+                </li>""".format(
+                    idx = str(prtIdx),
+                    path = self.partFileName(prtIdx),
+                    title = title
+                )
+                
+            for book in part:
+                bkIdx += 1
+                if book.title() is not None:
+                    title = self.generate_any_TITLE_SEP_HTML(book) + htmlEscape(self.generate_any_TITLE(book))
+                    tocHtml += """
+                    <li class='bodymatter book' id='tocBook{idx}'>
+                        <a href="{path}">
+                            Book {idx}{title}
+                        </a>
+                    </li>""".format(
+                        idx = str(bkIdx),
+                        path = self.bookFileName(bkIdx),
+                        title = title
+                    )
+
+                for chapter in book:
+                    chIdx += 1
+                    title = self.generate_any_TITLE_SEP_HTML(chapter) + htmlEscape(self.generate_any_TITLE(chapter))
+
+                    tocHtml += """
+                        <li class='bodymatter chapter' id='tocChapter{idx}'>
+                            <a href="{path}">
+                                Chapter {idx}{title}
+                            </a>
+                        </li>""".format(
+                        idx = str(chIdx),
+                        path = self.chapterFileName(chIdx),
+                        title = title
+                    )
+
+        return tocHtml
+        
+
+
+    def generate_NCX_XML(self):
+        ncxXml = ""
+        chIdx = 0
+        #TODO: XXX: Left off here.
+        for part in self.__tome:
             for book in part:
                 for chapter in book:
                     chIdx += 1
                     chUid = self.__chUid(chIdx)
                     chNum = str(chIdx)
 
-                    title = self.generate_CHAP_TITLE_SEP_HTML(chapter) + htmlEscape(self.generate_CHAP_TITLE(chapter))
-
-                    tocHtml += """
-                <li class='bodymatter chapter' id='tocChapter{chNum}'>
-                    <a href="chapter{chUid}.xhtml">
-                        Chapter {chNum}{title}
-                    </a>
-                </li>""".format(
-                        chNum = chNum,
-                        chUid = chUid,
-                        title = title
-                    )
-
-        return tocHtml
-        
-
-
-    def generate_NCX_XML(self):
-        ncxXml = ""
-        chIdx = 0
-        for part in self.__tome:
-            for book in part:
-                for chapter in book:
-                    chIdx += 1
-                    chUid = self.__chUid(chIdx)
-                    chNum = str(chIdx)
-
-                    title = self.generate_CHAP_SHORTMARK_SEP_HTML(chapter) + self.generate_CHAP_SHORTMARK(chapter)
+                    title = self.generate_any_SHORTMARK_SEP_HTML(chapter) + self.generate_any_SHORTMARK(chapter)
 
                     ### Add an entry for the chapter.
                     ncxXml += """
                     chUid = self.__chUid(chIdx)
                     chNum = str(chIdx)
 
-                    title = self.generate_CHAP_SHORTMARK_SEP_HTML(chapter) + self.generate_CHAP_SHORTMARK(chapter)
+                    title = self.generate_any_SHORTMARK_SEP_HTML(chapter) + self.generate_any_SHORTMARK(chapter)
 
                     ### Add an entry for the chapter.
                     navHtml += """