From dedcd05910aa51b5eefa5ec3f6dfcc5b7bfc3890 Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Thu, 12 Jul 2018 11:47:03 -0400 Subject: [PATCH] Configure MathJax when it's loaded by XBlocks in studio When using RequireJS, MathJax was configured in an `init` function in the RequireJS config. With the switch to Webpack and $script, that configuration needed to be moved to the dynamic loading done by $script. [EDUCATOR-3160] --- cms/djangoapps/pipeline_js/js/xmodule.js | 25 +++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/cms/djangoapps/pipeline_js/js/xmodule.js b/cms/djangoapps/pipeline_js/js/xmodule.js index 881b6482a1..3acc0958e0 100644 --- a/cms/djangoapps/pipeline_js/js/xmodule.js +++ b/cms/djangoapps/pipeline_js/js/xmodule.js @@ -16,10 +16,33 @@ define( window.$ = $; window._ = _; + $script( '//cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js' + '?config=TeX-MML-AM_SVG&delayStartupUntil=configured', - 'mathjax' + 'mathjax', + function() { + window.MathJax.Hub.Config({ + tex2jax: { + inlineMath: [ + ['\\(', '\\)'], + ['[mathjaxinline]', '[/mathjaxinline]'] + ], + displayMath: [ + ['\\[', '\\]'], + ['[mathjax]', '[/mathjax]'] + ] + } + }); + + // In order to eliminate all flashing during interactive + // preview, it is necessary to set processSectionDelay to 0 + // (remove delay between input and output phases). This + // effectively disables fast preview, regardless of + // the fast preview setting as shown in the context menu. + window.MathJax.Hub.processSectionDelay = 0; + window.MathJax.Hub.Configured(); + } ); window.CodeMirror = CodeMirror; window.RequireJS = {