mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
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.
This commit is contained in:
parent
ce6b8fff70
commit
bfc03b10ad
@ -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."""
|
||||
|
Loading…
Reference in New Issue
Block a user