Last active
February 10, 2017 16:07
-
-
Save pkra/36f5873e5d57f11a87858fab6412ff87 to your computer and use it in GitHub Desktop.
A snippet for wordpress's math PNGs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
var images = document.querySelectorAll('img.latex'); | |
for (var i = 0; i < images.length; i++){ | |
var image = images[i]; | |
tex = image.getAttribute('alt'); | |
var preview = document.createElement('span'); | |
preview.setAttribute('class','MathJax_Preview'); | |
image.parentNode.insertBefore(preview, image); | |
preview.appendChild(image); | |
var script = document.createElement('script'); | |
script.type = 'math/tex'; | |
script.text= tex; // strip dollars from TeX string | |
preview.parentNode.insertBefore(script, preview.nextSibling) | |
} | |
var mathjax = document.createElement('script'); | |
mathjax.src= 'https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_CHTML-full'; | |
document.head.appendChild(mathjax); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment