diff options
Diffstat (limited to 'sphinx/ext/mathbase.py')
-rw-r--r-- | sphinx/ext/mathbase.py | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/sphinx/ext/mathbase.py b/sphinx/ext/mathbase.py index 549ca30cd..8370c923e 100644 --- a/sphinx/ext/mathbase.py +++ b/sphinx/ext/mathbase.py @@ -10,6 +10,7 @@ """ from docutils import nodes, utils +from docutils.nodes import make_id from docutils.parsers.rst import Directive, directives from sphinx.roles import XRefRole @@ -51,7 +52,8 @@ class MathDomain(Domain): label = 'mathematics' initial_data = { - 'objects': {}, # labelid -> (docname, eqno) + 'nameids': {}, # label -> equation ID + 'objects': {}, # equation ID -> (docname, eqno) } # type: Dict[unicode, Dict[unicode, Tuple[unicode, int]]] dangling_warnings = { 'eq': 'equation not found: %(target)s', @@ -59,9 +61,9 @@ class MathDomain(Domain): def clear_doc(self, docname): # type: (unicode) -> None - for labelid, (doc, eqno) in list(self.data['objects'].items()): + for equation_id, (doc, eqno) in list(self.data['objects'].items()): if doc == docname: - del self.data['objects'][labelid] + del self.data['objects'][equation_id] def merge_domaindata(self, docnames, otherdata): # type: (Iterable[unicode], Dict) -> None @@ -81,8 +83,8 @@ class MathDomain(Domain): return newnode else: title = nodes.Text("(%d)" % number) - return make_refnode(builder, fromdocname, docname, - "equation-" + target, title) + node_id = make_id('equation-%s' % target) + return make_refnode(builder, fromdocname, docname, node_id, title) else: return None @@ -226,7 +228,8 @@ class MathDirective(Directive): node['number'] = eqno # add target node - target = nodes.target('', '', ids=['equation-' + node['label']]) + node_id = make_id('equation-%s' % node['label']) + target = nodes.target('', '', ids=[node_id]) self.state.document.note_explicit_target(target) ret.insert(0, target) except UserWarning as exc: |