diff options
| author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2018-11-01 01:24:12 +0900 |
|---|---|---|
| committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2018-11-01 01:24:12 +0900 |
| commit | 8b687ac30481e7204677138d8f2f3b49e354963e (patch) | |
| tree | 7723d959db00959780dc7f9f56c673cd47d7cd97 /sphinx/ext/jsmath.py | |
| parent | e8e0f93c3fc7a9f8be4a91c13c6ec49672347a1e (diff) | |
| parent | f4d7b2e60e4352aac6e19dad16f39328bf493ff4 (diff) | |
| download | sphinx-git-8b687ac30481e7204677138d8f2f3b49e354963e.tar.gz | |
Merge branch '1.8'
Diffstat (limited to 'sphinx/ext/jsmath.py')
| -rw-r--r-- | sphinx/ext/jsmath.py | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/sphinx/ext/jsmath.py b/sphinx/ext/jsmath.py index 0ee42050c..3babd408e 100644 --- a/sphinx/ext/jsmath.py +++ b/sphinx/ext/jsmath.py @@ -21,6 +21,7 @@ if False: # For type annotation from typing import Any, Dict # NOQA from sphinx.application import Sphinx # NOQA + from sphinx.environment import BuildEnvironment # NOQA def html_visit_math(self, node): @@ -58,14 +59,16 @@ def html_visit_displaymath(self, node): raise nodes.SkipNode -def builder_inited(app): - # type: (Sphinx) -> None +def install_jsmath(app, env): + # type: (Sphinx, BuildEnvironment) -> None if app.builder.format != 'html' or app.builder.math_renderer_name != 'jsmath': # type: ignore # NOQA - pass - elif not app.config.jsmath_path: + return + if not app.config.jsmath_path: raise ExtensionError('jsmath_path config value must be set for the ' 'jsmath extension to work') - if app.builder.format == 'html': + + if env.get_domain('math').has_equations(): # type: ignore + # Enable jsmath only if equations exists app.builder.add_js_file(app.config.jsmath_path) # type: ignore @@ -76,5 +79,5 @@ def setup(app): (html_visit_displaymath, None)) app.add_config_value('jsmath_path', '', False) - app.connect('builder-inited', builder_inited) + app.connect('env-check-consistency', install_jsmath) return {'version': sphinx.__display_version__, 'parallel_read_safe': True} |
