Created
August 26, 2017 18:33
-
-
Save danthedaniel/157bb1ee76ae236d43258e38f9e5764f to your computer and use it in GitHub Desktop.
Tiny automatic KaTeX rendering.
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
// Automatically render all elements of type pre.math as latex equations. | |
(function() { | |
var math_elements = document.querySelectorAll('pre.math'); | |
math_elements.forEach(function(e) { | |
e.innerHTML = katex.renderToString(e.innerText); | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In my opinion, this is significantly better than using the massive auto-render.js that KaTeX provides. You don't get the convenience of automatically rending LaTeX inside of text blocks, but you save over 10KB and an extra HTTP request.