diff --git a/CHANGES b/CHANGES index 4e850e894..5b9835446 100644 --- a/CHANGES +++ b/CHANGES @@ -46,6 +46,7 @@ Bugs fixed * #2304: auto line breaks in latexpdf codeblocks * #1534: Word wrap long lines in Latex verbatim blocks * #2460: too much white space on top of captioned literal blocks in PDF output +* Show error reason when multiple math extensions are loaded (ref: #2499) Release 1.4.1 (released Apr 12, 2016) diff --git a/sphinx/ext/imgmath.py b/sphinx/ext/imgmath.py index 40a9c1402..73a405ceb 100644 --- a/sphinx/ext/imgmath.py +++ b/sphinx/ext/imgmath.py @@ -22,7 +22,7 @@ from six import text_type from docutils import nodes import sphinx -from sphinx.errors import SphinxError +from sphinx.errors import SphinxError, ExtensionError from sphinx.util.png import read_png_depth, write_png_depth from sphinx.util.osutil import ensuredir, ENOENT, cd from sphinx.util.pycompat import sys_encoding @@ -267,7 +267,11 @@ def html_visit_displaymath(self, node): def setup(app): - mathbase_setup(app, (html_visit_math, None), (html_visit_displaymath, None)) + try: + mathbase_setup(app, (html_visit_math, None), (html_visit_displaymath, None)) + except ExtensionError: + raise ExtensionError('sphinx.ext.mathjax: other math package is already installed') + app.add_config_value('imgmath_image_format', 'png', 'html') app.add_config_value('imgmath_dvipng', 'dvipng', 'html') app.add_config_value('imgmath_dvisvgm', 'dvisvgm', 'html') diff --git a/sphinx/ext/mathjax.py b/sphinx/ext/mathjax.py index 5d1f82408..43f28e376 100644 --- a/sphinx/ext/mathjax.py +++ b/sphinx/ext/mathjax.py @@ -15,6 +15,7 @@ from docutils import nodes import sphinx from sphinx.application import ExtensionError +from sphinx.errors import ExtensionError from sphinx.ext.mathbase import setup_math as mathbase_setup @@ -63,7 +64,11 @@ def builder_inited(app): def setup(app): - mathbase_setup(app, (html_visit_math, None), (html_visit_displaymath, None)) + try: + mathbase_setup(app, (html_visit_math, None), (html_visit_displaymath, None)) + except ExtensionError: + raise ExtensionError('sphinx.ext.mathjax: other math package is already installed') + # more information for mathjax secure url is here: # http://docs.mathjax.org/en/latest/start.html#secure-access-to-the-cdn app.add_config_value('mathjax_path', @@ -72,4 +77,5 @@ def setup(app): app.add_config_value('mathjax_inline', [r'\(', r'\)'], 'html') app.add_config_value('mathjax_display', [r'\[', r'\]'], 'html') app.connect('builder-inited', builder_inited) + return {'version': sphinx.__display_version__, 'parallel_read_safe': True} diff --git a/sphinx/ext/pngmath.py b/sphinx/ext/pngmath.py index a2801bd1f..8707ca383 100644 --- a/sphinx/ext/pngmath.py +++ b/sphinx/ext/pngmath.py @@ -23,7 +23,7 @@ from six import text_type from docutils import nodes import sphinx -from sphinx.errors import SphinxError +from sphinx.errors import SphinxError, ExtensionError from sphinx.util.png import read_png_depth, write_png_depth from sphinx.util.osutil import ensuredir, ENOENT, cd from sphinx.util.pycompat import sys_encoding @@ -239,7 +239,11 @@ def html_visit_displaymath(self, node): def setup(app): app.warn('sphinx.ext.pngmath has been deprecated. Please use sphinx.ext.imgmath instead.') - mathbase_setup(app, (html_visit_math, None), (html_visit_displaymath, None)) + try: + mathbase_setup(app, (html_visit_math, None), (html_visit_displaymath, None)) + except ExtensionError: + raise ExtensionError('sphinx.ext.mathjax: other math package is already installed') + app.add_config_value('pngmath_dvipng', 'dvipng', 'html') app.add_config_value('pngmath_latex', 'latex', 'html') app.add_config_value('pngmath_use_preview', False, 'html')