Last active
November 8, 2016 13:12
-
-
Save tillahoffmann/e03a7a9cf4059e92774b to your computer and use it in GitHub Desktop.
JavaScript to add MathJax support to Simplenote web app.
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
if (window.MathJax === undefined) { | |
//Add the MathJax script | |
var script = document.createElement("script"); | |
script.type = "text/javascript"; | |
script.src = "//cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"; | |
var config = 'MathJax.Hub.Config({' + 'extensions: ["tex2jax.js"],' + 'tex2jax: { inlineMath: [["$","$"],["\\\\\\\\\\\\(","\\\\\\\\\\\\)"]], displayMath: [["$","$"],["\\\\[","\\\\]"]], processEscapes: true },' + 'jax: ["input/TeX","output/HTML-CSS"]' + '});'; | |
if (window.opera) { | |
script.innerHTML = config | |
} else { | |
script.text = config | |
} | |
document.getElementsByTagName("head")[0].appendChild(script); | |
//Add the reload tag | |
script = document.createElement("script"); | |
script.text = 'document.getElementById("view_mode_markdown").onclick = ' + 'function() {MathJax.Hub.Queue(["Typeset", MathJax.Hub, "static_content"]);};'; | |
document.getElementsByTagName("head")[0].appendChild(script); | |
} else { | |
//Render the content | |
MathJax.Hub.Queue(["Typeset", MathJax.Hub, "static_content"]); | |
} |
I use the console in the developer tools (Firefox) to work it.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It looks great but I could not get it to work. Can you help please?