diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2018-01-20 02:22:35 +0900 |
---|---|---|
committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2018-01-20 02:22:35 +0900 |
commit | 8b8c3d173637fa8c69fd30518a4a79e7260f17ae (patch) | |
tree | 4e1b70c40d7e00106765f7f4253877d0ab773108 /sphinx/ext/mathbase.py | |
parent | 80a4b272addaaf76c9e04d80080543ca33503bff (diff) | |
parent | 2b89f72d54acf1503ac4f9a79e22daf9882d6b2d (diff) | |
download | sphinx-git-8b8c3d173637fa8c69fd30518a4a79e7260f17ae.tar.gz |
Merge branch 'stable' into 1.7-release
Diffstat (limited to 'sphinx/ext/mathbase.py')
-rw-r--r-- | sphinx/ext/mathbase.py | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/sphinx/ext/mathbase.py b/sphinx/ext/mathbase.py index f2e15b485..d9bc3726b 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.config import string_classes @@ -55,7 +56,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', @@ -63,9 +65,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 @@ -84,10 +86,10 @@ class MathDomain(Domain): newnode['target'] = target return newnode else: + node_id = make_id('equation-%s' % target) if env.config.math_numfig and env.config.numfig: if docname in env.toc_fignumbers: - id = 'equation-' + target - number = env.toc_fignumbers[docname]['displaymath'].get(id, ()) + number = env.toc_fignumbers[docname]['displaymath'].get(node_id, ()) number = '.'.join(map(str, number)) else: number = '' @@ -98,8 +100,8 @@ class MathDomain(Domain): logger.warning('Invalid math_eqref_format: %r', exc, location=node) title = nodes.Text("(%d)" % number) - return make_refnode(builder, fromdocname, docname, - "equation-" + target, title) + title = nodes.Text("(%d)" % number) + return make_refnode(builder, fromdocname, docname, node_id, title) else: return None @@ -260,7 +262,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: |