summaryrefslogtreecommitdiff
path: root/sphinx/ext/jsmath.py
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2018-05-17 00:57:09 +0900
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2018-07-28 18:20:11 +0900
commitdd65d00f2996419c82158818bee592cae869fc80 (patch)
tree9c38c8cb3c2484b08c718a54982ad8d791ca51b4 /sphinx/ext/jsmath.py
parent2f5a66d647cfc549c9598e6d20b3f37dfb2b21dc (diff)
downloadsphinx-git-dd65d00f2996419c82158818bee592cae869fc80.tar.gz
Implement math_renderer framework
Diffstat (limited to 'sphinx/ext/jsmath.py')
-rw-r--r--sphinx/ext/jsmath.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/sphinx/ext/jsmath.py b/sphinx/ext/jsmath.py
index 809ce0424..5dbb20fba 100644
--- a/sphinx/ext/jsmath.py
+++ b/sphinx/ext/jsmath.py
@@ -15,7 +15,6 @@ from docutils import nodes
import sphinx
from sphinx.errors import ExtensionError
from sphinx.ext.mathbase import get_node_equation_number
-from sphinx.ext.mathbase import setup_math as mathbase_setup
from sphinx.locale import _
if False:
@@ -61,7 +60,9 @@ def html_visit_displaymath(self, node):
def builder_inited(app):
# type: (Sphinx) -> None
- if not app.config.jsmath_path:
+ if app.builder.format != 'html' or app.builder.math_renderer_name != 'jsmath': # type: ignore # NOQA
+ pass
+ elif 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':
@@ -70,10 +71,9 @@ def builder_inited(app):
def setup(app):
# type: (Sphinx) -> Dict[unicode, Any]
- try:
- mathbase_setup(app, (html_visit_math, None), (html_visit_displaymath, None))
- except ExtensionError:
- raise ExtensionError('sphinx.ext.jsmath: other math package is already loaded')
+ app.add_html_math_renderer('jsmath',
+ (html_visit_math, None),
+ (html_visit_displaymath, None))
app.add_config_value('jsmath_path', '', False)
app.connect('builder-inited', builder_inited)