summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoland Meister <devnull@localhost>2013-06-06 21:27:53 +0200
committerRoland Meister <devnull@localhost>2013-06-06 21:27:53 +0200
commit454a2e4efaecc6c42a83c7ffd00d83662eb30762 (patch)
treeceacf3c4a2273d841ef186d605c1f49a39b63cc8
parent57f19b8b217b7df797256f69dad5a15d7c9edc1f (diff)
downloadsphinx-454a2e4efaecc6c42a83c7ffd00d83662eb30762.tar.gz
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.
-rw-r--r--sphinx/builders/epub.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/sphinx/builders/epub.py b/sphinx/builders/epub.py
index a35a72b5..e8e5f081 100644
--- a/sphinx/builders/epub.py
+++ b/sphinx/builders/epub.py
@@ -194,9 +194,14 @@ class EpubBuilder(StandaloneHTMLBuilder):
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."""