Commits

Roland Meister  committed d8d4c39

Change algorithm for EpubBuilder.make_id

The new algorithm no longer derives the id from the name (which
may contain illegal characters for ids) but uses a cache to
associate names to ids.

  • Participants
  • Parent commits d1f7714

Comments (0)

Files changed (1)

File sphinx/builders/epub.py

         return self.config.epub_theme, self.config.epub_theme_options
 
     # generic support functions
-    def make_id(self, name):
-        """Replace all characters not allowed for (X)HTML ids."""
-        return name.replace('/', '_').replace(' ', '')
+    def make_id(self, name, id_cache={}):
+        # id_cache is intentionally mutable
+        """Return a unique id for name."""
+        id = id_cache.get(name)
+        if not id:
+            id = 'epub-%d' % self.env.new_serialno('epub')
+            id_cache[name] = id
+        return id
 
     def esc(self, name):
         """Replace all characters not allowed in text an attribute values."""