aboutsummaryrefslogtreecommitdiff
path: root/plugin
diff options
context:
space:
mode:
authorHakim El Hattab <hakim.elhattab@gmail.com>2018-10-08 08:41:08 +0200
committerGitHub <noreply@github.com>2018-10-08 08:41:08 +0200
commit5890f602b32d4f7ec31d9f6c4b4e5e17b0866b96 (patch)
treefc5cc251b1aa4e7e78a0cfb10e24be0c364db856 /plugin
parente7a365255f0ceddf87d41f0debca19a074e754e9 (diff)
parentb2d532ea28eaaf0b7b2cf225c713c8a8d3f4a3bf (diff)
downloadperl-software-in-gnu-guix-5890f602b32d4f7ec31d9f6c4b4e5e17b0866b96.tar
perl-software-in-gnu-guix-5890f602b32d4f7ec31d9f6c4b4e5e17b0866b96.tar.gz
Merge pull request #2090 from bnjmnt4n/math
Allow users to customise MathJax options.
Diffstat (limited to 'plugin')
-rwxr-xr-xplugin/math/math.js39
1 files changed, 28 insertions, 11 deletions
diff --git a/plugin/math/math.js b/plugin/math/math.js
index 7867376..29445cd 100755
--- a/plugin/math/math.js
+++ b/plugin/math/math.js
@@ -7,19 +7,26 @@
var RevealMath = window.RevealMath || (function(){
var options = Reveal.getConfig().math || {};
- options.mathjax = options.mathjax || 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js';
- options.config = options.config || 'TeX-AMS_HTML-full';
- options.tex2jax = options.tex2jax || {
- inlineMath: [['$','$'],['\\(','\\)']] ,
- skipTags: ['script','noscript','style','textarea','pre'] };
+ var mathjax = options.mathjax || 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js';
+ var config = options.config || 'TeX-AMS_HTML-full';
+ var url = mathjax + '?config=' + config;
- loadScript( options.mathjax + '?config=' + options.config, function() {
+ var defaultOptions = {
+ messageStyle: 'none',
+ tex2jax: {
+ inlineMath: [ [ '$', '$' ], [ '\\(', '\\)' ] ],
+ skipTags: [ 'script', 'noscript', 'style', 'textarea', 'pre' ]
+ },
+ skipStartupTypeset: true
+ };
- MathJax.Hub.Config({
- messageStyle: 'none',
- tex2jax: options.tex2jax,
- skipStartupTypeset: true
- });
+ defaults( options, defaultOptions );
+ defaults( options.tex2jax, defaultOptions.tex2jax );
+ options.mathjax = options.config = null;
+
+ loadScript( url, function() {
+
+ MathJax.Hub.Config( options );
// Typeset followed by an immediate reveal.js layout since
// the typesetting process could affect slide height
@@ -35,6 +42,16 @@ var RevealMath = window.RevealMath || (function(){
} );
+ function defaults( options, defaultOptions ) {
+
+ for ( var i in defaultOptions ) {
+ if ( !options.hasOwnProperty( i ) ) {
+ options[i] = defaultOptions[i];
+ }
+ }
+
+ }
+
function loadScript( url, callback ) {
var head = document.querySelector( 'head' );