From 57053a4171a25874145a70348d2fd1eb54ea12f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20Do=CC=88rr?= Date: Sun, 6 Oct 2013 14:03:43 +0200 Subject: [PATCH] Add math gimmick via MathJax --- Gruntfile.js | 1 + js/gimmicks/math.js | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 js/gimmicks/math.js diff --git a/Gruntfile.js b/Gruntfile.js index 98869c94..774d3833 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -46,6 +46,7 @@ module.exports = function(grunt) { 'js/gimmicks/googlemaps.js', 'js/gimmicks/highlight.js', 'js/gimmicks/image_linker.js', + 'js/gimmicks/math.js', // 'js/gimmicks/leaflet.js', 'js/gimmicks/themechooser.js', 'js/gimmicks/twitter.js', diff --git a/js/gimmicks/math.js b/js/gimmicks/math.js new file mode 100644 index 00000000..664ed01d --- /dev/null +++ b/js/gimmicks/math.js @@ -0,0 +1,18 @@ +(function($) { + var mathGimmick = { + name: 'math', + once: function() { + $.md.linkGimmick(this, 'math', load_mathjax); + } + }; + $.md.registerGimmick(mathGimmick); + + function load_mathjax($links, opt, ref) { + $links.remove(); + var script = document.createElement('script'); + script.type = 'text/javascript'; + script.src = '//cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'; + document.getElementsByTagName('head')[0].appendChild(script); + } + +}(jQuery));