From 97941530e38d1bbcf40db539055d13f8e4095e6c Mon Sep 17 00:00:00 2001 From: David Baumgold Date: Fri, 18 Oct 2013 11:39:29 -0400 Subject: [PATCH] Configure MathJax using require.js --- cms/static/coffee/spec/main.coffee | 16 ++++++++++++++-- cms/static/coffee/spec/main_squire.coffee | 16 ++++++++++++++-- cms/templates/base.html | 19 +++++++++++++++++-- 3 files changed, 45 insertions(+), 6 deletions(-) diff --git a/cms/static/coffee/spec/main.coffee b/cms/static/coffee/spec/main.coffee index 4251307892..2f08f5b45e 100644 --- a/cms/static/coffee/spec/main.coffee +++ b/cms/static/coffee/spec/main.coffee @@ -33,7 +33,7 @@ requirejs.config({ "draggabilly": "xmodule_js/common_static/js/vendor/draggabilly.pkgd", "domReady": "xmodule_js/common_static/js/vendor/domReady", - "mathjax": "//edx-static.s3.amazonaws.com/mathjax-MathJax-727332c/MathJax.js?config=TeX-MML-AM_HTMLorMML-full", + "mathjax": "//edx-static.s3.amazonaws.com/mathjax-MathJax-727332c/MathJax.js?config=TeX-MML-AM_HTMLorMML-full&delayStartupUntil=configured", "youtube": "//www.youtube.com/player_api?noext", "tender": "//edxedge.tenderapp.com/tender_widget" @@ -114,7 +114,19 @@ requirejs.config({ exports: "tinymce" }, "mathjax": { - exports: "MathJax" + exports: "MathJax", + init: -> + MathJax.Hub.Config + tex2jax: + inlineMath: [ + ["\\(","\\)"], + ['[mathjaxinline]','[/mathjaxinline]'] + ] + displayMath: [ + ["\\[","\\]"], + ['[mathjax]','[/mathjax]'] + ] + MathJax.Hub.Configured() }, "xmodule": { exports: "XModule" diff --git a/cms/static/coffee/spec/main_squire.coffee b/cms/static/coffee/spec/main_squire.coffee index ee23792509..1589abb964 100644 --- a/cms/static/coffee/spec/main_squire.coffee +++ b/cms/static/coffee/spec/main_squire.coffee @@ -33,7 +33,7 @@ requirejs.config({ "draggabilly": "xmodule_js/common_static/js/vendor/draggabilly.pkgd", "domReady": "xmodule_js/common_static/js/vendor/domReady", - "mathjax": "//edx-static.s3.amazonaws.com/mathjax-MathJax-727332c/MathJax.js?config=TeX-MML-AM_HTMLorMML-full", + "mathjax": "//edx-static.s3.amazonaws.com/mathjax-MathJax-727332c/MathJax.js?config=TeX-MML-AM_HTMLorMML-full&delayStartupUntil=configured", "youtube": "//www.youtube.com/player_api?noext", "tender": "//edxedge.tenderapp.com/tender_widget.js" @@ -114,7 +114,19 @@ requirejs.config({ exports: "tinymce" }, "mathjax": { - exports: "MathJax" + exports: "MathJax", + init: -> + MathJax.Hub.Config + tex2jax: + inlineMath: [ + ["\\(","\\)"], + ['[mathjaxinline]','[/mathjaxinline]'] + ] + displayMath: [ + ["\\[","\\]"], + ['[mathjax]','[/mathjax]'] + ] + MathJax.Hub.Configured(); }, "xmodule": { exports: "XModule" diff --git a/cms/templates/base.html b/cms/templates/base.html index ff2fcf9b01..680f54ea04 100644 --- a/cms/templates/base.html +++ b/cms/templates/base.html @@ -69,7 +69,7 @@ var require = { // externally hosted files "tender": "//edxedge.tenderapp.com/tender_widget", - "mathjax": "//edx-static.s3.amazonaws.com/mathjax-MathJax-727332c/MathJax.js?config=TeX-MML-AM_HTMLorMML-full", + "mathjax": "//edx-static.s3.amazonaws.com/mathjax-MathJax-727332c/MathJax.js?config=TeX-MML-AM_HTMLorMML-full&delayStartupUntil=configured", // youtube URL does not end in ".js". We add "?noext" to the path so // that require.js adds the ".js" to the query component of the URL, // and leaves the path component intact. @@ -157,7 +157,22 @@ var require = { exports: "tinymce" }, "mathjax": { - exports: "MathJax" + exports: "MathJax", + init: function() { + MathJax.Hub.Config({ + tex2jax: { + inlineMath: [ + ["\\(","\\)"], + ['[mathjaxinline]','[/mathjaxinline]'] + ], + displayMath: [ + ["\\[","\\]"], + ['[mathjax]','[/mathjax]'] + ] + } + }); + MathJax.Hub.Configured(); + } }, "coffee/src/main": {