math.js 860 B

12345678910111213141516171819202122232425262728293031323334353637
  1. /**
  2. * A plugin which enables rendering of math equations inside
  3. * of reveal.js slides. Essentially a thin wrapper for MathJax.
  4. *
  5. * @author Hakim El Hattab
  6. */
  7. (function(){
  8. var head = document.querySelector( 'head' );
  9. var script = document.createElement( 'script' );
  10. script.type = 'text/javascript';
  11. script.src = 'http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_SVG-full';
  12. // Detect when the script has loaded
  13. script.onload = onScriptLoad;
  14. script.onreadystatechange = function() {
  15. if ( this.readyState === 'loaded' ) {
  16. onScriptLoad.call();
  17. }
  18. }
  19. head.appendChild( script );
  20. function onScriptLoad() {
  21. MathJax.Hub.Config({
  22. messageStyle: 'none',
  23. tex2jax: { inlineMath: [['$','$'],['\\(','\\)']] }
  24. });
  25. Reveal.addEventListener( 'slidechanged', function( event ) {
  26. MathJax.Hub.Rerender();
  27. } );
  28. }
  29. })();