Anonymous avatar Anonymous committed 56ac3c3

Working with guides

Comments (0)

Files changed (1)


   <spine toc="ncx">
-  <guilde>
+  <guide>
 _spine_template = u'''\
     <itemref idref="%(idref)s" />'''
+_guide_template = u'''\
+    <reference type="%(type)" title="%(title)" href="%(uri)" />'''
 _toctree_template = u'toctree-l%d'
 _link_target_template = u' [%(uri)s]'
-    def content_metadata(self, files, spine):
+    def content_metadata(self, files, spine, guide):
         """Create a dictionary with all metadata for the content.opf
         file properly escaped.
         metadata['date'] = self.esc(time.strftime('%Y-%m-%d'))
         metadata['files'] = files
         metadata['spine'] = spine
+        metadata['guide'] = guide
         return metadata
     def build_content(self, outdir, outname):
                         os.path.splitext(_coverpage_name)[0], ctx, tmpl)
+        guide = []
+        if self.config.epub_guide:
+            for type, title, uri in self.config.epub_guide:
+                guide.append(_guide_template % {
+                        'type': self.esc(type),
+                        'title': self.esc(title),
+                        'uri': self.esc(uri)
+                        })
         projectfiles = '\n'.join(projectfiles)
         spine = '\n'.join(spine)
+        guide = '\n'.join(guide)
         # write the project file
         f =, outname), 'w', 'utf-8')
             f.write(content_tmpl % \
-                self.content_metadata(projectfiles, spine))
+                self.content_metadata(projectfiles, spine, guide))
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.