diff --git a/render_math/Readme.md b/render_math/Readme.md index 45d600a..9a4412f 100644 --- a/render_math/Readme.md +++ b/render_math/Readme.md @@ -106,6 +106,12 @@ sequences. **Default Value**: True rendering LaTex. If set to `Tex`, then the TeX code is used as the preview (which will be visible until it is processed by MathJax). **Default Value**: `Tex` * `color`: controls the color of the mathjax rendered font. **Default Value**: `black` + * `ssl`: specifies if ssl should be used to load MathJax engine. Can be set to one +of three things + * `auto`: **Default Value** will automatically determine what protodol to use +based on current protocol of the site. + * `force`: will force ssl to be used. + * `off`: will ensure that ssl is not used For example, in settings.py, the following would make math render in blue and displaymath align to the left: diff --git a/render_math/math.py b/render_math/math.py index da595c7..c6b71f0 100644 --- a/render_math/math.py +++ b/render_math/math.py @@ -167,7 +167,6 @@ def process_summary(instance, ignore_within): return match.group(1) + match.group(4) # check for partial math tags at end. These must be removed - summary = _MATH_INCOMPLETE_TAG_REGEX.sub(incomplete_end_latex_tag, summary) if process_summary.altered_summary or insert_mathjax: @@ -199,6 +198,11 @@ def process_settings(settings): _MATHJAX_SETTINGS['latex_preview'] = 'TeX' # controls what user sees while waiting for LaTex to render _MATHJAX_SETTINGS['color'] = 'black' # controls color math is rendered in + # Source for MathJax: default (below) is to automatically determine what protocol to use + _MATHJAX_SETTINGS['source'] = """'https:' == document.location.protocol + ? 'https://c328740.ssl.cf1.rackcdn.com/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML' + : 'http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'""" + # This next setting controls whether the mathjax script should be automatically # inserted into the content. The mathjax script will not be inserted into # the content if no math is detected. For summaries that are present in the @@ -239,6 +243,12 @@ def process_settings(settings): if key == 'color' and isinstance(value, str): _MATHJAX_SETTINGS[key] = value + if key == 'ssl' and isinstance(value, str): + if value == 'off': + _MATHJAX_SETTINGS['source'] = "'http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'" + + if value == 'force': + _MATHJAX_SETTINGS['source'] = "'https://c328740.ssl.cf1.rackcdn.com/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'" def process_content(instance): """Processes content, with logic to ensure that typogrify does not clash diff --git a/render_math/mathjax_script.txt b/render_math/mathjax_script.txt index e1f3f12..b9c75c3 100644 --- a/render_math/mathjax_script.txt +++ b/render_math/mathjax_script.txt @@ -3,9 +3,7 @@ var mathjaxscript = document.createElement('script'); mathjaxscript.id = 'mathjaxscript_pelican_#%@#$@#'; mathjaxscript.type = 'text/javascript'; - mathjaxscript.src = 'https:' == document.location.protocol - ? 'https://c328740.ssl.cf1.rackcdn.com/mathjax/latest/MathJax.js' - : 'http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'; + mathjaxscript.src = {source}; mathjaxscript[(window.opera ? "innerHTML" : "text")] = "MathJax.Hub.Config({{" + " config: ['MMLorHTML.js']," +